# Invoice to JSON Extraction API (x402)

> Invoice to JSON Extraction API (x402) is a paid API for AI agents from freetier-agent-api.pages.dev, paid per call via x402, $0.0075/call, status unknown (last checked 2026-10-29).

Extracts structured JSON data from invoices and receipts provided as a PDF, image, or text, including line items, totals, vendor/customer details, and validation checks.

## Facts

- Endpoint: POST https://freetier-agent-api.pages.dev/api/invoice-json?utm_source=zero.xyz
- Price: $0.0075/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/invoice-to-json-extraction-api-x402-18d69d7d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_qtdC8Obg8rgc-GwkMb2Si

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability invoice-to-json-extraction-api-x402-18d69d7d -d '<json body>'
```

Example prompt: Can you parse this invoice PDF at https://example.com/invoice.pdf and give me the vendor, customer, line items, totals, and due date as structured JSON — and tell me if the math checks out?

## When to prefer this

Choose this endpoint when you need to extract structured, validated invoice or receipt data from PDFs, images, or raw text without setting up an account or API key, and want per-call micropayment pricing via USDC on Base. It is especially well-suited for AI agents doing automated accounts payable, expense processing, or document ingestion pipelines where privacy matters (documents are not stored).

## Known failure modes

- File exceeds 8 MB limit — request rejected
- Scanned PDF without image input returns poor extraction quality (text layer absent)
- LLM misreads complex or unusual invoice layouts — confidence scores help flag this
- Invalid or inaccessible URL returns an error
- Unsupported MIME type causes rejection
- Payment not completed via x402 results in 402 Payment Required response

## How this service works

Invoice-to-JSON, on-chain tools (transaction explainer + payment check, wallet profile, contract ABI, ERC-20 token risk), company contacts and web-to-RAG for AI agents. Pay per call with x402 (USDC on Base). No signup, no API key.

## Output

A JSON object containing: document type, vendor and customer name/address, invoice number, issue date, due date, currency, line items with amounts and confidence scores, subtotal, VAT breakdown, total amount due, validation checks (e.g. subtotal+VAT=total), missing fields, overall confidence score, model used, and a note that documents are not stored.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "url": {
   "type": "string",
   "description": "public http(s) URL of a PDF, PNG, JPEG or WebP invoice/receipt (max 8 MB)"
  },
  "text": {
   "type": "string",
   "description": "invoice text instead of a file (max 40,000 chars)"
  },
  "mime_type": {
   "type": "string",
   "description": "POST JSON only: application/pdf, image/png, image/jpeg, image/webp or text/plain"
  },
  "file_base64": {
   "type": "string",
   "description": "POST JSON only: base64 file content"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "input": "pdf",
  "model": "@cf/mistralai/mistral-small-3.1-24b-instruct",
  "pages": 1,
  "checks": {
   "due_date_not_before_issue_date": true,
   "subtotal_plus_vat_equals_total": true,
   "vat_breakdown_sum_equals_vat_total": true,
   "line_items_sum_equals_subtotal_or_total": true
  },
  "limits": "LLM extraction can misread layouts; check important values (quotes make that quick). Scanned PDFs need image input. Documents are not stored.",
  "totals": {
   "total": 4.11,
   "subtotal": 4.11,
   "vat_total": 0,
   "amount_due": 4.11
  },
  "vendor": {
   "name": "Amazon Web Services, Inc.",
   "address": "410 Terry Ave North Seattle, WA 98109-5210, US"
  },
  "missing": [
   "vendor_vat_id"
  ],
  "sources": [
   {
    "url": "https://developers.cloudflare.com/workers-ai/",
    "name": "Cloudflare Workers AI: toMarkdown (PDF text layer), Mistral Small 3.1 24B (OCR of images + field extraction; fallback Llama 3.3 70B / Llama 4 Scout / Gemma 3...",
    "note": "Documents are processed in memory and not stored or logged. No third-party LLM API."
   }
  ],
  "currency": "USD",
  "customer": {
   "name": "iViveLabs Limited",
   "address": "93B Sai Yu Chung Yuen Long, N.T., 0000, HK"
  },
  "due_date": "2014-08-03",
  "billed_usd": 0.003,
  "issue_date": "2014-08-03",
  "line_items": [
   {
    "quote": "AWS Data Transfer $0.01",
    "amount": 0.01,
    "vat_rate": 0,
    "confidence": 0.85,
    "description": "AWS Data Transfer"
   }
  ],
  "text_chars": 1839,
  "document_type": "invoice",
  "vat_breakdown": [
   {
    "base": 0.01,
    "rate": 0,
    "quote": "VAT ** $0.00",
    "amount": 0,
    "confidence": 0.85
   }
  ],
  "invoice_number": "42183017",
  "confidence_method": "Per field: 0.6 if the quote is found verbatim in the document text (+0.3 if the value matches the quote; 0.35 base if the quote is not verbatim), then +0.08/...",
  "overall_confidence": 0.94
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/invoice-to-json-extraction-api-x402-18d69d7d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from freetier-agent-api.pages.dev](https://www.zero.xyz/host/freetier-agent-api.pages.dev/llms.txt)
