Review

Approve, reject, edit fields, recapture regions and ask questions of a document.

Next document to review#

The next document waiting for review after this one.

GET/api/v2/documents/{id}/next

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

Path parameters

idstringrequired
Document id.

Query parameters

queueIdstring
Stay within this queue.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/next" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"nextId": "clx9k2m4p0001qh8z3v7d5f2a"
}

Approve#

force approves despite blocking validation errors.

POST/api/v2/documents/{id}/approve

Requires documents:approve on the queue it touches.queue-scoped

Path parameters

idstringrequired
Document id.

Body

application/json
notestring
forceboolean

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/documents/{id}/approve" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"note": "Checked against the purchase order"
}'
Response200
{
"ok": true
}

Reject#

Reject

POST/api/v2/documents/{id}/reject

Requires documents:reject on the queue it touches.queue-scoped

Path parameters

idstringrequired
Document id.

Body

application/json
reasonstringrequired

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/documents/{id}/reject" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"reason": "Duplicate of an earlier upload"
}'
Response200
{
"ok": true
}

Reopen#

Return an approved or rejected document to review. Needs documents:approve.

DELETE/api/v2/documents/{id}/reject

Requires documents:approve on the queue it touches.queue-scoped

Path parameters

idstringrequired
Document id.

Responses

OK

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

List comments#

Oldest first. Filter by fieldPath or by resolved. Comments an automation wrote have no author and carry systemLabel.

GET/api/v2/documents/{id}/comments

Requires documents:read on the queue it touches.queue-scopedcursor-paginated

Path parameters

idstringrequired
Document id.

Query parameters

fieldPathstring
Only comments on this field path.
resolved"true" | "false"
Only resolved (true) or open (false) comments.
cursorstring
limitinteger
Page size (default 50, max 200).

Responses

OK. Cursor-paginated: pass nextCursor back as cursor; null means the last page.

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/comments" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"items": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"body": "Please confirm the PO number with the supplier.",
"fieldPath": "invoiceTotal",
"author": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
},
"systemLabel": "systemLabel",
"resolved": false,
"resolvedAt": null,
"createdAt": "2026-10-01T12:00:00.000Z"
}
],
"nextCursor": "clx9k2m4p0001qh8z3v7d5f2a"
}

Comment#

Optionally on a field (fieldPath). @mentions notify members.

POST/api/v2/documents/{id}/comments

Requires documents:comment on the queue it touches.queue-scoped

Needs a signed-in person: API keys can't call this.

Path parameters

idstringrequired
Document id.

Body

application/json
bodystringrequired
fieldPathstring | null

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/documents/{id}/comments" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION" \
-H "Content-Type: application/json" \
-d '{
"body": "Please confirm the PO number with the supplier.",
"fieldPath": "invoiceTotal"
}'
Response201
{
"comment": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"body": "Please confirm the PO number with the supplier.",
"fieldPath": "invoiceTotal",
"author": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
},
"createdAt": "2026-10-01T12:00:00.000Z"
}
}

Edit or resolve a comment#

body changes the text (author only, else 403); resolved resolves or reopens it (anyone with documents:comment). Editing does not re-send @mention notifications.

PATCH/api/v2/documents/{id}/comments/{commentId}

Requires documents:comment on the queue it touches.queue-scoped

Needs a signed-in person: API keys can't call this.

Path parameters

idstringrequired
Document id.
commentIdstringrequired
Comment id.

Body

application/json
bodystring
New text. Only the comment's author may change it.
resolvedboolean
Resolve (true) or reopen (false) the comment.

Responses

OK

curl -X PATCH "https://docuflow.pendral.io/api/v2/documents/{id}/comments/{commentId}" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION" \
-H "Content-Type: application/json" \
-d '{
"body": "Please confirm the PO number with the supplier."
}'
Response200
{
"comment": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"body": "Please confirm the PO number with the supplier.",
"fieldPath": "invoiceTotal",
"author": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace",
"email": "ada@example.com",
"image": null
},
"systemLabel": "systemLabel",
"resolved": false,
"resolvedAt": null,
"createdAt": "2026-10-01T12:00:00.000Z"
}
}

Delete a comment#

Author only (403 otherwise). Permanent.

DELETE/api/v2/documents/{id}/comments/{commentId}

Requires documents:comment on the queue it touches.queue-scoped

Needs a signed-in person: API keys can't call this.

Path parameters

idstringrequired
Document id.
commentIdstringrequired
Comment id.

Responses

OK

curl -X DELETE "https://docuflow.pendral.io/api/v2/documents/{id}/comments/{commentId}" \
-H "Cookie: __Secure-better-auth.session_token=$DOCUFLOW_SESSION"
Response200
{
"ok": true
}

Extraction history#

Every extraction run of the document, newest first: model, status, timings, tokens and cost. current marks the run the document's values come from.

GET/api/v2/documents/{id}/extractions

Requires documents:read on the queue it touches.queue-scopedcursor-paginated

Path parameters

idstringrequired
Document id.

Query parameters

status"queued" | "running" | "succeeded" | "failed"
cursorstring
limitinteger
Page size (default 50, max 200).

Responses

OK. Cursor-paginated: pass nextCursor back as cursor; null means the last page.

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/extractions" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"items": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"status": "queued",
"model": "model",
"verifyModel": "verifyModel",
"schemaId": "clx9k2m4p0001qh8z3v7d5f2a",
"schemaVersion": 1,
"startedAt": "2026-10-01T12:00:00.000Z",
"finishedAt": "2026-10-01T12:00:00.000Z",
"durationMs": 184,
"inputTokens": 1,
"outputTokens": 1,
"costUsd": 1,
"pagesProcessed": 1,
"error": null,
"triggeredBy": "triggeredBy",
"fieldCount": 1,
"current": false,
"createdAt": "2026-10-01T12:00:00.000Z"
}
],
"nextCursor": "clx9k2m4p0001qh8z3v7d5f2a"
}

One extraction run#

The run, the schema it extracted against, and its fields (with bounding boxes, validation and any later edits) and values as a nested object. Compare two runs to see what a reprocess changed.

GET/api/v2/documents/{id}/extractions/{runId}

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

Path parameters

idstringrequired
Document id.
runIdstringrequired
Extraction run id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/extractions/{runId}" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"run": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"status": "queued",
"model": "model",
"verifyModel": "verifyModel",
"schemaId": "clx9k2m4p0001qh8z3v7d5f2a",
"schemaVersion": 1,
"startedAt": "2026-10-01T12:00:00.000Z",
"finishedAt": "2026-10-01T12:00:00.000Z",
"durationMs": 184,
"inputTokens": 1,
"outputTokens": 1,
"costUsd": 1,
"pagesProcessed": 1,
"error": null,
"triggeredBy": "triggeredBy",
"fieldCount": 1,
"current": false,
"createdAt": "2026-10-01T12:00:00.000Z",
"schema": [
{
"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"
}
}
]
},
"values": {},
"fields": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"runId": "clx9k2m4p0001qh8z3v7d5f2a",
"path": "invoiceTotal",
"key": "invoiceNumber",
"label": "Invoice number",
"type": "type",
"value": "1240.00",
"originalValue": "originalValue",
"normalizedValue": "normalizedValue",
"page": 1,
"bbox": {
"x": 1,
"y": 1,
"w": 1,
"h": 1
},
"confidence": 0.94,
"ocrConfidence": 1,
"matchScore": 1,
"status": "status",
"validation": [
{
"level": "level",
"message": "message"
}
]
}
]
}

Validation issues#

The issues on the current run's fields. Any error makes approve answer 422 unless force is sent.

GET/api/v2/documents/{id}/validation

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

Path parameters

idstringrequired
Document id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/validation" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"runId": "clx9k2m4p0001qh8z3v7d5f2a",
"valid": false,
"errorCount": 1,
"warningCount": 1,
"issues": [
{
"fieldId": "clx9k2m4p0001qh8z3v7d5f2a",
"path": "invoiceTotal",
"label": "Invoice number",
"value": "1240.00",
"rule": "rule",
"ruleId": "clx9k2m4p0001qh8z3v7d5f2a",
"level": "error",
"message": "message",
"suggestion": {
"value": "1240.00"
}
}
]
}

Current field values#

The latest successful run's fields, and the values as a plain nested object (what exports and webhooks send).

GET/api/v2/documents/{id}/fields

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

Path parameters

idstringrequired
Document id.

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/fields" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"documentId": "clx9k2m4p0001qh8z3v7d5f2a",
"status": "received",
"runId": "clx9k2m4p0001qh8z3v7d5f2a",
"values": {},
"fields": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"runId": "clx9k2m4p0001qh8z3v7d5f2a",
"path": "invoiceTotal",
"key": "invoiceNumber",
"label": "Invoice number",
"type": "type",
"value": "1240.00",
"originalValue": "originalValue",
"normalizedValue": "normalizedValue",
"page": 1,
"bbox": {
"x": 1,
"y": 1,
"w": 1,
"h": 1
},
"confidence": 0.94,
"ocrConfidence": 1,
"matchScore": 1,
"status": "status",
"validation": [
{
"level": "level",
"message": "message"
}
]
}
]
}

Edit fields and table rows#

updates change values, status, page or box; rowOps insert, delete, move or duplicate table rows (applied in order after updates).

PATCH/api/v2/documents/{id}/fields

Requires documents:update on the queue it touches.queue-scoped

Path parameters

idstringrequired
Document id.

Body

application/json
updatesobject[]
Default[]
source"edit" | "revert" | "recapture" | "ask" | "paste"
rowOpsobject[]

Responses

OK

curl -X PATCH "https://docuflow.pendral.io/api/v2/documents/{id}/fields" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Response200
{
"changed": 1,
"rows": [
"row"
]
}

Field history#

Every value one field has had, newest first: model readings per run and each human change.

GET/api/v2/documents/{id}/fields/history

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

Path parameters

idstringrequired
Document id.

Query parameters

pathstringrequired

Responses

OK

curl -X GET "https://docuflow.pendral.io/api/v2/documents/{id}/fields/history?path=path" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY"
Response200
{
"path": "invoiceTotal",
"entries": [
{
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"kind": "kind",
"value": "1240.00",
"previousValue": "previousValue",
"at": "2026-10-01T12:00:00.000Z",
"actor": {
"id": "clx9k2m4p0001qh8z3v7d5f2a",
"name": "Ada Lovelace"
},
"model": "model",
"confidence": 0.94,
"runId": "clx9k2m4p0001qh8z3v7d5f2a"
}
]
}

Recapture a field from a region#

Re-reads one field from a drawn region. Returns a proposal; apply it with PATCH fields.

POST/api/v2/documents/{id}/recapture

Requires documents:update on the queue it touches.queue-scoped

Path parameters

idstringrequired
Document id.

Body

application/json
fieldIdstringrequired
pageintegerrequired
regionobjectrequired

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/documents/{id}/recapture" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fieldId": "clx9k2m4p0001qh8z3v7d5f2a",
"page": 1,
"region": {
"x": 0,
"y": 0,
"w": 0,
"h": 0
}
}'
Response200
{
"value": "1240.00",
"confidence": 0.94,
"bbox": {
"x": 1,
"y": 1,
"w": 1,
"h": 1
}
}

Capture table rows from a region#

Reads every row of a table from a drawn region. Returns proposals; insert them with PATCH fields rowOps.

POST/api/v2/documents/{id}/recapture/rows

Requires documents:update on the queue it touches.queue-scoped

Path parameters

idstringrequired
Document id.

Body

application/json
tablestringrequired
pageintegerrequired
regionobjectrequired

Responses

OK

curl -X POST "https://docuflow.pendral.io/api/v2/documents/{id}/recapture/rows" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"table": "table",
"page": 1,
"region": {
"x": 0,
"y": 0,
"w": 0,
"h": 0
}
}'
Response200
{
"table": "table",
"columns": [
null
],
"rows": [
{}
]
}

Ask the document#

Streams NDJSON: meta, then delta chunks, then done with the answer, an optional extracted value and citations grounded to page word boxes (or error).

POST/api/v2/documents/{id}/ask

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

Path parameters

idstringrequired
Document id.

Body

application/json
questionstringrequired
fieldobject | null
historyobject[]

Responses

One JSON event per line.

curl -X POST "https://docuflow.pendral.io/api/v2/documents/{id}/ask" \
-H "Authorization: Bearer $DOCUFLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "What is the invoice total?"
}'
Responseapplication/x-ndjson200
{"t":"meta"}