Skip to content

Packets

A packet is one submission of several documents that belong together: a claim form, the hospital bill, pharmacy bills, the discharge summary, a few reports. Deskew routes each document to one of your published extractors, runs them as ordinary background jobs, and when the last one finishes evaluates packet rules across the results: the claimed total against the sum of the bills, one patient name across documents, dates that agree.

Terminal window
curl https://api.deskew.dev/v1/packets \
-H "Authorization: Bearer $DESKEW_API_KEY" \
-F "packet=health-claim" \
-F "files=@claim-form.pdf" \
-F "files=@final-bill.pdf" \
-F "files=@pharmacy-1.jpg" \
-F "files=@discharge-summary.pdf"

Repeat files for each document, or send one zip (expanded one level; nested zips are refused; at most 40 documents). The answer is 202 with the packet; poll GET /v1/packets/{id} or set a webhook_url and wait for packet.completed. Packets always run in the background.

Each document becomes a job with source: "packet", visible under Jobs and billed as usual. One extra credit per document pays for routing when the document is not assigned.

Without assignments, Deskew asks the fast model which of the candidate extractors the document is, reading its first two pages. Candidates are the extractors of the packet definition’s roles, or every published extractor in the project when no definition is given. A document that matches none is parsed only, carries extractor: null, and adds the warning flag unrouted_document.

To skip routing for a file, pass assignments as JSON mapping file name to extractor: -F 'assignments={"claim-form.pdf": "health-claim-form"}'.

Each document’s routing object reports assigned, the model’s confidence and a one-line reason.

A definition names roles and the rules across them.

{
"title": "Health claim packet",
"roles": {
"claim": { "extractor": "health-claim-form", "min": 1, "max": 1 },
"hospital_bill": { "extractor": "hospital-invoice", "min": 1, "max": 1 },
"pharmacy_bills": { "extractor": "pharmacy-bill", "min": 0, "max": null },
"discharge": { "extractor": "discharge-summary", "min": 0, "max": 1 }
},
"rules": [
{ "id": "claimed_vs_bills",
"check": "abs(claim.claimed.total - (hospital_bill.total + sum(pharmacy_bills[].total))) <= 1",
"message": "The claimed total does not match the bills", "severity": "error" },
{ "id": "same_patient",
"check": "lower(claim.patient.name) == lower(hospital_bill.patient.name)",
"message": "Patient name differs between the form and the bill", "severity": "error" }
]
}
  • A role with max: 1 is singular: its data is one object (claim.claimed.total). A role with max: null or greater than one is plural: its data is a list, addressed as pharmacy_bills[].total or count(pharmacy_bills). Using pharmacy_bills.total on a plural role is a validation error.
  • min below the number of documents found adds an error flag missing_role; more than max documents adds a warning flag too_many_documents and the extra ones are ignored for singular roles (role_duplicate).
  • Rules use the rules language over the packet data; every path must start with a role name. Rules on missing values are skipped, not failed, exactly as in extractors.
  • The role’s extractor must be published in the project when a packet is submitted, else 409 extractor_unpublished.

Create one with POST /v1/packet-definitions ({name, definition} or {name, from_starter: "health-claim"}), edit it with PUT /v1/packet-definitions/{name} (the version increments; running packets keep the snapshot they started with), archive with DELETE. There is one starter today, health-claim, which expects the eight claims starters to be published.

{
"object": "packet",
"id": "pkt_01M…",
"status": "flagged",
"env": "live",
"definition": { "name": "health-claim", "version": 2, "title": "Health claim packet" },
"documents": [
{ "id": "pkd_…", "job_id": "job_…", "position": 0, "file_name": "claim-form.pdf",
"role": "claim", "extractor": "health-claim-form", "version": 3,
"routing": { "assigned": true }, "status": "completed",
"extraction": { "status": "ok", "flags": 0, "credits": 7 }, "error": null },
{ "id": "pkd_…", "job_id": "job_…", "position": 1, "file_name": "final-bill.pdf",
"role": "hospital_bill", "extractor": "hospital-invoice", "version": 5,
"routing": { "assigned": false, "confidence": 0.93, "reason": "itemised charges and a net payable" },
"status": "completed", "extraction": { "status": "flagged", "flags": 1, "credits": 11 }, "error": null }
],
"data": { "claim": { … }, "hospital_bill": { … }, "pharmacy_bills": [ { … } ], "discharge": null },
"flags": [
{ "rule": "claimed_vs_bills", "severity": "error", "message": "The claimed total does not match the bills",
"fields": ["claim.claimed.total", "hospital_bill.total", "pharmacy_bills[].total"],
"detail": "claim.claimed.total=184300.0, hospital_bill.total=181300.0, pharmacy_bills[].total=[1 items]" },
{ "rule": "document_flagged", "severity": "warning", "message": "'final-bill.pdf' was flagged by extractor 'hospital-invoice'", "fields": ["hospital_bill"] }
],
"credits": 31,
"created_at": "2026-12-05T09:12:04Z",
"finished_at": "2026-12-05T09:13:40Z",
"packet_url": "https://api.deskew.dev/v1/packets/pkt_01M…"
}
Status Meaning
queued, processing Documents still running
completed Every document done, no error flags
flagged At least one error flag: a failed rule, a missing role, a failed or rejected document
failed No document could be processed
canceled Cancelled with DELETE while queued; jobs that had not started are cancelled

data holds each role’s extracted data (null for an absent singular role, [] for an empty plural one); it is omitted from the list endpoint and from the webhook payload. Per-document evidence stays on the job result (GET /v1/jobs/{job_id}/result).

packet.completed fires once per packet with the packet object minus data as data, to every endpoint subscribed to it and to the packet’s webhook_url. See Webhooks.