Skip to content

POST /v1/extract

POST https://api.deskew.dev/v1/extract

Send one document and get back its content. Small documents are processed inline (200); larger ones are queued (202). Requires the extract:write scope.

Two body formats are accepted:

  • multipart/form-data with a file part and the options below as further fields. Use this to upload.
  • application/json with a url field and the options as JSON properties. Deskew fetches the URL (30 s timeout, up to 5 redirects, 500 MB max).

A url field is also accepted in multipart form, in place of file.

Header Required Description
Authorization yes Bearer deskew_live_sk_… or Bearer deskew_test_sk_… (X-Api-Key is an alternative)
Content-Type yes multipart/form-data (set automatically by HTTP clients) or application/json
Idempotency-Key no Any string up to 255 characters; replays the stored response for 24 hours. See Idempotency
Name Type Default Description
file file The document. One of file or url is required
url string http(s):// URL of the document. One of file or url is required
output markdown | json | text markdown Which representation to return. json returns markdown, text and blocks together
tables boolean true Detect tables and return tables[]
bbox boolean false Include bounding boxes on blocks[] (implies blocks are returned)
quality auto | fast | accurate | premium auto Engine policy for scanned pages. See Concepts
handwriting boolean false Route scanned pages to the handwriting model (+2 credits per scanned page)
fields boolean false Extract generic key-value fields (+2 credits per page)
schema string Name of a stored schema to extract into; implies fields (+2 credits per page)
images boolean false Accepted and recorded; image extraction is not available yet and the flag has no effect on the result
language string Language hint (for example de, pt-BR) passed to the OCR engines for scanned pages. Text-layer and Office pages ignore it
mode auto | sync | async auto Force inline or queued processing. See Concepts
webhook_url string Also deliver this job’s events to this URL. See Webhooks
pdf_password string Password for an encrypted PDF. In JSON bodies, send as options.pdf_password
Terminal window
# Upload
curl https://api.deskew.dev/v1/extract \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "file=@invoice.pdf" \
-F "output=json" \
-F "bbox=true" \
-F "fields=true"
# From a URL
curl https://api.deskew.dev/v1/extract \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/report.pdf","output":"markdown","quality":"accurate","mode":"async"}'

The document was processed inline. The body is the result object:

{
"id": "job_01JE4K9QW2M3N4P5Q6R7S8T9V0",
"status": "completed",
"pages": 1,
"markdown": "# Invoice 2026-0193\n\n**Northwind Studio** · Due 2026-12-28\n\n| Item | Qty | Amount |\n|---|---|---|\n| Design work | 12 h | 1,440.00 |\n| Hosting | 1 | 49.00 |\n| Total | | 1,489.00 |",
"text": "Invoice 2026-0193\n\nNorthwind Studio · Due 2026-12-28\n\nItem\tQty\tAmount\nDesign work\t12 h\t1,440.00\nHosting\t1\t49.00\nTotal\t\t1,489.00",
"blocks": [
{ "type": "heading", "page": 1, "text": "Invoice 2026-0193", "bbox": [0.071, 0.062, 0.52, 0.097], "level": 1, "confidence": 1.0, "meta": {} },
{ "type": "paragraph", "page": 1, "text": "Northwind Studio · Due 2026-12-28", "bbox": [0.071, 0.11, 0.46, 0.128], "confidence": 1.0, "meta": {} },
{ "type": "table", "page": 1, "text": "", "bbox": [0.071, 0.182, 0.929, 0.33], "confidence": 1.0, "meta": { "table_index": 0 } }
],
"tables": [
{
"page": 1,
"bbox": [0.071, 0.182, 0.929, 0.33],
"n_rows": 4,
"n_cols": 3,
"rows": [["Item", "Qty", "Amount"], ["Design work", "12 h", "1,440.00"], ["Hosting", "1", "49.00"], ["Total", "", "1,489.00"]],
"csv": "Item,Qty,Amount\nDesign work,12 h,\"1,440.00\"\nHosting,1,49.00\nTotal,,\"1,489.00\"",
"markdown": "| Item | Qty | Amount |\n|---|---|---|\n| Design work | 12 h | 1,440.00 |\n| Hosting | 1 | 49.00 |\n| Total | | 1,489.00 |"
}
],
"fields": {
"document_type": "invoice",
"title": "Invoice 2026-0193",
"date": "2026-11-28",
"parties": ["Northwind Studio", "Ledgerly Inc."],
"identifiers": [{ "name": "Invoice number", "value": "2026-0193" }],
"total_amount": 1489.0,
"currency": "EUR",
"key_values": [{ "key": "Due date", "value": "2026-12-28" }]
},
"page_results": [
{ "page": 1, "kind": "digital", "engine": "text-layer", "confidence": 1.0, "quality_score": null, "language": null, "duration_ms": 131, "credits": 1, "low_confidence": false }
],
"usage": { "pages": 1, "credits": 3, "premium_credits": 2, "engines": { "text-layer": 1 } },
"warnings": []
}

The document was queued, because it exceeded the synchronous limits, because you sent mode=async, or because an inline run passed its 55-second budget.

{
"id": "job_01JE4KB0X8Y2Z3A4B5C6D7E8F9",
"object": "job",
"status": "queued",
"mode": "async",
"pages": { "total": 48, "done": 0 },
"poll_url": "https://api.deskew.dev/v1/jobs/job_01JE4KB0X8Y2Z3A4B5C6D7E8F9",
"created_at": "2026-12-02T09:14:07.512Z"
}

Poll poll_url or wait for a webhook, then fetch /v1/jobs/{id}/result.

Status Code When
401 missing_api_key, invalid_api_key, key_revoked, key_expired Authentication failed
403 insufficient_scope, ip_not_allowed Key not allowed to do this
402 quota_exceeded Plan allowance or spend cap would be exceeded
409 idempotency_conflict Idempotency-Key reused with a different request
413 file_too_large, sync_limit_exceeded Over 500 MB, or mode=sync on an ineligible document
415 unsupported_type, legacy_office_unsupported File format not supported
422 validation_error, missing_file, empty_file, invalid_url, url_fetch_failed Bad request
422 password_protected, corrupt_file, empty_document, too_many_pages Document cannot be processed (inline runs; for jobs these appear in error)
429 rate_limited, test_daily_cap Slow down, or the test key’s daily pages are used up
500 / 503 processing_failed, engine_error, engine_unavailable Processing failed inline

Full descriptions in Errors.