Skip to navigation

Extract Fields

View as Markdown

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}/results returns result (your fields) plus annotations, which mirrors result and gives every field a confidence and its sources.
  • GET /doc-ai/v1/job/{job_id}/download-url returns the CSV or XLSX file when you set that output_format.

Retrying: add an Idempotency-Key header to retry the same submission without creating a second job.

Authentication

api-subscription-keystring
API Key authentication via header

Headers

Idempotency-KeystringOptional

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

This endpoint expects a multipart form with multiple files.
filefilesOptional

Document file(s) to extract from. Repeatable multipart part. Exactly one of file and upload_ids must be provided.

upload_idsstringOptional

Comma-separated upload IDs returned by POST /doc-ai/v1/job/upload. Exactly one of file and upload_ids must be provided.

schemastringOptional

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.

config_idstringOptional

Saved extraction configuration ID. Exactly one of schema and config_id is required. To get your config_id, see Reuse a schema.

languagestringOptionalDefaults to en-IN

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.

output_formatenumOptionalDefaults to json
Output format of the extraction results.
Allowed values:
classificationstringOptionalDefaults to false

Not supported on Extract. Sending true returns 400 CLASSIFICATION_NOT_SUPPORTED. To classify a document, use the Classify operation.

modelstringOptionalDefaults to sarvam-vision-v1

Model to use. Leave it out to use the default, sarvam-vision-v1. Other values, including sarvam-vision, return 400 MODEL_INVALID.

modeenumOptionalDefaults to basic

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.

Allowed values:

Response

Created
job_idstring
The unique identifier of the job.
statusstring
Current status of the job.
run_idstring
The unique identifier of the job run.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
413
Content Too Large Error
429
Too Many Requests Error
503
Service Unavailable Error