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.
/api/v2/documents/{id}/nextRequires 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"
{"nextId": "clx9k2m4p0001qh8z3v7d5f2a"}
Approve#
force approves despite blocking validation errors.
/api/v2/documents/{id}/approveRequires documents:approve on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Body
application/jsonnotestringforceboolean
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"}'
{"ok": true}
Reject#
Reject
/api/v2/documents/{id}/rejectRequires documents:reject on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Body
application/jsonreasonstringrequired
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"}'
{"ok": true}
Reopen#
Return an approved or rejected document to review. Needs documents:approve.
/api/v2/documents/{id}/rejectRequires 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"
{"ok": true}
List comments#
Oldest first. Filter by fieldPath or by resolved. Comments an automation wrote have no author and carry systemLabel.
/api/v2/documents/{id}/commentsRequires 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. cursorstringlimitinteger- 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"
{"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.
/api/v2/documents/{id}/commentsRequires 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/jsonbodystringrequiredfieldPathstring | 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"}'
{"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.
/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/jsonbodystring- 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."}'
{"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.
/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"
{"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.
/api/v2/documents/{id}/extractionsRequires documents:read on the queue it touches.queue-scopedcursor-paginated
Path parameters
idstringrequired- Document id.
Query parameters
status"queued" | "running" | "succeeded" | "failed"cursorstringlimitinteger- 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"
{"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.
/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"
{"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.
/api/v2/documents/{id}/validationRequires 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"
{"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).
/api/v2/documents/{id}/fieldsRequires 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"
{"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).
/api/v2/documents/{id}/fieldsRequires documents:update on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Body
application/jsonupdatesobject[]- 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 '{}'
{"changed": 1,"rows": ["row"]}
Field history#
Every value one field has had, newest first: model readings per run and each human change.
/api/v2/documents/{id}/fields/historyRequires 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"
{"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.
/api/v2/documents/{id}/recaptureRequires documents:update on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Body
application/jsonfieldIdstringrequiredpageintegerrequiredregionobjectrequired
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}}'
{"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.
/api/v2/documents/{id}/recapture/rowsRequires documents:update on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Body
application/jsontablestringrequiredpageintegerrequiredregionobjectrequired
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}}'
{"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).
/api/v2/documents/{id}/askRequires documents:read on the queue it touches.queue-scoped
Path parameters
idstringrequired- Document id.
Body
application/jsonquestionstringrequiredfieldobject | nullhistoryobject[]
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?"}'
{"t":"meta"}