For the complete documentation index, see llms.txt. This page is also available as Markdown.
Extraction

Quickstart: extract a document

One document in, structured fields out, in a single call.

Goal. Send a PDF to Document AI and get back structured fields — company name, dates, financial line items — without writing any polling logic.

This is the shortest path from a file to data. It uses the synchronous endpoint, which holds the connection open until extraction finishes. That makes it ideal for trying the API out and poor for production, for reasons the last section covers.

Before you start

  • An API key. Settings → API Keys in the portal, as Owner or Admin — see Authentication.

  • A document. This recipe uses a one-page balance sheet PDF.

  • A client that will wait at least two minutes for a response.

export DOCAI_API_KEY='ak_…'

Step 1 — Choose a document type

Extraction is schema-driven: telling the platform what the document is determines which fields it looks for. Values come from the registry.

curl -s "https://api-docai-uat.uptiq.ai/listSupportedDocuments" \
  | jq -r '.documents[] | "\(.type)\t\(.category)"' | head
ACATAccountTransferForm         Account Transfer Document
AadhaarCard                     Identity Document
AccountReceivablesAgingReport   Financial Report
AccountsPayableAgingReport      Financial Report
ArticlesOfIncorporation         Corporate Document

We want BalanceSheet. If you do not know the type ahead of time, classify first.

Step 2 — Build the request

The document travels inside the JSON body, base64-encoded, so no multipart upload is involved.

If your file already has a URL the platform can reach, send file_url instead of content and skip the base64 step. Send one or the other — never both.

Step 3 — Call the endpoint

Use Synchronous document extraction for the complete request and response schema.

This took 93 seconds for a single page. That is normal — the work is OCR plus model inference. Do not lower your timeout to "fix" it.

Step 4 — Read the result

Check documentStatusProcessed means it worked. status: "success" refers to the API call, not the document, and will read success even for a document that failed to process.

The fields are under result.extractedData, each with its value and where it was found on the page:

The bbox coordinates are in inches, page-relative — enough to draw a highlight over the source document if you are building a review UI.

Step 5 — Judge whether to trust it

Do not treat every extraction as equally good. result.extractionMetrics grades the run:

On our run, four of six expected fields were populated — hence completenessScore of 66.67 — because the test document was deliberately sparse. missingFields names exactly what was not found.

A sensible gate: auto-accept above a threshold on accuracyScore, route anything below it to human review. result.documentQuality.level (high, and a sharpness figure) tells you whether a poor result is the document's fault or the model's.

What it cost

Useful for chargeback, and for noticing when a job runs away.

When it goes wrong

Symptom
Cause
Fix

401

Missing, expired or revoked key

Check Settings → API Keys

500 immediately

Missing or malformed body — not a server fault on this endpoint

Validate your JSON; see Errors

Client timeout

Waiting less than ~2 minutes

Raise the timeout, or use the async endpoint

documentStatus: Failed

The document could not be read

Check result.documentQuality; resubmitting an unreadable file will fail again

Empty extractedData

Wrong documentType for the document

Next steps

Do not build production on this endpoint. Ninety seconds of held connection does not survive a load balancer, a serverless timeout, or a user watching a spinner. Move to Extract asynchronously and poll, or better, Build an event-driven pipeline. The request body is identical — only the URL changes.

Last updated