Extract structured data from a document
Extract structured data from a document
Pull specific fields from a document into a typed schema.
Accepts either a file upload (multipart/form-data) or a document URL (JSON body), plus a JSON Schema (the schema field) describing what to extract.
Sync mode (default)
Blocks until extraction completes and returns 200 with the full result.
curl -X POST https://api.context212.com/api/v1/extract \ -H 'Authorization: Bearer $TOKEN' \ -F file=@invoice.pdf \ -F 'schema={"type":"object","properties":{"invoice_number":{"type":"string"}}}'Async mode (options.async = true)
Not implemented yet — returns 501.
For multipart uploads, pass options as a JSON-encoded form field: -F 'options={"async":true}'.
Supported file types: .pdf, .png, .jpg, .jpeg, .pptx, .docx, .xlsx, .html, .xhtml
Sync limits: 20 MB file size, 15 pages.
Authorization
bearerAuth Console session token (Authorization: Bearer <session>) or product API key (Authorization: Bearer <api-key> or x-api-key). Session tokens are validated via Better Auth get-session; API keys against the shared database.
In: header
Header Parameters
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/api/v1/extract" \ -H "Content-Type: application/json" \ -d '{ "schema": {} }'{ "id": "string", "status": "string", "created_at": "2019-08-24T14:15:22Z", "completed_at": "2019-08-24T14:15:22Z", "processing_time_ms": 0, "document": { "filename": "string", "page_count": 0, "file_size_bytes": 0, "mime_type": "string" }, "result": { "data": [ {} ], "pagination": { "page": 0, "page_size": 0, "total_items": 0, "total_pages": 0, "has_next": true, "has_prev": true } }, "usage": { "pages_processed": 0 }, "progress": { "percentage": 0, "pages_processed": 0 }}Render a document as PDF POST
Render a document as PDF Convert a document into a PDF suitable for inline preview. Accepts a **file upload** (multipart/form-data), a **document URL**, or a **file_id** referencing a document already ingested in the platform (JSON body). The conversion is synchronous — the PDF bytes are returned directly. **Supported file types:** `.pdf`, `.png`, `.jpg`, `.jpeg`, `.pptx`, `.ppt`, `.odp`, `.docx`, `.odt`, `.doc`, `.html`, `.xhtml` **Size limit:** 20 MB.
Get the status and result of an async extract job GET
Get the status and result of an async extract job Poll for the status and result of an async extract job submitted via `POST /api/v1/extract` with `options.async=true`. Returns the same envelope shape as the synchronous extract endpoint once `status` is `completed`. **Pagination:** when completed, `result.data` is paginated with a fixed page size of 15. Use the `page` query param (1-based) to navigate; `result.pagination` reports `total_items`, `total_pages`, `has_next`, `has_prev`. **Recommended polling cadence:** 1s for the first 10s, then 5s, capped at 30s. Stop polling once `status` is in `{completed, failed}`.