# x402-gateway Document Extract to JSON

> x402-gateway Document Extract to JSON is a paid API for AI agents from x402.freeq.one, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-31).

Extracts structured JSON (sections, tables, key-values, and caller-named fields) from documents (PDF, DOCX, PPTX, XLSX, CSV, EPUB, HTML, text) using deterministic parsing — no OCR or LLM inference — paid per call in USDC on Base.

## Facts

- Endpoint: POST https://x402.freeq.one/tools/document_extract?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-31
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-gateway-document-extract-to-json-860b5add
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__UL0aFv2PEaxfzPObJfEx

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 x402-gateway-document-extract-to-json-860b5add -d '<json body>'
```

Example prompt: Extract structured JSON from this PDF invoice at https://example.com/invoices/inv-2024-001.pdf — I need the document sections, any tables, and these specific fields: invoice_number (string), total_amount (number), due_date (date), and is_paid (boolean).

## When to prefer this

Choose this endpoint when you need deterministic, reproducible structured extraction from common document formats (PDF, DOCX, PPTX, XLSX, CSV, EPUB, HTML) without relying on LLM inference or OCR. It is especially valuable when you need typed, named fields extracted consistently, or when you want to avoid hallucination risks from LLM-based parsers. Prefer it over LLM document tools when auditability and determinism matter, and over OCR tools when the document has parseable text layers.

## Known failure modes

- Invalid or inaccessible document URL returns an error
- Unsupported file format returns a format error
- Base64-encoded file exceeding 28MB is rejected
- Caller-named fields that cannot be matched return null (not an error)
- More than 20 caller-named fields returns a validation error
- Malformed or corrupted document may return a partial or empty extraction
- Payment not received or insufficient USDC balance returns 402 Payment Required

## How this service works

Document Extract to JSON: Extract structured JSON from a document: sections, tables, key-values and caller-named fields. PDF, DOCX, PPTX, XLSX, CSV, EPUB, HTML, text. Deterministic parsing — no OCR, no LLM inference. Pay per call in USDC on Base via x402 — POST https://x402.freeq.one/tools/document_extract.

## Output

A structured JSON object containing the document's parsed sections, tables, and key-value pairs, along with any caller-named fields and their typed values (string, number, boolean, or date). Unmatched caller-named fields return null rather than guessed values. Output is deterministic — identical input always produces identical output.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "url": {
   "type": "string",
   "example": "https://x402.freeq.one/samples/report.pdf",
   "description": "Alias for document_url"
  },
  "fields": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "name": {
      "type": "string",
      "example": "invoice_number"
     },
     "type": {
      "enum": [
       "string",
       "number",
       "boolean",
       "date"
      ],
      "type": "string",
      "example": "string"
     }
    }
   },
   "description": "Optional caller-named fields (max 20), each {name, type} with type string, number, boolean or date; unmatched fields return null, never guessed"
  },
  "file_b64": {
   "type": "string",
   "maxLength": 28000000,
   "description": "Base64-encoded document bytes (alternative to document_url)"
  },
  "filename": {
   "type": "string",
   "example": "report.pdf",
   "description": "Optional original filename"
  },
  "max_length": {
   "type": "integer",
   "example": 100000,
   "description": "Truncate converted text to N characters"
  },
  "document_url": {
   "type": "string",
   "example": "https://x402.freeq.one/samples/report.pdf",
   "description": "Direct URL to the document (alternative: file_b64)"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-gateway-document-extract-to-json-860b5add/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.freeq.one](https://www.zero.xyz/host/x402.freeq.one/llms.txt)
