Skip to content

Poll status and results

Processing is asynchronous. The status snapshot at links.status (GET /documents/{document_id}) is the authoritative view of a document. Poll it until state is terminal, or let events or webhooks tell you when to read it.

state processing_stage Meaning
accepted chunking Stored durably; the page plan is being prepared. plan is null.
processing ocr Pages are being recognized, chunk by chunk.
combining combine or export Page results are being assembled and outputs written.
succeeded null All requested outputs are published. Read the result manifest.
failed null Processing stopped. failure explains why.

succeeded and failed are terminal: once there, a document does not change state again. The webhook field can still change after that, as delivery attempts are recorded.

Snapshot of a two-page PDF while its single chunk is processed (contract fixture)
{
"document_id": "a~d17",
"trace_id": "86bc31a843374ae6b6a3def26d08a011",
"state": "processing",
"processing_stage": "ocr",
"chunk_pages": 400,
"profile": "default",
"output_plan": {
"formats": [
"txt"
],
"transformations": []
},
"last_sequence": 4,
"plan": {
"page_count": 2,
"total_chunks": 1,
"completed_chunks": 0,
"chunks": [
{
"range": {
"first_page": 1,
"last_page": 2
},
"state": "running",
"attempts": 1,
"state_since": "2026-11-30T20:00:04Z"
}
]
},
"failure": null,
"webhook": null,
"links": {
"status": "https://docs.example/documents/a~d17",
"history": "https://docs.example/documents/a~d17/events",
"result": "https://docs.example/documents/a~d17/result",
"event_tickets": "https://docs.example/documents/a~d17/event-tickets",
"events": "wss://docs.example/documents/a~d17/events"
},
"expires_at": "2026-12-07T20:00:00Z"
}
  • plan divides the document into chunks of at most chunk_pages pages, in page order, covering every page once. completed_chunks counts chunks that have succeeded. A 401-page document with the default 400-page chunks has two chunks: pages 1–400 and 401–401.
  • attempts on a chunk counts processing attempts, including the current one. A chunk may be retried after a transient error.
  • last_sequence is the sequence number of the latest event this snapshot includes. Use it as the cursor for event history and live events.
  • failure is set only when state is failed.
  • webhook is null until processing ends and a delivery is created. It then lists finished attempts.

A failed document reports the stage, a machine-readable code, a message you can show to users, and the affected page range when known:

api/specs/examples/failure.json (contract fixture)
{
"stage": "ocr",
"code": "ocr_attempts_exhausted",
"message": "OCR failed after the final attempt.",
"range": {
"first_page": 1,
"last_page": 2
}
}

Branch on code, not on message. When a chunk fails, it is marked failed and other unfinished chunks become stopped.

  • Poll every few seconds. A 429 quota_exceeded or 503 response carries Retry-After: wait at least that long.
  • Stop when state is succeeded or failed.
  • For many documents, prefer webhooks and read the snapshot once when notified.

When state is succeeded, read the result manifest at links.result and download the listed files. See output formats. Reading the manifest earlier returns 409 result_pending; after a failure it returns 409 document_failed.

GET /documents lists your tenant’s documents, newest first, 20 per page by default and at most 100 (limit). Pass next_cursor from a response as cursor to get the next page; it is null on the last page. Cursors are opaque and only valid for your tenant. Deleted and expired documents are not listed.