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.lighton.ai/api/v3/extract \
-H 'Authorization: Bearer $TOKEN' \
-F file=@invoice.pdf \
-F 'schema={"type":"object","properties":{"invoice_number":{"type":"string"}}}'
Async mode (options.async = true)
Returns 202 immediately with an ext_<token> job id. Poll GET /api/v3/extract/{id} with that same id until status is completed or failed.
curl -X POST https://api.lighton.ai/api/v3/extract \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{"document": "https://example.com/report.pdf", "schema": {"type": "object", "properties": {"title": {"type": "string"}}}, "options": {"async": true}}'
For multipart uploads, pass options as a JSON-encoded form field: -F 'options={"async":true}'.
Supported file types: .pdf, .png, .jpg, .jpeg, .pptx, .ppt, .odp, .docx, .odt, .doc, .html
Sync limits: 20 MB file size, 15 pages.
Async limits: 100 MB file size, 1000 pages.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Body for POST /api/v3/extract.
schema is the JSON Schema that drives extraction. It arrives as a dict
on JSON requests and as a JSON-encoded string on multipart requests — both
are coerced to dict.
options is a free-form dict; currently supports {"async": bool}.
Response
Extraction completed (sync mode).
Live progress of a long-running async job while it is in flight.
Shared by the parse (GET /api/v3/parse/<id>) and extract
(GET /api/v3/extract/<id>) polling envelopes: pages_processed is the
count of pages done so far and percentage is the completion percentage
[0, 100] derived from it.