Skip to main content
Extract fills a JSON Schema that you write with values read from a completed parse. Use it when you know which fields you want, such as an invoice’s number and total. Each value comes back with a confidence score and a citation of the parse elements it was read from:

Extract fields from a document

This example reads the account holder, closing balance and transactions from a sample bank statement.
1

Write the schema

List the fields you want, each with a type, and save the schema as statement_schema.json:
2

Parse the document, then extract

This code parses the statement, then fills the schema from that parse, waiting for each job to finish.
prompt holds conventions the schema can’t express, such as units or how to classify an entry. For a long parse, send async: true and poll the job instead: see Jobs and results.
The calls in order: An expired or deleted parse is refused with a 410 (RESULT_EXPIRED), so run Extract before an unsaved parse’s expires_at.

Read the result

GET /extract/{extract_id}/result (client.extract.get_result) returns the values, shown here with one transaction:
extraction.enriched has your schema’s shape. Each single value becomes an object with three fields: To have a person check a low-confidence value, highlight its source on its page. format defaults to ["enriched"]. Send ["raw"] for the values alone, in extraction.raw, shaped exactly like your schema, or "all" for both.

Write the schema

input_schema is a JSON Schema (Draft 7) whose root is an object with at least one property. It can also use $ref to $defs or definitions in the same schema, anyOf, oneOf and allOf, nullable types such as ["string", "null"], and if, then and else. An object returns only the properties it declares, unless its additionalProperties allows more. A schema that breaks these rules is refused with a 400 before any work starts, and costs nothing. For more reliable values:
  • Give a description to each field that could be confused with another, such as remit_to: “Address payments are sent to, often in the footer”.
  • If a value is missing, read the parse’s markdown. Extract finds only what the parse found.
A schema can declare at most 5,000 properties, counting nested objects, definitions and branches. format, such as "format": "date", is a hint and isn’t enforced.Enum values, const values, defaults and property names are copied into the output exactly, so they can’t contain quotation marks or apostrophes, straight or curly, or start or end with whitespace: owner's_name is refused. No string in the schema, descriptions and titles included, can contain a control character other than a tab or a newline (\n).

Choose pages, effort and confidence

These options sit in config beside input_schema: Extract costs 1 credit per page it reads, 6 credits per page with effort: "high", and 3 more credits per page with confidence: "agentic" (Pricing).

Next steps

Split, then extract

Find each section’s pages with Split, then run a small schema on each.

Saved configs

Save a schema, then send its config_id.

Extract API reference

Every option, field and limit.