Skip to content

Background jobs

Every extraction is a job. Short ones finish inside the request; the rest are queued and you fetch the result later. This page covers the second case. For the rule that decides which is which, see Concepts.

A 202 from POST /v1/extract returns the job stub:

{
"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"
}

You get a 202 when the document is too large for a synchronous run, when you pass mode=async, or when a synchronous run exceeds its 55-second budget and is downgraded. Handle all three the same way.

GET /v1/jobs/:id returns the full job object. While status is processing, pages.done advances and eta_seconds estimates the time left from the observed page rate. It is null until at least one page is done.

import time
def wait_for(job_id, timeout=600):
deadline = time.time() + timeout
while time.time() < deadline:
job = requests.get(f"{API}/v1/jobs/{job_id}", headers=HEADERS).json()
if job["status"] == "completed":
return requests.get(f"{API}/v1/jobs/{job_id}/result", headers=HEADERS).json()
if job["status"] in ("failed", "canceled"):
raise RuntimeError(job.get("error") or job["status"])
time.sleep(min(max(job.get("eta_seconds") or 2, 1), 10))
raise TimeoutError(job_id)

Poll no faster than once a second; polling counts against your rate limit. For anything beyond a handful of concurrent jobs, use webhooks instead.

status Meaning
queued Accepted, waiting for a worker
processing Pages are being extracted; pages.done and eta_seconds update
completed Result available at result_url until expires_at
failed Nothing could be produced; error holds {type, code, message}
canceled Stopped by DELETE /v1/jobs/:id

A job fails only when the document itself cannot be processed (corrupt file, no pages, engine outage on every page). Individual pages that cannot be read are counted in pages.failed; the job still completes and the result’s warnings[] and page_results[] tell you which pages are missing.

GET /v1/jobs/:id/result returns the result object as JSON. Before completion it answers 409 result_not_ready; the job object tells you the current status.

DELETE /v1/jobs/:id moves a queued or processing job to canceled and returns the job object. Pages already in flight finish, but no result is stored, no webhook fires and the job is not billed. Cancelling a job that has already completed or failed is a no-op that returns the job unchanged. The key needs the jobs:write scope, or extract:write as a fallback.

Results are stored for 24 hours from completion (expires_at on the job). After that the stored JSON is deleted and GET /v1/jobs/:id/result answers 410 result_expired. The job record itself, with its status, page counts and credits, stays visible in GET /v1/jobs and the dashboard.

Download results promptly or let a webhook trigger the download. If you need a result after it has expired, submit the document again; with an Idempotency-Key that has also expired (24 hours), that is simply a new job.

GET /v1/jobs lists the key’s project jobs newest first, filtered by status and paginated with limit (1–100, default 20) and starting_after=<job id>. Job ids are ULIDs, so pagination is by id and stable under new arrivals.

Terminal window
curl "https://api.deskew.dev/v1/jobs?status=completed&limit=50" \
-H "Authorization: Bearer $DESKEW_API_KEY"