not_found on a field is an
answer about the document, not an HTTP error. Exactly one of json_schema /
schema or schema_id is required.
- Python
- TypeScript
- curl
ParseResultSource so the parse is not paid for twice.
On a parse-result source, page_ranges keeps only those pages of the reused
parse.
For checkbox forms, choose parse_mode="medium" or parse_mode="high" on the
original Parse request and check that its output preserves the selection marks.
The default low-effort parse may omit them. Extract reuses a ParseResultSource
as it is; it does not reparse the form to recover missing marks. To change parsing
effort, create a new parse from the original upload or URL and extract from that
new result.
Validate a schema first with client.documents.validate_extract_schema or
POST /v1/extract/schema-validation. Register reusable schemas with
extraction schemas and pass schema_id.
Supported schema keywords
Extract supports a limited subset of JSON Schema. The root must have"type": "object" and a non-empty properties object.
- Supported keywords:
type,properties,items,required,description,enum,title,additionalProperties,maxItems, anduniqueItems. additionalPropertiesis supported only asfalse.maxItemsanduniqueItemsapply only to arrays directly inside the root object’sproperties.- Common JSON Schema forms are accepted and rewritten into this subset, so a
schema generated from a Pydantic model works as is:
$refinto$defs(ordefinitions) is inlined. A recursive$refis rejected.anyOf/oneOfof one type and{"type": "null"}becomes a nullable type.constbecomes a one-valueenum. The field still needs an explicittype.format,pattern,minimum,maximum,minLength,maxLength,minItems,defaultandexamplesare kept as guidance in the field’sdescription. Extract does not enforce them on extracted values. The same applies tomaxItemsanduniqueItemson nested arrays.$schema,$id,$comment,deprecated,readOnlyandwriteOnlyare dropped.
- Other keywords, such as
allOfor other unions, are rejected with422 invalid_schema.
normalized_schema.
warnings lists only the keywords kept as guidance in a field’s description,
one entry per node with its path. Inlined $refs, nullable anyOf/oneOf,
const rewritten to enum and dropped metadata appear only in
normalized_schema, so compare it with your schema to see them.
A rejected schema lists every problem at once. The validation endpoint returns
them in errors, and a rejected extract returns them in the 422’s
error.detail.errors. Each entry has a path, the
JSON Pointer of the offending node
(for example /properties/lines/items/properties/amount), and a message.
For dates, "format": "date" works, or describe the representation yourself:
Match links to a small set of known records
When a document names related records, put their known names in anenum on
each link’s key field. Enums also work on leaves inside nested arrays. For
example, this schema requests film–actor links using names from your own catalog:
json_schema to Extract with your document source. Build each enum
from the records you already know; the example lists are placeholders for your
catalog. Include null to represent a missing match and declare the key nullable
("type": ["string", "null"]), as in the example. Null in an enum on a plain
"string" is rejected. Each enum accepts at most
100 values, including null, so a nullable key can list up to 99 names. The
complete schema must fit within 50,000 characters when serialized with a
space after each : and ,. The same limit applies after normalization:
inlined references, const converted to enum, and guidance moved into
descriptions can make the schema longer. It can define at most 128 properties
and nest at most 5 properties or items levels below the root.
The key fields above are already at that depth, so do not wrap this example in
another object. Check a schema near these limits with schema validation first.
Map each returned name to its stored ID in your application. Request the names
needed for that lookup; omit database ID fields when the document does not print
IDs: a requested ID the document does not print may come back as an invented value
rather than null. An enum supplies candidate values, not their IDs or a uniqueness
guarantee.
Extract constrains or validates enum fields against your listed values, so a name
the document prints that is not in your enum is not returned as written: it comes
back as null or an absent link, or it may be matched to a listed name that
resembles it. Treat every returned key as a candidate and confirm it against the
source text before linking records; a missing or null key is not proof that the
document names no other record. The original recipe evaluation did not test
absent candidates.
Use unambiguous names, handle duplicate names and aliases in your application,
and check both that a returned key belongs to your catalog and that the document
supports the relationship. A missing match may be an absent or empty link array,
a null key, or a link item without key. Validate the returned data before
using it to update records.
This recipe is for small candidate sets. It does not establish exhaustive
matching against a larger table, and independent enums do not constrain which
film–actor pairs are valid. Do not truncate a larger catalog and interpret missing
links as evidence that the document contains no matching records.