Schemas & rules
Versioned extraction schemas and validation rules.
Active schema and versions#
Active schema and versions
/api/v2/queues/{id}/schemaRequires 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"
{"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.
/api/v2/queues/{id}/schemaRequires schemas:edit on the queue it touches.queue-scoped
Path parameters
idstringrequired- Queue id.
Body
application/jsonfieldsFieldDef[]requiredinstructionsstring | nulldocumentTypestring | nullnamestringdescriptionstring | 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."}'
{"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.
/api/v2/queues/{id}/schema/generateRequires schemas:edit on the queue it touches.queue-scoped
Path parameters
idstringrequired- Queue id.
Body
application/jsondocumentIdstringdescriptionstringhintstring
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."}'
{"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}.
/api/v2/queues/{id}/schema/restoreRequires schemas:edit on the queue it touches.queue-scoped
Path parameters
idstringrequired- Queue id.
Body
application/jsonschemaIdstringrequired- 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"}'
{"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
/api/v2/queues/{id}/rulesRequires 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"
{"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
/api/v2/queues/{id}/rulesRequires rules:edit on the queue it touches.queue-scoped
Path parameters
idstringrequired- Queue id.
Body
application/jsonnamestringrequiredfieldPathstring | nullkind"required" | "regex" | "range" | "length" | "enum" | "date_range" | "cross_field" | "expression" | "confidence" | "dataset_match" | "lookup"requiredconfigRecord<string, any>- Default
{} level"error" | "warning"- Default
"error" enabledboolean- Default
true 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}'
{"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.
/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"
{"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
/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/jsonnamestringfieldPathstring | nullkind"required" | "regex" | "range" | "length" | "enum" | "date_range" | "cross_field" | "expression" | "confidence" | "dataset_match" | "lookup"configRecord<string, any>level"error" | "warning"enabledbooleanorderinteger
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}'
{"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
/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"
{"ok": true}
Test rules against values#
Evaluates the queue's rules (and schema constraints unless includeSchema: false) against sample values.
/api/v2/queues/{id}/rules/testRequires rules:read on the queue it touches.queue-scoped
Path parameters
idstringrequired- Queue id.
Body
application/jsonvaluesRecord<string, any>requiredincludeSchemaboolean- Default
true
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": {}}'
{"issues": {"key": [{"level": "level","message": "message"}]},"count": 1}
Get a schema version#
Get a schema version
/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"
{"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.
/api/v2/schemas/templatesRequires queues:read.
Responses
OK
curl -X GET "https://docuflow.pendral.io/api/v2/schemas/templates" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"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"}}]}]}