Extract structured data from a document
Changed onUpload a file, provide a URL, or reference an existing document to extract structured data.
Provide exactly one document source: file, file_url, or document_id.
Optionally supply a schema (inline JSON or schema_id) and/or free-text instructions to guide extraction.
Synchronous or asynchronous. The number of pages plays no part:
- With a schema (inline schema or schema_id) the response is synchronous (200). A newly uploaded file is read first: the request stays open while that happens (it waits up to 300 seconds for the document to be read) and then extracts.
- Without a schema the response is asynchronous by default (202).
- A document that is already completed, and a document uploaded for text only or for storage only, are answered synchronously.
- async in options overrides this: true forces 202, false forces 200.
Asynchronous results. The 202 body names the document, not a job. Poll GET /v1/documents/{id} (the poll_url) until status is completed, then read GET /v1/documents/{id}/extractions or GET /v1/extractions/{id}. Those return the document's own captured values. They are not shaped to a schema sent with the request: to get values in your schema, call this endpoint with document_id and the schema once the document is completed. That call is synchronous and works from the text already read.
Request
- Base URLhttps://api.talonic.com
- AuthHTTP bearer
Headers
Unique key for idempotent requests, at most 64 characters (a longer key is refused with 400 invalid_idempotency_key before any work). A retry with the same key, request and API key within 24 hours returns the first response with Idempotent-Replayed: true; the same key on a different request or from another API key answers 422 idempotency_key_reused. On POST /v1/extract the key caches the extraction result for the workspace instead: any key of the workspace sending it gets that result with cached: true.
Request body multipart/form-data
The document file to extract from. Max 500 MB. Accepted types: PDF, PNG, JPG, TIFF, WEBP, DOCX, TXT, CSV.
Public URL of the document to download and extract from.
ID of an already-uploaded document to re-extract.
Inline JSON Schema definition describing the fields to extract.
ID of a saved schema to use for extraction.
Free-text extraction instructions (e.g. "Extract all line items with amounts").
When "true", includes the OCR-converted markdown of the document in the response under the markdown field. Useful for PDF-to-markdown conversion without requiring a schema.
JSON string of extraction options.
- async (boolean) — force async (true, answers 202) or sync (false, answers 200) processing. Must be a JSON boolean, not a string. When omitted, a request with a schema is synchronous and a request without one is asynchronous.
Optional caller grouping key stamped on the document (documents.client_batch_id).
Optional JSON string of a FLAT object { [key]: string | number | boolean | null } (nested objects/arrays rejected 400; ≤50 keys, key ≤128, string value ≤1024), stamped on the document as documents.client_metadata.
Example request
{
"document_id": "f0e1d2c3-b4a5-9687-8765-432109876543",
"schema_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901"
}Response
Synchronous extraction completed.
Extracted key-value pairs.
Example response
{
"extraction_id": "d1a2b3c4-5678-9abc-def0-1234567890ab",
"request_id": "req_x7y8z9a0b1c2d3e4",
"status": "complete",
"document": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"filename": "invoice-042.pdf",
"pages": 3,
"size_bytes": 245760,
"type_detected": "Invoice",
"language_detected": "en"
},
"data": {
"invoice_number": "INV-2024-0042",
"total_amount": 1250,
"vendor_name": "Acme Corp"
},
"schema": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
},
"confidence": {
"overall": 0.92,
"fields": {
"invoice_number": 0.99,
"total_amount": 0.95,
"vendor_name": 0.82
}
},
"processing": {
"duration_ms": 3420,
"pages_processed": 3,
"region": "eu-west"
}
}Changes
- breaking
the
request_idresponse's property format changed fromuuidto no format for status - breaking
removed the required property
jobfrom the response with the status - info
added the optional property
links/documentto the response with the status
5 more changes in this revision
- breaking