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.
States
Section titled “States”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.
The snapshot
Section titled “The snapshot”{ "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"}plandivides the document into chunks of at mostchunk_pagespages, in page order, covering every page once.completed_chunkscounts chunks that have succeeded. A 401-page document with the default 400-page chunks has two chunks: pages 1–400 and 401–401.attemptson a chunk counts processing attempts, including the current one. A chunk may be retried after a transient error.last_sequenceis the sequence number of the latest event this snapshot includes. Use it as the cursor for event history and live events.failureis set only whenstateisfailed.webhookisnulluntil processing ends and a delivery is created. It then lists finished attempts.
Failures
Section titled “Failures”A failed document reports the stage, a machine-readable code, a message you can show to users, and the affected page range when known:
{ "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.
Polling well
Section titled “Polling well”- Poll every few seconds. A
429 quota_exceededor503response carriesRetry-After: wait at least that long. - Stop when
stateissucceededorfailed. - For many documents, prefer webhooks and read the snapshot once when notified.
Results
Section titled “Results”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.
Listing documents
Section titled “Listing documents”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.