> ## Documentation Index
> Fetch the complete documentation index at: https://pdfbase.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured extraction

> Extract structured data from PDFs using AI. Turns invoices, receipts, and documents into typed JSON.

## Phase

**Phase 3** — Ships only if \$1K+ MRR. Requires LLM infrastructure.

## Request

<ParamField body="source" type="object" required>
  The PDF to extract from. Same source options as other endpoints:

  * `{ "pdf_id": "pdf_abc123" }`
  * `{ "url": "https://example.com/invoice.pdf" }`
  * `{ "base64": "JVBERi0x..." }`
</ParamField>

<ParamField body="preset" type="string">
  Use a built-in extraction preset. Mutually exclusive with `schema`. Available presets:

  * `invoice` — Extracts: vendor, customer, line items, subtotal, tax, total, invoice number, dates.
  * `receipt` — Extracts: merchant, items, total, payment method, date.
  * `contract` — Extracts: parties, effective date, termination date, key terms, signatures.
  * `resume` — Extracts: name, contact, experience, education, skills.
</ParamField>

<ParamField body="schema" type="object">
  Custom extraction schema. Define the exact fields you want extracted. Mutually exclusive with `preset`.

  ```json theme={null}
  {
    "vendor_name": "string",
    "total_amount": "number",
    "currency": "string",
    "line_items": [{
      "description": "string",
      "quantity": "number",
      "unit_price": "number"
    }]
  }
  ```
</ParamField>

<ParamField body="pages" type="string" default="all">
  Pages to extract from.
</ParamField>

## Response

```json theme={null}
{
  "id": "ext_struct1",
  "object": "extraction",
  "status": "completed",
  "method": "ai",
  "preset": "invoice",
  "data": {
    "vendor_name": "Acme Corp",
    "customer_name": "Globex Industries",
    "invoice_number": "INV-2026-0042",
    "invoice_date": "2026-05-01",
    "due_date": "2026-06-01",
    "line_items": [
      {
        "description": "Widget Pro (Annual License)",
        "quantity": 10,
        "unit_price": 50.00,
        "total": 500.00
      },
      {
        "description": "Premium Support",
        "quantity": 1,
        "unit_price": 200.00,
        "total": 200.00
      }
    ],
    "subtotal": 700.00,
    "tax": 63.00,
    "total": 763.00,
    "currency": "USD"
  },
  "confidence": 0.96,
  "created_at": "2026-05-19T14:00:00Z"
}
```

<ResponseField name="confidence" type="number">
  AI confidence score. Range: 0.0 to 1.0. Below 0.8 suggests ambiguous or low-quality source document.
</ResponseField>

<ResponseField name="data" type="object">
  Extracted data matching the preset or custom schema. Field types match what was specified.
</ResponseField>

## Example

```bash theme={null}
# Using a preset
curl -X POST https://api.pdfbase.dev/v1/extract/structured \
  -H "Authorization: Bearer pk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { "pdf_id": "pdf_invoice" },
    "preset": "invoice"
  }'

# Using a custom schema
curl -X POST https://api.pdfbase.dev/v1/extract/structured \
  -H "Authorization: Bearer pk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { "url": "https://example.com/report.pdf" },
    "schema": {
      "company_name": "string",
      "revenue": "number",
      "quarter": "string",
      "highlights": ["string"]
    }
  }'
```
