Schemas & rules

Versioned extraction schemas and validation rules.

Active schema and versions#

Active schema and versions

GET/api/v2/queues/{id}/schema

Requires schemas:read on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/queues/{id}/schema" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"active": true,
"versions": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"version": 1,
"name": "Invoices",
"createdAt": "2026-10-01T12:00:00.000Z",
"fieldCount": 1,
"documentType": "invoice",
"active": true
}
]
}

Publish a schema version#

Versions are immutable; this creates version n+1 and makes it active.

POST/api/v2/queues/{id}/schema

Requires schemas:edit on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Body

application/json
fieldsFieldDef[]required
instructionsstring | null
documentTypestring | null
namestring
descriptionstring | null

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/queues/{id}/schema" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fields": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"type": "string",
"description": "Supplier invoices from the accounts payable mailbox."
}
],
"instructions": "Dates are day-first. The total is the amount due, not the subtotal.",
"documentType": "invoice",
"name": "Invoices",
"description": "Supplier invoices from the accounts payable mailbox."
}'
Response201
{
"schema": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"description": "Supplier invoices from the accounts payable mailbox.",
"version": 1,
"fields": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"type": "string",
"description": "Supplier invoices from the accounts payable mailbox.",
"required": false,
"options": [
"option"
],
"children": [
[]
],
"itemType": "string",
"pattern": "pattern",
"min": 1,
"max": 1,
"format": "format",
"examples": [
"example"
],
"enrich": {
"dataset": "dataset",
"keyPath": "keyPath",
"column": "column",
"mode": "exact"
}
}
],
"instructions": "Dates are day-first. The total is the amount due, not the subtotal.",
"documentType": "invoice",
"createdAt": "2026-10-01T12:00:00.000Z",
"createdById": "clx9k2m4p0001qh8z3v7d5f2a"
}
}

Generate a schema#

Propose fields from a processed document (documentId, optional hint) or a description.

POST/api/v2/queues/{id}/schema/generate

Requires schemas:edit on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Body

application/json
documentIdstring
descriptionstring
hintstring

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/queues/{id}/schema/generate" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Supplier invoices from the accounts payable mailbox."
}'
Response200
{
"proposal": {
"fields": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"type": "string",
"description": "Supplier invoices from the accounts payable mailbox.",
"required": false,
"options": [
"option"
],
"children": [
[]
],
"itemType": "string",
"pattern": "pattern",
"min": 1,
"max": 1,
"format": "format",
"examples": [
"example"
],
"enrich": {
"dataset": "dataset",
"keyPath": "keyPath",
"column": "column",
"mode": "exact"
}
}
]
}
}

Restore an earlier schema version#

Saves a NEW version with the chosen version's fields, instructions and document type, and makes it active. History is never rewritten: documents keep the version they were extracted with, and the restore shows in the version list. List versions with GET /queues/{id}/schema; read one with GET /schemas/{schemaId}.

POST/api/v2/queues/{id}/schema/restore

Requires schemas:edit on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Body

application/json
schemaIdstringrequired
The earlier version of this queue's schema to bring back.

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/queues/{id}/schema/restore" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"schemaId": "clx9k2m4p0001qh8z3v7d5f2a"
}'
Response201
{
"schema": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"description": "Supplier invoices from the accounts payable mailbox.",
"version": 1,
"fields": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"type": "string",
"description": "Supplier invoices from the accounts payable mailbox.",
"required": false,
"options": [
"option"
],
"children": [
[]
],
"itemType": "string",
"pattern": "pattern",
"min": 1,
"max": 1,
"format": "format",
"examples": [
"example"
],
"enrich": {
"dataset": "dataset",
"keyPath": "keyPath",
"column": "column",
"mode": "exact"
}
}
],
"instructions": "Dates are day-first. The total is the amount due, not the subtotal.",
"documentType": "invoice",
"createdAt": "2026-10-01T12:00:00.000Z",
"createdById": "clx9k2m4p0001qh8z3v7d5f2a"
},
"restoredFrom": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"version": 1
}
}

List validation rules#

List validation rules

GET/api/v2/queues/{id}/rules

Requires rules:read on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/queues/{id}/rules" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"rules": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"fieldPath": "invoiceTotal",
"kind": "kind",
"config": "config",
"level": "error",
"enabled": true,
"order": 1
}
]
}

Create a validation rule#

Create a validation rule

POST/api/v2/queues/{id}/rules

Requires rules:edit on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Body

application/json
namestringrequired
fieldPathstring | null
kind"required" | "regex" | "range" | "length" | "enum" | "date_range" | "cross_field" | "expression" | "confidence" | "dataset_match" | "lookup"required
configRecord<string, any>
Default{}
level"error" | "warning"
Default"error"
enabledboolean
Defaulttrue
orderinteger

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/queues/{id}/rules" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices",
"fieldPath": "invoiceTotal",
"kind": "required",
"enabled": true
}'
Response201
{
"rule": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"fieldPath": "invoiceTotal",
"kind": "kind",
"config": "config",
"level": "error",
"enabled": true,
"order": 1
}
}

Get a validation rule#

Credentials in a lookup rule's config.auth come back masked.

GET/api/v2/queues/{id}/rules/{ruleId}

Requires rules:read on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.
ruleIdstringrequired
Rule id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/queues/{id}/rules/{ruleId}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"rule": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"fieldPath": "invoiceTotal",
"kind": "kind",
"config": "config",
"level": "error",
"enabled": true,
"order": 1
}
}

Update a validation rule#

Update a validation rule

PATCH/api/v2/queues/{id}/rules/{ruleId}

Requires rules:edit on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.
ruleIdstringrequired
Rule id.

Body

application/json
namestring
fieldPathstring | null
kind"required" | "regex" | "range" | "length" | "enum" | "date_range" | "cross_field" | "expression" | "confidence" | "dataset_match" | "lookup"
configRecord<string, any>
level"error" | "warning"
enabledboolean
orderinteger

Responses

OK

curl -X PATCH "https://docuflow.pendral.io/api/v2/queues/{id}/rules/{ruleId}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoices",
"fieldPath": "invoiceTotal",
"enabled": true
}'
Response200
{
"rule": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"fieldPath": "invoiceTotal",
"kind": "kind",
"config": "config",
"level": "error",
"enabled": true,
"order": 1
}
}

Delete a validation rule#

Delete a validation rule

DELETE/api/v2/queues/{id}/rules/{ruleId}

Requires rules:edit on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.
ruleIdstringrequired
Rule id.

Responses

OK

curl -X DELETE "https://docuflow.pendral.io/api/v2/queues/{id}/rules/{ruleId}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"ok": true
}

Test rules against values#

Evaluates the queue's rules (and schema constraints unless includeSchema: false) against sample values.

POST/api/v2/queues/{id}/rules/test

Requires rules:read on the queue it touches.queue-scoped

Path parameters

idstringrequired
Queue id.

Body

application/json
valuesRecord<string, any>required
includeSchemaboolean
Defaulttrue

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/queues/{id}/rules/test" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"values": {}
}'
Response200
{
"issues": {
"key": [
{
"level": "level",
"message": "message"
}
]
},
"count": 1
}

Get a schema version#

Get a schema version

GET/api/v2/schemas/{schemaId}

Requires schemas:read on the queue it touches.queue-scoped

Path parameters

schemaIdstringrequired
Schema id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/schemas/{schemaId}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"description": "Supplier invoices from the accounts payable mailbox.",
"version": 1,
"fields": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"type": "string",
"description": "Supplier invoices from the accounts payable mailbox.",
"required": false,
"options": [
"option"
],
"children": [
[]
],
"itemType": "string",
"pattern": "pattern",
"min": 1,
"max": 1,
"format": "format",
"examples": [
"example"
],
"enrich": {
"dataset": "dataset",
"keyPath": "keyPath",
"column": "column",
"mode": "exact"
}
}
],
"instructions": "Dates are day-first. The total is the amount due, not the subtotal.",
"documentType": "invoice",
"createdAt": "2026-10-01T12:00:00.000Z",
"createdById": "clx9k2m4p0001qh8z3v7d5f2a",
"queueId": "clx9k2m4p0001qh8z3v7d5f2a"
}

Schema templates#

Built-in starting points for new queues.

GET/api/v2/schemas/templates

Requires queues:read.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/schemas/templates" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"templates": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Invoices",
"fields": [
{
"key": "invoiceNumber",
"label": "Invoice number",
"type": "string",
"description": "Supplier invoices from the accounts payable mailbox.",
"required": false,
"options": [],
"children": [],
"itemType": "string",
"pattern": "pattern",
"min": 1,
"max": 1,
"format": "format",
"examples": [],
"enrich": {
"dataset": "dataset",
"keyPath": "keyPath",
"column": "column",
"mode": "exact"
}
}
]
}
]
}