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.
Request
Section titled “Request”Two body formats are accepted:
multipart/form-datawith afilepart and the options below as further fields. Use this to upload.application/jsonwith aurlfield 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.
Headers
Section titled “Headers”| 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 |
Parameters
Section titled “Parameters”| 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 |
Examples
Section titled “Examples”# Uploadcurl 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 URLcurl 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"}'import os, uuid, requests
API = "https://api.deskew.dev"HEADERS = {"Authorization": f"Bearer {os.environ['DESKEW_API_KEY']}"}
# Uploadwith open("invoice.pdf", "rb") as f: r = requests.post( f"{API}/v1/extract", headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())}, files={"file": f}, data={"output": "json", "bbox": "true", "fields": "true"}, )
# From a URLr = requests.post( f"{API}/v1/extract", headers=HEADERS, json={"url": "https://example.com/report.pdf", "output": "markdown", "quality": "accurate", "mode": "async"},)
if r.status_code == 200: result = r.json() # finished inlineelif r.status_code == 202: job = r.json() # poll job["poll_url"]else: print(r.json()["error"])import { readFile } from "node:fs/promises";import { randomUUID } from "node:crypto";
const API = "https://api.deskew.dev";const headers = { Authorization: `Bearer ${process.env.DESKEW_API_KEY}` };
// Uploadconst form = new FormData();form.append("file", new Blob([await readFile("invoice.pdf")]), "invoice.pdf");form.append("output", "json");form.append("bbox", "true");form.append("fields", "true");
let res = await fetch(`${API}/v1/extract`, { method: "POST", headers: { ...headers, "Idempotency-Key": randomUUID() }, body: form,});
// From a URLres = await fetch(`${API}/v1/extract`, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify({ url: "https://example.com/report.pdf", output: "markdown", quality: "accurate", mode: "async" }),});
if (res.status === 200) { const result = await res.json(); // finished inline} else if (res.status === 202) { const job = await res.json(); // poll job.poll_url} else { console.error((await res.json()).error);}Responses
Section titled “Responses”200 OK: result
Section titled “200 OK: result”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": []}202 Accepted: job
Section titled “202 Accepted: job”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.
Errors
Section titled “Errors”| 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.