one request,
fields back.
Post a document to a workflow you published; get each field as typed JSON, with the page and the text it was read from. This page is the short version of the reference.
a key,
as a bearer token.
Create a key in the app under keys; it starts with pat_live_ and is shown once. Send it on every request in the Authorization header. Keep it on your server, never in a browser or a mobile app.
A missing or revoked key gets 401. Too many requests get 429 with a Retry-After header.
Authorization: Bearer $PATRAPI_KEYpost a file
to your workflow.
POST /v1/workflows/{id}/extractions with the file as multipart form data. The workflow id comes from the app once the workflow is published. One file is one document, and costs 1¢₹1 a page. The result's credits is the pages billed.
Send an Idempotency-Key header to make retries safe. The same file sent twice to the same workflow version is read, and charged, once.
curl https://api.patrapi.com/v1/workflows/wf_YOUR_WORKFLOW_ID/extractions \
-H "Authorization: Bearer $PATRAPI_KEY" \
-H "Idempotency-Key: APP-2291-pan" \
-F [email protected] \
-F wait=30 \
-F metadata='{"application_id":"APP-2291"}'| form field | required | what it does |
|---|---|---|
| file | yes | The document: a PDF, JPEG, PNG or WebP. One file is one document. |
| version | no | Pin a published version of the workflow. Latest when omitted. |
| wait | no | Hold the request open up to this many seconds (60 at most) and return the finished extraction if it completes in time. |
| metadata | no | A JSON object as a string. Returned on the extraction and in webhooks, so you can carry your own ids. |
| password | no | The open password of a locked PDF. Used once to unlock the file, never stored. |
every value,
with its evidence.
With wait, a document that finishes in time comes back in the same response, status 200. Otherwise you get a receipt, status 202, and poll GET /v1/extractions/{id} or let a webhook tell you.
{
"object": "extraction.receipt",
"id": "ext_3f9c1e2ab7d44c0e9a51b6f0c2d87e14",
"status": "queued"
}curl https://api.patrapi.com/v1/extractions/ext_3f9c1e2ab7d44c0e9a51b6f0c2d87e14 \
-H "Authorization: Bearer $PATRAPI_KEY"An extraction's status is one of queued, processing, succeeded, needs_review, failed, cancelled, rejected. needs_review means a person should check the result before you use it.
{
"object": "extraction",
"id": "ext_3f9c1e2ab7d44c0e9a51b6f0c2d87e14",
"status": "succeeded",
"document_type": "pan_card",
"profile_version": 1,
"pipeline_version": "pan_card.v1.spec10",
"fields": {
"pan": {
"value": "ABCDE1234F",
"normalized": "ABCDE1234F",
"status": "present",
"page": 1,
"source_text": "Permanent Account Number ABCDE1234F",
"bbox": null
},
"name": {
"value": "ASHA RAMESH PATEL",
"normalized": "ASHA RAMESH PATEL",
"status": "present",
"page": 1,
"source_text": "Name ASHA RAMESH PATEL",
"bbox": null
},
"father_name": {
"value": null,
"normalized": null,
"status": "not_present",
"page": null,
"source_text": null,
"bbox": null
},
"date_of_birth": {
"value": "12/04/1990",
"normalized": "1990-04-12",
"status": "present",
"page": 1,
"source_text": "Date of Birth 12/04/1990",
"bbox": null
}
},
"warnings": [],
"review_reasons": [],
"credits": 1,
"metadata": {
"application_id": "APP-2291"
},
"workflow": {
"id": "wf_YOUR_WORKFLOW_ID",
"version": 1
},
"reviewed_at": null,
"rejection": null,
"pages": 1,
"created_at": "2026-11-25T09:30:00.000Z",
"completed_at": "2026-11-25T09:30:06.000Z",
"result_expires_at": "2027-02-23T09:30:06.000Z",
"deleted_at": null
}| field key | what it holds |
|---|---|
| value | What was read, as printed on the document. |
| normalized | The same value in a clean, typed form: dates as YYYY-MM-DD, amounts as numbers, names in capitals. |
| status | Whether the value was found: present, not_present, unreadable, redacted, conflicting. |
| page | The page it was read from. |
| source_text | The text on the page the value came from: the evidence. |
| bbox | Where on the page, as four numbers, when known. |
| field status | what it means |
|---|---|
| present | Found, with the source text to prove it. |
| not_present | Not on this document. The value is null, never invented. |
| unreadable | It is there, but the scan is too poor to read it. |
| redacted | Masked on the document itself. |
| conflicting | Two different values on the document. Sent to review. |
or be told
when it's done.
Add an endpoint in the app under webhooks and patrapi posts an event when an extraction finishes, is reviewed, or a batch completes: extraction.succeeded, extraction.needs_review, extraction.failed, extraction.approved, extraction.rejected, batch.completed.
Deliveries are signed the Standard Webhooks way, with the headers webhook-id, webhook-timestamp, webhook-signature. Verify them with any Standard Webhooks library and the endpoint's whsec_ secret. A failed delivery is retried with the same webhook-id, so deduplicate on it.
{
"id": "msg_2b7e0c9d41f84a6c8d3e5f1a9b0c7d62",
"type": "extraction.succeeded",
"timestamp": "2026-11-25T09:30:06.000Z",
"data": { … the extraction, as GET /v1/extractions/{id} returns it … }
}when it says no.
Errors are JSON with a _tag naming what went wrong. These are the ones sending a document can return.
| status | _tag | what happened |
|---|---|---|
| 401 | Unauthorized | The key is missing, malformed, revoked or unknown. |
| 402 | InsufficientCredits | The account's pages cannot cover this document. The body carries `required` and `available`, in pages. |
| 404 | WorkflowNotPublished | No such workflow for this key, or it has no published version (or not the one asked for). |
| 422 | UnsupportedFile | The file is not a PDF, JPEG, PNG or WebP that patrapi can read. |
| 422 | PasswordProtected | The PDF is locked: `reason` is `password_required` or `wrong_password`. Send `password` with the file. |
| 429 | RateLimited | Too many requests. Wait `retry_after_seconds`; the `Retry-After` header says the same. |
the whole api.
Generated from the same spec as the interactive reference, which has every request and response schema. Machines can read openapi.json or llms-full.txt; each recipe lists the fields its documents return.
| method | path | what it does |
|---|---|---|
| POST | /v1/workflows/{id}/extractions | Run a document through a published workflow. Returns 202 with an id to poll at `GET /v1/extractions/{id}`, or 200 with the finished extraction when `wait` is set and it completes in time, or the same bytes were already processed by this version. Send `Idempotency-Key` to make retries safe. |
| POST | /v1/extractions | Submit one logical document. Returns 202 with an id to poll. Send `Idempotency-Key` to make retries safe. Returns 200 with the existing resource when the same bytes were already processed under the same profile and pipeline version. |
| GET | /v1/extractions | — |
| GET | /v1/extractions/{id} | — |
| DELETE | /v1/extractions/{id} | Delete the document's data: stops it first if it is still queued or processing, then removes the field values, evidence, metadata and file name. The extraction stays (status, pages and usage) with `deleted_at` set. Results are also deleted automatically at `result_expires_at`. Safe to repeat. |
| POST | /v1/extractions/{id}/feedback | Tell us which fields were wrong and what they should have been. Send only the wrong fields: `{ "fields": { "pan": { "correct": "ABCDE1234F" }, "trade_name": { "correct": null } } }`, where `null` means the document doesn't carry the field. The result itself is not changed. Corrections show up as field health on the workflow, so its weak fields can be fixed. Sending a field again replaces its earlier correction. |
| GET | /v1/document-profiles | — |