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.

GET/api/v2/documents/{id}/automation-runs

Requires 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"
Response200
{
"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

GET/api/v2/automations

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

Query parameters

queueIdstring
triggerstring
enabled"true" | "false"

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/automations" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"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.

POST/api/v2/automations

Requires queues:configure on the queue it touches.queue-scoped

Body

application/json
namestringrequired
descriptionstring | null
queueIdstring | null
trigger"document.received" | "document.classified" | "document.extracted" | "document.needs_review" | "document.approved" | "document.rejected" | "document.exported" | "document.stalled"required
afterMinutesinteger | null
conditionsschema0
Default{"match":"all","conditions":[]}
actionsobject[]required
stopOnMatchboolean
Defaultfalse
enabledboolean
Defaulttrue
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
}'
Response201
{
"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

GET/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"
Response200
{
"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

PATCH/api/v2/automations/{id}

Requires queues:configure on the queue it touches.queue-scoped

Path parameters

idstringrequired
Automation id.

Body

application/json
namestring
descriptionstring | null
queueIdstring | null
trigger"document.received" | "document.classified" | "document.extracted" | "document.needs_review" | "document.approved" | "document.rejected" | "document.exported" | "document.stalled"
afterMinutesinteger | null
conditionsschema0
Default{"match":"all","conditions":[]}
actionsobject[]
stopOnMatchboolean
Defaultfalse
enabledboolean
Defaulttrue
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
}'
Response200
{
"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.

DELETE/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"
Response200
{
"ok": true
}

Run log#

Every evaluation of this rule, newest first, with the condition trace and what each action did.

GET/api/v2/automations/{id}/runs

Requires 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"
Response200
{
"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.

GET/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"
Response200
{
"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.

GET/api/v2/automation-runs

Requires 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.
fromstring
tostring
cursorstring
limitinteger
Default50

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"
Response200
{
"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.

POST/api/v2/automations/simulate

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

Body

application/json
queueIdstring | null
trigger"document.received" | "document.classified" | "document.extracted" | "document.needs_review" | "document.approved" | "document.rejected" | "document.exported" | "document.stalled"required
conditionsschema0required
actionsany[]
documentIdstring
limitinteger

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
}'
Response200
{
"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.

POST/api/v2/automations/reorder

Requires queues:configure on the queue it touches.queue-scoped

Body

application/json
idsstring[]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"
]
}'
Response200
{
"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"
}
]
}