Skip to main content
POST
Extract structured data from a document against a JSON schema and persist the result as an Extraction resource that can later be retrieved via GET /v1/extractions/{extraction_id} or listed via GET /v1/extractions.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request to run a structured extraction on a single document.

Extends the base extraction request with the document to process (either inline content or a reference to a previously uploaded file) and a stream flag that controls whether results are returned incrementally.

document
MIMEData · object
required

A file represented by its filename and a base64 data url.

json_schema
Json Schema · object
required

JSON schema describing the structured output

model
string
default:retab-small

The model to use for the extraction

instructions
string | null

Free-form instructions appended to the system prompt to steer the extraction.

n_consensus
integer
default:1

Number of consensus extraction runs to perform. Uses deterministic single-pass when set to 1.

metadata
Metadata · object | null

User-defined metadata to associate with this extraction

additional_messages
Additional Messages · object[] | null

Additional chat messages forwarded to the extraction model.

bust_cache
boolean
default:false

If true, skip the LLM cache and force a fresh completion

stream
boolean
default:false
background
boolean
default:false

If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1//{id} until status is terminal. Mutually exclusive with stream.

deep_extraction
boolean
default:false

Optimizes for accuracy over latency in documents with very large arrays.

sources
SourcesOptions · object

Automatic source computation. Omission defaults to located; cited must be requested explicitly.

agentic_extraction
boolean
default:false

Agentic extraction for long documents with large repeated arrays: an agent reads the document, writes and runs extraction code in a sandbox, and submits an output checked against the schema. Accepts every document type extraction accepts; images and scanned pages are read with OCR. Requires model retab-large, n_consensus 1, and no instructions or additional_messages; not supported with stream=true or on POST /v1/extractions/stream. Runs the standard deep extraction instead where agentic extraction is not available (including when your organization already has too many agentic extractions running at once), when the schema has no top-level array of objects, when it does not apply to the document (for example a short document), or when it cannot finish. Once the agent takes the request, HTML, MHTML, audio and emails without paged attachments are counted and billed like text files, one page per 3,000 characters, even if the request then falls back. A request the agent does not take (for example where agentic extraction is not available, or when the schema has no top-level array of objects), and a background run that times out and is run again, are counted and billed like any standard deep extraction, which counts each of those documents as one page.

Response

Streaming extraction chunks