api quickstart

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.

full api referenceopenapi.jsonbase url · https://api.patrapi.com
authentication

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_KEY
1 · send the document

post 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 fieldrequiredwhat it does
fileyesThe document: a PDF, JPEG, PNG or WebP. One file is one document.
versionnoPin a published version of the workflow. Latest when omitted.
waitnoHold the request open up to this many seconds (60 at most) and return the finished extraction if it completes in time.
metadatanoA JSON object as a string. Returned on the extraction and in webhooks, so you can carry your own ids.
passwordnoThe open password of a locked PDF. Used once to unlock the file, never stored.
2 · read the result

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 keywhat it holds
valueWhat was read, as printed on the document.
normalizedThe same value in a clean, typed form: dates as YYYY-MM-DD, amounts as numbers, names in capitals.
statusWhether the value was found: present, not_present, unreadable, redacted, conflicting.
pageThe page it was read from.
source_textThe text on the page the value came from: the evidence.
bboxWhere on the page, as four numbers, when known.
field statuswhat it means
presentFound, with the source text to prove it.
not_presentNot on this document. The value is null, never invented.
unreadableIt is there, but the scan is too poor to read it.
redactedMasked on the document itself.
conflictingTwo different values on the document. Sent to review.
webhooks

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 … }
}
errors

when it says no.

Errors are JSON with a _tag naming what went wrong. These are the ones sending a document can return.

status_tagwhat happened
401UnauthorizedThe key is missing, malformed, revoked or unknown.
402InsufficientCreditsThe account's pages cannot cover this document. The body carries `required` and `available`, in pages.
404WorkflowNotPublishedNo such workflow for this key, or it has no published version (or not the one asked for).
422UnsupportedFileThe file is not a PDF, JPEG, PNG or WebP that patrapi can read.
422PasswordProtectedThe PDF is locked: `reason` is `password_required` or `wrong_password`. Send `password` with the file.
429RateLimitedToo many requests. Wait `retry_after_seconds`; the `Retry-After` header says the same.
every endpoint

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.

methodpathwhat it does
POST/v1/workflows/{id}/extractionsRun 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/extractionsSubmit 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}/feedbackTell 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—