How to Use the PDF.ai Extract API

Publish date
Sep 13, 2026
AI summary
The Extract API lets you send a JSON schema to /v2/extract to receive named fields, tables, or invoice lines as JSON with citations back to the source PDF; it can reuse a cached docId to avoid parse credits, charges credits based on page count and field count (≤5 fields uses 2 credits/page, >5 uses 4 credits/page), and requires an API key. Use it for automated data extraction when the next step is a structured database row, not for free‑form chat answers.
Language
People look up an Extract API when a PDF is not the final answer. They need named fields, tables, or invoice lines as JSON — with a schema, citations back to the page, and a docId they can reuse.
This page is the schema → fields path on the PDF.ai API v2 Extract endpoint. It does not replace the API Hub (keys and plan live there). It does not re-rank the head term pdf api. For the first-request path (key + first Parse), see How to Get Started with the PDF.ai API. For the browser extract job (not code), see Extract Data from PDF: Get Fields and Tables Out.

What Extract is for

After a clean Extract call on PDF.ai API v2, three things should be true:
  • You sent a JSON schema that names the fields you want
  • The response includes data.result shaped like that schema, plus data.citations that point each field back to source segments
  • You know whether parse credits applied (new file/url) or you reused a cached docId
Docs: Extract. Playground (no article needed to try the shape): https://pdf.ai/extract.
Practical rule: Extract answers "give me these fields." Ask answers a free-form question. Parse turns the PDF into markdown/contents first. Use Extract when your next step is a database row, not a chat reply.

Browser extract vs Extract API

Path
Best when
What you get
Web extract UI
One file, no code
Fields in the browser
API POST /v2/extract
Automation, your product, batches
JSON (result • citations) with an X-API-Key

Credits before you scale a schema

From the live Extract and credit usage docs:
  • Extraction credits: 2 credits × page count when the schema has ≤5 fields; 4 credits × page count when the schema has >5 fields
  • Parse credits: apply when you send a file or url and there is no cached parse; 0 when you pass a cached docId
  • Total: parse credits + extraction credits
Examples from the Extract docs:
  • 10-page PDF, not cached, advanced parse quality, schema with 3 fields → parse 20 + extract 20 = 40 credits
  • 5-page PDF, cached docId, schema with 8 fields → parse 0 + extract 20 = 20 credits
API plan examples on credit usage:
  • Free: $0/month for 200 credits/month, no credit card required
  • Paid examples: $49 / 3,000, $99 / 10,000, $249 / 30,000, $599 / 100,000 credits per month
Generate the key and manage the plan on https://pdf.ai/developer. The docs say the key is shown only once when generated.
Practical rule: keep schemas ≤5 fields while you are proving the pipeline. Crossing 5 fields doubles extract credits per page.

How to call Extract

1. Have an API key

Open https://pdf.ai/developer, generate a key, store it as a secret. Send it as the X-API-Key header on every call.

2. Prefer a cached docId when you already parsed

If you already ran POST https://pdf.ai/api/v2/parse, keep the docId. Passing that docId into Extract skips parse credits for that call.
If you have not parsed yet, you can still send file or url on Extract; parse credits will apply during that call, and the response returns a docId for later reuse.

3. POST a schema

Endpoint from the docs: POST https://pdf.ai/api/v2/extract
Content type: multipart/form-data.
Required:
  • schema — JSON Schema string defining the structure to extract
Optional (from Extract):
  • system_prompt — default "Be precise and thorough."
  • docId, or url, or file
  • quality: standard (default) or advanced
  • lang_list: languages for standard OCR (default ["en"])
Example shape (Python), matching the docs sample:
import requests
import json

url = "https://pdf.ai/api/v2/extract"
headers = {"X-API-Key": "YOUR_API_KEY"}

schema = {
    "type": "object",
    "properties": {
        "title": {"type": "string"},
        "author": {"type": "string"}
    },
    "required": ["title"]
}

data = {
    "docId": "your-document-id",
    "schema": json.dumps(schema),
    "system_prompt": "Extract document metadata accurately."
}

response = requests.post(url, headers=headers, data=data)
print(response.json())
A successful response includes success, data.result, data.citations (each with content, pageNumber, schemaLink), and docId.

4. Check the output before you trust it

  • Confirm success and that data.result keys match your schema
  • Open at least one citations[].pageNumber in the source PDF and compare the cited content to the field value
  • If you get Invalid API key / No API key present, fix the header before you change the schema
  • If fields are empty on a scanned PDF, parse first with quality=standard (or set quality on Extract when sending file/url) and retry with the returned docId
Practical rule: a non-empty result object is not a verified invoice. Read the citation for every field you will write to a database.

When Extract is the wrong tool

  • You need a free-form answer in code. Use POST https://pdf.ai/api/v2/ask with a prior docId (Ask). Ask is 3 credits × total page count across the docIds you query.
  • You wanted a generic “pdf api” category hub. Stay on https://pdf.ai/developer. This page is the Extract how-to, not a replacement hub.

A short action plan

  1. Open https://pdf.ai/developer, create a key, store it once.
  1. Check credit usage against page count and field count (≤5 vs >5).
  1. Parse a short PDF (or reuse a docId), then POST https://pdf.ai/api/v2/extract with a tight schema.
  1. Verify data.result against data.citations and the source PDF before you wire production.
If you want the rest of the PDF workflow after the fields are clean, start at PDF.ai. Use the Extract API when the next step is your schema, not a single upload box.