PDF-to-JSON
PDF data extraction to JSON
Endpoint
https://www.claix.dev/api/pdf-jsonThis endpoint accepts a PDF file and returns a single JSON object with the data extracted from the document, following exactly the structure you define via a schema. It works with selectable-text PDFs and scanned PDFs, because analysis is performed by an AI model with native document understanding, not a plain-text extractor.
It is intended for server-to-serverintegrations (backends, scripts, n8n/Zapier/Make). It must not be called from an end user's browser because it requires a secret API key.
Unlike Excel/CSV, the full PDF is treated as a single data source and the response contains exactly one record in data — ideal for invoices, contracts, forms, certificates, or reports.
1. Authentication
Every request must include your API key. It is a personal server credential and should be handled with the same care as a database password.
Option A — Dedicated header (recommended):
x-api-key: <YOUR_API_KEY>
Option B — Standard Authorization header:
Authorization: Bearer <YOUR_API_KEY>
Either one is sufficient. If you send both, x-api-key takes priority.
Before processing the PDF, the system validates that:
- The API key exists and is active.
- The associated account is active (not suspended).
If validation fails, the request is rejected with 401 without processing the file.
2. Request format
Method: POST · Content-Type: multipart/form-data (required)
| Field | Type | Required | Description |
|---|---|---|---|
| file | Binary file | Yes | The PDF to analyze. Must be the file itself, not a path or URL. |
| schema_id | Text (UUID) | Yes | Schema previously created in your account, of type PDF → JSON. |
Field names must be exactly file and schema_id. Aliases such as pdf, documento, or upload are not supported.
The schema_id must correspond to a schema of type PDF → JSON. If you send one of Excel → JSON or another type, you will receive 400.
File requirements:
- Format: .pdf only (validated by MIME type and extension).
- Cannot be empty (0 bytes).
- Maximum size: 15 MB (413 error if exceeded).
- Compatible with text and scanned PDFs.
3. How to build the request
- Have your API key and the correct schema_id ready.
- Build a POST request to the endpoint URL.
- Add the authentication header.
- Send
multipart/form-datawithfile(PDF) andschema_id. - Check the HTTP status code: only 200 indicates success.
4. Request examples
See the panel on the right for examples in cURL, JavaScript, Node.js, Python, PHP, and n8n.
5. Successful response format
200 OK · Content-Type: application/json
{
"success": true,
"schema_utilizado": "Facturas de Proveedores",
"total_registros": 1,
"data": [
{
"numero_factura": "F-2026-00456",
"fecha_emision": "2026-03-14",
"proveedor": "Suministros Industriales del Ebro S.L.",
"importe_total": 1284.50,
"moneda": "EUR"
}
]
}| Field | Type | Description |
|---|---|---|
| success | boolean | Always true when HTTP is 200. |
| schema_utilizado | string | Name of the applied schema (not the id). |
| total_registros | number | Always 1: one document = one extracted record. |
| data | array | Contains exactly one object with the schema properties. Values not found are null. |
If a schema property represents a list (e.g. invoice line items), instances are grouped in an array. If the schema expects a single value but there are multiple instances, the most relevant one is extracted.
6. Error codes
{
"error": "Descripción legible del problema.",
"detalle": "Información técnica adicional (solo presente en algunos casos)."
}400 — Missing file or schema_id, invalid multipart, not a PDF, empty file, corrupt file, or schema of the wrong type.
401 — Authentication failed.
404 — schema_id does not exist or does not belong to your account.
413 — PDF exceeds 15 MB.
422 — PDF read but no extractable data according to the schema.
502 — AI service failure (transient).
405 — Method other than POST. · 500 — Internal error.
7. Code summary
| Code | Category | Retry? |
|---|---|---|
| 200 | Success | — |
| 400 | Client error (malformed file or data) | No — fix the request first |
| 401 | Authentication error | No — fix credentials first |
| 404 | Resource not found | No — fix schema_id first |
| 405 | Incorrect HTTP method | No — fix the method first |
| 413 | PDF too large | No — reduce file size first |
| 422 | No extractable data | No — review PDF/schema first |
| 500 | Internal server error | Yes, with caution |
| 502 | AI service failure | Yes, recommended with backoff |
8. Best practices
- Validate the HTTP status code before reading data[0].
- Check the PDF size on your client before sending it.
- Remember: data always has exactly one element (one document = one object).
- Retry automatically only on 500 and 502, never on 400, 401, 404, 413, or 422.
- Clear descriptions on schema properties improve accuracy on documents with non-standard layouts.
- Do not include your API key in frontend code or public repositories.