Extract

Extract structured data from a document

Changed on

Pull specific fields from a document into a typed schema.

Accepts exactly one of: a file upload (multipart/form-data), a document URL (JSON body), or a file_id referencing an already-ingested document (from POST /v3/files), 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.

post/api/v3/extract

Request

  • Base URL
    https://api.lighton.ai
  • URL
    https://api.lighton.ai/api/v3/extract
  • Auth
    HTTP bearer

Request body

documentstring nullable
file_idinteger nullable
schemaobject required
optionsobject

Response

Extraction completed (sync mode).

idstring required
statusstring required
created_atstring date-time nullable
completed_atstring date-time nullable
processing_time_msinteger nullable

Changes

    • breaking

      added required request body

    • info

      api operation id api_v3_extract_create was added

    • info

      the endpoint scheme security bearerAuth was added to the API

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the success response with the status

    • info

      added the success response with the status