Extract Fields
Creates and starts an Extract job. Extract pulls the fields you define out of a document, using an inline schema or a saved configuration.
Input: send exactly one of file and upload_ids. Send exactly one of schema (an inline JSON schema, as a JSON string) and config_id (a saved extraction configuration). Several files in one request are read together and give one merged result.
Processing: the job runs asynchronously. This call returns a job_id straight away with status pending. Poll GET /doc-ai/v1/job/{job_id}/status until a terminal status (completed, partially_completed, failed, rejected), then fetch the output:
GET /doc-ai/v1/job/{job_id}/resultsreturnsresult(your fields) plusannotations, which mirrorsresultand gives every field aconfidenceand itssources.GET /doc-ai/v1/job/{job_id}/download-urlreturns the CSV or XLSX file when you set thatoutput_format.
Retrying: add an Idempotency-Key header to retry the same submission without creating a second job.
Authentication
Headers
Retry the same submission without creating another job. The same key with the same request returns the original job; the same key with a changed request returns 409 IDEMPOTENCY_KEY_REUSED.
Request
Document file(s) to extract from. Repeatable multipart part. Exactly one of file and upload_ids must be provided.
Comma-separated upload IDs returned by POST /doc-ai/v1/job/upload. Exactly one of file and upload_ids must be provided.
Inline extraction schema as a JSON string. The root must be type: "object" with non-empty properties; every field needs a type, and a description is recommended. Supported types: string, number, integer, boolean, object, array (objects need properties, arrays need items); optional enum; maximum nesting depth 4. Exactly one of schema and config_id is required.
Saved extraction configuration ID. Exactly one of schema and config_id is required. To get your config_id, see Reuse a schema.
Language code of the document (BCP-47), e.g. en-IN, hi-IN. Defaults to indic (Indic OCR). For English documents, send en-IN. Always pass the document’s language for best accuracy.
Not supported on Extract. Sending true returns 400 CLASSIFICATION_NOT_SUPPORTED. To classify a document, use the Classify operation.
Model to use. Leave it out to use the default, sarvam-vision-v1. Other values, including sarvam-vision, return 400 MODEL_INVALID.
Extraction mode. basic reads each field on the page where it is printed; best for forms, IDs, and invoices at volume. advanced adds a second reading of the whole document to resolve context such as quarterly vs annual values and to check that line items add up to the total; best for financial statements, filings, slide decks, and long records. advanced takes longer and costs more per page. Both modes take the same schema and return the same response format.