Automations
Workflow rules: when a document reaches a trigger, if its conditions hold, do a list of actions. Ordered per workspace; a rule with no queue reaches every queue.
Automation runs on a document#
Every rule evaluated against this document, newest first: whether its conditions held (with the per-condition trace) and what each action did. Also needs queues:read on the document's queue.
/api/v2/documents/{id}/automation-runsRequires documents:read, queues:read on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Query parameters
matched"true" | "false"true: only runs whose conditions held.limitinteger- Newest first; default 50, max 200.
Responses
OK
curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/automation-runs" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"runs": [{"id": "clx9k2m4p0001qh8z3v7d5f2a","automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","trigger": "trigger"},"documentId": "clx9k2m4p0001qh8z3v7d5f2a","documentName": "documentName","trigger": "trigger","matched": false,"outcomes": [{"type": "type","ok": true,"detail": "detail","skipped": false}],"trace": {},"error": null,"ms": 1,"createdAt": "2026-10-01T12:00:00.000Z"}]}
List automations#
List automations
/api/v2/automationsRequires queues:read on the queue it touches.queue-scoped
Query parameters
queueIdstringtriggerstringenabled"true" | "false"
Responses
OK
curl -X GET "https://docuflow.pendral.io/api/v2/automations" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"automations": [{"id": "clx9k2m4p0001qh8z3v7d5f2a","queueId": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","trigger": "trigger","afterMinutes": 1,"conditions": {},"actions": [{}],"summary": ["summary"],"stopOnMatch": false,"enabled": true,"order": 1,"lastRunAt": "2026-10-01T12:00:00.000Z","matchCount": 1,"runCount": 1,"errorCount": 1,"lastError": null,"createdAt": "2026-10-01T12:00:00.000Z","updatedAt": "2026-10-01T12:00:00.000Z"}]}
Create an automation#
A rule scoped to a queue needs queues:configure on that queue; a workspace-wide rule needs it across the workspace.
/api/v2/automationsRequires queues:configure on the queue it touches.queue-scoped
Body
application/jsonnamestringrequireddescriptionstring | nullqueueIdstring | nulltrigger"document.received" | "document.classified" | "document.extracted" | "document.needs_review" | "document.approved" | "document.rejected" | "document.exported" | "document.stalled"requiredafterMinutesinteger | nullconditionsschema0- Default
{"match":"all","conditions":[]} actionsobject[]requiredstopOnMatchboolean- Default
false enabledboolean- Default
true orderinteger
Responses
OK
curl -X POST "https://docuflow.pendral.io/api/v2/automations" \-H "Authorization: Bearer $DOCUFLOW_API_KEY" \-H "Content-Type: application/json" \-d '{"name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","trigger": "document.received","actions": [{"type": "approve","note": "Checked against the purchase order"}],"enabled": true}'
{"automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","queueId": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","trigger": "trigger","afterMinutes": 1,"conditions": {},"actions": [{}],"summary": ["summary"],"stopOnMatch": false,"enabled": true,"order": 1,"lastRunAt": "2026-10-01T12:00:00.000Z","matchCount": 1,"runCount": 1,"errorCount": 1,"lastError": null,"createdAt": "2026-10-01T12:00:00.000Z","updatedAt": "2026-10-01T12:00:00.000Z"}}
Get an automation#
Get an automation
/api/v2/automations/{id}Requires queues:read on the queue it touches.queue-scoped
Path parameters
idstringrequired- Automation id.
Responses
OK
curl -X GET "https://docuflow.pendral.io/api/v2/automations/{id}" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","queueId": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","trigger": "trigger","afterMinutes": 1,"conditions": {},"actions": [{}],"summary": ["summary"],"stopOnMatch": false,"enabled": true,"order": 1,"lastRunAt": "2026-10-01T12:00:00.000Z","matchCount": 1,"runCount": 1,"errorCount": 1,"lastError": null,"createdAt": "2026-10-01T12:00:00.000Z","updatedAt": "2026-10-01T12:00:00.000Z"}}
Update an automation#
Update an automation
/api/v2/automations/{id}Requires queues:configure on the queue it touches.queue-scoped
Path parameters
idstringrequired- Automation id.
Body
application/jsonnamestringdescriptionstring | nullqueueIdstring | nulltrigger"document.received" | "document.classified" | "document.extracted" | "document.needs_review" | "document.approved" | "document.rejected" | "document.exported" | "document.stalled"afterMinutesinteger | nullconditionsschema0- Default
{"match":"all","conditions":[]} actionsobject[]stopOnMatchboolean- Default
false enabledboolean- Default
true orderinteger
Responses
OK
curl -X PATCH "https://docuflow.pendral.io/api/v2/automations/{id}" \-H "Authorization: Bearer $DOCUFLOW_API_KEY" \-H "Content-Type: application/json" \-d '{"name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","enabled": true}'
{"automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","queueId": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","trigger": "trigger","afterMinutes": 1,"conditions": {},"actions": [{}],"summary": ["summary"],"stopOnMatch": false,"enabled": true,"order": 1,"lastRunAt": "2026-10-01T12:00:00.000Z","matchCount": 1,"runCount": 1,"errorCount": 1,"lastError": null,"createdAt": "2026-10-01T12:00:00.000Z","updatedAt": "2026-10-01T12:00:00.000Z"}}
Delete an automation#
The rule and its run history go; documents it already acted on are unchanged.
/api/v2/automations/{id}Requires queues:configure on the queue it touches.queue-scoped
Path parameters
idstringrequired- Automation id.
Responses
OK
curl -X DELETE "https://docuflow.pendral.io/api/v2/automations/{id}" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"ok": true}
Run log#
Every evaluation of this rule, newest first, with the condition trace and what each action did.
/api/v2/automations/{id}/runsRequires queues:read on the queue it touches.queue-scoped
Path parameters
idstringrequired- Automation id.
Query parameters
matched"true" | "false"limitstring
Responses
OK
curl -X GET "https://docuflow.pendral.io/api/v2/automations/{id}/runs" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"runs": [{"id": "clx9k2m4p0001qh8z3v7d5f2a","automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","trigger": "trigger"},"documentId": "clx9k2m4p0001qh8z3v7d5f2a","documentName": "documentName","trigger": "trigger","matched": false,"outcomes": [{"type": "type","ok": true,"detail": "detail","skipped": false}],"trace": {},"error": null,"ms": 1,"createdAt": "2026-10-01T12:00:00.000Z"}]}
Get one run#
One evaluation of this rule: the condition trace and what each action did.
/api/v2/automations/{id}/runs/{runId}Requires queues:read on the queue it touches.queue-scoped
Path parameters
idstringrequired- Automation id.
runIdstringrequired- Run id.
Responses
OK
curl -X GET "https://docuflow.pendral.io/api/v2/automations/{id}/runs/{runId}" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"run": {"id": "clx9k2m4p0001qh8z3v7d5f2a","automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","trigger": "trigger"},"documentId": "clx9k2m4p0001qh8z3v7d5f2a","documentName": "documentName","trigger": "trigger","matched": false,"outcomes": [{"type": "type","ok": true,"detail": "detail","skipped": false}],"trace": {},"error": null,"ms": 1,"createdAt": "2026-10-01T12:00:00.000Z"}}
Workspace run log#
Every rule evaluation across the workspace, newest first — the place to find what a rule did to a document, or every rule that errored this week. Rules scoped to queues the caller can't read are left out; workspace-wide rules are always included unless queueId is set.
/api/v2/automation-runsRequires queues:read on the queue it touches.queue-scopedcursor-paginated
Query parameters
automationIdstring- Only this rule's runs.
queueIdstring- Only rules scoped to this queue (workspace-wide rules are excluded).
documentIdstring- Only runs about this document.
triggerstring- Only runs fired by this trigger, e.g.
document.extracted. matched"true" | "false"- Only runs whose conditions held (or did not).
failed"true" | "false"true= only runs that recorded an error.fromstringtostringcursorstringlimitinteger- Default
50
Responses
OK. Cursor-paginated: pass nextCursor back as cursor; null means the last page.
curl -X GET "https://docuflow.pendral.io/api/v2/automation-runs" \-H "Authorization: Bearer $DOCUFLOW_API_KEY"
{"items": [{"id": "clx9k2m4p0001qh8z3v7d5f2a","automation": {"id": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","trigger": "trigger"},"documentId": "clx9k2m4p0001qh8z3v7d5f2a","documentName": "documentName","trigger": "trigger","matched": false,"outcomes": [{"type": "type","ok": true,"detail": "detail","skipped": false}],"trace": {},"error": null,"ms": 1,"createdAt": "2026-10-01T12:00:00.000Z"}],"nextCursor": "clx9k2m4p0001qh8z3v7d5f2a"}
Dry-run a rule#
Evaluates conditions against recent documents and reports what would have matched. Takes no action.
/api/v2/automations/simulateRequires queues:read on the queue it touches.queue-scoped
Body
application/jsonqueueIdstring | nulltrigger"document.received" | "document.classified" | "document.extracted" | "document.needs_review" | "document.approved" | "document.rejected" | "document.exported" | "document.stalled"requiredconditionsschema0requiredactionsany[]documentIdstringlimitinteger
Responses
OK
curl -X POST "https://docuflow.pendral.io/api/v2/automations/simulate" \-H "Authorization: Bearer $DOCUFLOW_API_KEY" \-H "Content-Type: application/json" \-d '{"trigger": "document.received","limit": 50}'
{"sampled": 1,"matched": 1,"wouldRun": ["wouldRun"],"results": [{"documentId": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","status": "received","createdAt": "2026-10-01T12:00:00.000Z","matched": false,"trace": {}}]}
Reorder automations#
The given ids take positions 0..n. Rules on the same trigger run in this order.
/api/v2/automations/reorderRequires queues:configure on the queue it touches.queue-scoped
Body
application/jsonidsstring[]required
Responses
OK
curl -X POST "https://docuflow.pendral.io/api/v2/automations/reorder" \-H "Authorization: Bearer $DOCUFLOW_API_KEY" \-H "Content-Type: application/json" \-d '{"ids": ["clx9k2m4p0001qh8z3v7d5f2a"]}'
{"automations": [{"id": "clx9k2m4p0001qh8z3v7d5f2a","queueId": "clx9k2m4p0001qh8z3v7d5f2a","name": "Invoices","description": "Supplier invoices from the accounts payable mailbox.","trigger": "trigger","afterMinutes": 1,"conditions": {},"actions": [{}],"summary": ["summary"],"stopOnMatch": false,"enabled": true,"order": 1,"lastRunAt": "2026-10-01T12:00:00.000Z","matchCount": 1,"runCount": 1,"errorCount": 1,"lastError": null,"createdAt": "2026-10-01T12:00:00.000Z","updatedAt": "2026-10-01T12:00:00.000Z"}]}