Skip to content

Extractors

Extractors live under /v1/extractors and are shared between the test and live keys of a project. Reading needs extractors:read, changing needs extractors:write; both are on new keys by default. Concepts are in the Extractors overview; test documents and test runs are on their own page.

{
"object": "extractor",
"id": "ext_01JE4KH8W9X0Y1Z2A3B4C5D6E7",
"name": "hospital-invoice",
"title": "Hospital invoice",
"published_version": 2,
"published_at": "2026-12-04T11:02:40.558Z",
"draft_updated_at": "2026-12-04T11:30:12.004Z",
"draft_ahead": true,
"from_starter": null,
"archived_at": null,
"created_at": "2026-12-04T10:02:11.418Z"
}
Field Type Description
id string ext_ followed by a ULID
name string Unique per project, immutable. ^[a-z][a-z0-9_-]{0,63}$
title string From the definition’s title, else the name
published_version integer | null Current version, null before the first publish
published_at string | null When that version was published
draft_updated_at string Last draft edit
draft_ahead boolean true when the draft has edits that are not published yet (or nothing is published)
from_starter string | null The starter this extractor was cloned from, else null
archived_at string | null Set once archived
created_at string

Responses that carry a definition add definition (the full JSON, see Defining fields) and is_draft. Reading a published version also adds version and json_schema, the JSON Schema of the output data.

{
"object": "extractor_version",
"version": 2,
"notes": "tightened invoice_number pattern",
"published_by": null,
"published_at": "2026-12-04T11:02:40.558Z",
"test_summary": { "documents": 2, "passed": 2, "failed": 0, "field_accuracy": 1.0, "...": "..." }
}

published_by is null when published through the API. test_summary is the summary of the test run the publish was gated on, or null. GET .../versions/{n} adds definition.

GET https://api.deskew.dev/v1/extractors

Scope extractors:read. Ordered by name; not paginated.

Query Default Description
include_archived false Also return archived extractors
Terminal window
curl https://api.deskew.dev/v1/extractors -H "Authorization: Bearer $DESKEW_API_KEY"
{ "object": "list", "data": [ { "object": "extractor", "name": "hospital-invoice", "published_version": 2, "draft_ahead": false, "...": "..." } ] }

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

Scope extractors:write. Creates a draft; nothing is published yet.

Body field Type Description
name string Required. Lowercased; must match ^[a-z][a-z0-9_-]{0,63}$
definition object The definition. Omitted, a one-field placeholder (title, type string) is used
from_starter string Clone a starter by id (hospital-invoice, discharge-summary, pharmacy-bill, diagnostic-report, prescription, health-claim-form, motor-repair-estimate, id-document). The starter’s definition becomes the draft; definition is ignored except for title
include_test_set boolean With from_starter: copy the starter’s sample documents and their expected output into the test set. Default true; counts against the plan’s test-document limit
Terminal window
curl https://api.deskew.dev/v1/extractors \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "hospital-invoice",
"definition": {
"title": "Hospital invoice",
"fields": [
{ "name": "invoice_number", "type": "string", "required": true },
{ "name": "total", "type": "money", "required": true }
]
}
}'

201 Created:

{
"object": "extractor",
"id": "ext_01JE4KH8W9X0Y1Z2A3B4C5D6E7",
"name": "hospital-invoice",
"title": "Hospital invoice",
"published_version": null,
"published_at": null,
"draft_updated_at": "2026-12-04T10:02:11.418Z",
"draft_ahead": true,
"from_starter": null,
"archived_at": null,
"created_at": "2026-12-04T10:02:11.418Z",
"definition": { "title": "Hospital invoice", "description": "", "locale": "en-IN", "document": { "...": "..." }, "fields": [ "..." ], "rules": [], "output": { "...": "..." } },
"is_draft": true
}

The stored definition is the validated form with every default filled in.

Status Code When
404 starter_not_found Unknown from_starter id; GET /v1/starters lists the ids
403 plan_limit The project already has the plan’s maximum number of extractors (limit in the error)
409 extractor_exists An extractor with this name exists, archived or not
422 validation_error name malformed (param: "name")
422 extractor_invalid The definition has problems; problems[] lists {path, message}

GET https://api.deskew.dev/v1/extractors/{name}

Scope extractors:read. Returns the published version’s definition by default. Works for archived extractors.

Query Description
version A specific version number
draft true to return the draft definition
Terminal window
curl https://api.deskew.dev/v1/extractors/hospital-invoice -H "Authorization: Bearer $DESKEW_API_KEY"
curl "https://api.deskew.dev/v1/extractors/hospital-invoice?draft=true" -H "Authorization: Bearer $DESKEW_API_KEY"
{
"object": "extractor",
"name": "hospital-invoice",
"published_version": 2,
"version": 2,
"is_draft": false,
"definition": { "...": "..." },
"json_schema": {
"type": "object",
"title": "Hospital invoice",
"properties": {
"invoice_number": { "type": "string" },
"total": { "type": "number" }
},
"required": ["invoice_number", "total"]
},
"...": "..."
}

When nothing is published and version is not given, the draft is returned with "note": "No published version yet; showing the draft.".

Status Code When
404 extractor_not_found No extractor with this name
404 extractor_version_not_found version does not exist

PUT https://api.deskew.dev/v1/extractors/{name}/draft

Scope extractors:write. Validates and compiles the definition. A valid definition replaces the draft; an invalid one is not stored and the problems are returned with 200, so an editor can show them inline.

Body field Type Description
definition object Required. The whole definition; there is no partial update
Terminal window
curl -X PUT https://api.deskew.dev/v1/extractors/hospital-invoice/draft \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"definition": {"title": "Hospital invoice", "fields": [{"name": "total", "type": "money"}], "rules": [{"id": "positive", "check": "totl > 0"}]}}'
{
"object": "extractor_draft",
"name": "hospital-invoice",
"valid": false,
"problems": [ { "path": "rules.0.check", "message": "unknown field 'totl'" } ]
}

On success:

{
"object": "extractor_draft",
"name": "hospital-invoice",
"valid": true,
"problems": [],
"definition": { "...": "..." },
"draft_updated_at": "2026-12-04T11:30:12.004Z"
}

Saving the draft does not change what extractor=hospital-invoice runs; extractor=hospital-invoice@draft does.

Status Code When
404 extractor_not_found No such extractor, or it is archived

POST https://api.deskew.dev/v1/extractors/validate

Scope extractors:read. Validates and compiles without storing anything. Free.

Body field Type Description
definition object Required
{
"valid": true,
"problems": [],
"fields": 9,
"rules": 3,
"prompt_chars": 1842,
"json_schema": { "type": "object", "properties": { "...": "..." }, "required": [ "..." ] }
}

fields counts scalar leaves. prompt_chars is the size of the compiled model prompt before the document text is added. On an invalid definition the body is {"valid": false, "problems": [...]}.

POST https://api.deskew.dev/v1/extractors/{name}/publish

Scope extractors:write. Turns the draft into the next version and makes it current. Gated on the latest test run of the draft; see the publish gate.

Body field Type Default Description
notes string "" Up to 2,000 characters, kept on the version
force boolean false Publish even though the latest test run has failures
Terminal window
curl -X POST https://api.deskew.dev/v1/extractors/hospital-invoice/publish \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"notes": "first version"}'

201 Created: the version object plus name and warnings:

{
"object": "extractor_version",
"name": "hospital-invoice",
"version": 1,
"notes": "first version",
"published_by": null,
"published_at": "2026-12-04T10:02:11.418Z",
"test_summary": null,
"warnings": ["The test set has never been run on this draft."]
}
Status Code When
404 extractor_not_found No such extractor, or archived
409 extractor_tests_failing The latest draft test run has failing documents and force is not set. The error carries test_summary and test_run_id
422 extractor_invalid The draft does not validate

POST https://api.deskew.dev/v1/extractors/suggest

Scope extractors:write. Upload one typical document and get a proposed definition to start from: title, description, must-contain and reject-if statements, fields with types, descriptions and aliases, and a few rules. The proposal is cleaned and validated server-side, so it is always a valid draft; anything the model suggested that did not fit (an invalid rule, a field nested too deep) is listed in dropped. Nothing is created: send the definition to Create an extractor when you are happy with it.

Multipart form fields: file (the sample) or url, or job_id of a completed job to re-use its parsed text without parsing again. Costs the parse credits of the document plus 10 credits for the proposal. Large documents answer status: "queued" with the job; poll the job and call again with job_id.

Terminal window
curl https://api.deskew.dev/v1/extractors/suggest \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-F "file=@sample-bill.pdf"
{
"object": "suggestion",
"status": "ready",
"job_id": "job_01M…",
"definition": { "title": "Hospital invoice", "description": "…", "document": { "must_contain": ["…"], "reject_if": ["…"] }, "fields": [ … ], "rules": [ … ], "output": { … } },
"dropped": ["rule total_math: unknown field grand_total"],
"warnings": [],
"credits": 10
}

GET https://api.deskew.dev/v1/starters and GET https://api.deskew.dev/v1/starters/{id}

Scope extractors:read. Deskew-maintained definitions to clone, each with sample documents and expected output. The list carries { id, title, summary, category, fields, rules, samples }; a single starter also carries its full definition. See Starters.

GET https://api.deskew.dev/v1/extractors/{name}/versions

Scope extractors:read. Newest first, without definitions.

{
"object": "list",
"data": [
{ "object": "extractor_version", "version": 3, "notes": "rolled back to v1", "published_by": null, "published_at": "2026-12-04T12:00:09.311Z", "test_summary": null },
{ "object": "extractor_version", "version": 2, "notes": "tightened invoice_number pattern", "published_by": null, "published_at": "2026-12-04T11:02:40.558Z", "test_summary": { "...": "..." } },
{ "object": "extractor_version", "version": 1, "notes": "first version", "published_by": null, "published_at": "2026-12-04T10:02:11.418Z", "test_summary": null }
]
}

GET https://api.deskew.dev/v1/extractors/{name}/versions/{version}

Scope extractors:read. The version object with its full definition.

Status Code When
404 extractor_not_found, extractor_version_not_found

POST https://api.deskew.dev/v1/extractors/{name}/rollback

Scope extractors:write. Publishes a new version with the definition of an older one and resets the draft to it. Earlier versions are untouched.

Body field Type Description
version integer Required. The version to copy
Terminal window
curl -X POST https://api.deskew.dev/v1/extractors/hospital-invoice/rollback \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"version": 1}'

201 Created:

{ "object": "extractor_version", "name": "hospital-invoice", "version": 3, "notes": "rolled back to v1", "published_by": null, "published_at": "2026-12-04T12:00:09.311Z", "test_summary": null }
Status Code When
404 extractor_not_found, extractor_version_not_found

DELETE https://api.deskew.dev/v1/extractors/{name}

Scope extractors:write. Archives the extractor: hidden from the default list, no longer callable, no longer counted against the plan limit. Versions, runs and test documents stay readable.

Terminal window
curl -X DELETE https://api.deskew.dev/v1/extractors/hospital-invoice -H "Authorization: Bearer $DESKEW_API_KEY"

200 OK:

{ "object": "extractor", "name": "hospital-invoice", "archived_at": "2026-12-04T12:30:00.000Z" }

There is no un-archive endpoint. Posting the same name to the deprecated POST /v1/schemas re-activates it with a new version.

GET https://api.deskew.dev/v1/extractors/{name}/runs

Scope jobs:read. Jobs that ran this extractor in the key’s mode (test or live), newest first.

Query Default Description
status ok, flagged or rejected
limit 20 1 to 100
starting_after A job id; returns runs older than it
Terminal window
curl "https://api.deskew.dev/v1/extractors/hospital-invoice/runs?status=flagged&limit=50" \
-H "Authorization: Bearer $DESKEW_API_KEY"
{
"object": "list",
"data": [
{
"id": "job_01JE4K9QW2M3N4P5Q6R7S8T9V0",
"object": "job",
"status": "completed",
"mode": "sync",
"file_name": "bill-0913.pdf",
"pages": { "total": 2, "done": 2, "failed": 0 },
"credits": { "estimated": 7, "used": 7 },
"extraction": { "extractor": "hospital-invoice", "version": 2, "status": "flagged", "flags": 1 },
"result_url": "https://api.deskew.dev/v1/jobs/job_01JE4K9QW2M3N4P5Q6R7S8T9V0/result",
"...": "..."
}
],
"has_more": false,
"counts": { "ok": 41, "flagged": 6, "rejected": 2 }
}

Each entry is a job object whose extraction summary here has extractor, version, status and flags (no credits). counts is over every run of the extractor in this mode, regardless of the filter. A document rejected with output.on_reject: error appears as a rejected run with job status: "failed".

Status Code When
403 insufficient_scope The key lacks extractors:read, extractors:write or jobs:read as required
403 plan_limit Plan maximum reached; see Rate limits and quotas
404 extractor_not_found Unknown name, or archived where writes are concerned
404 extractor_version_not_found Unknown version number
409 extractor_exists Name already taken
409 extractor_tests_failing Publish blocked by the test set
422 extractor_invalid Definition problems, listed in problems[]
422 validation_error A malformed name or body

Full descriptions in Errors.