TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sputhenofficial/claimjumper/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/triage route in app/api/triage/route.ts is the single server-side endpoint in ClaimJumper. It accepts a multipart form upload containing a PNG EOB screenshot, runs the full five-stage pipeline (ingest → triage → invariants → prioritize → draft), and returns a TriageResponse JSON object containing every denial line ranked by priority with lane decisions, deadlines, urgency scores, and—where applicable—ready-to-review draft artifacts.
Request
The endpoint expects amultipart/form-data POST with a single file field named eob.
Must be
multipart/form-data. The request body is parsed with the standard Web Request.formData() API.A PNG EOB or remittance advice screenshot. The file must be a valid PNG — the server validates the PNG magic bytes before making any model call. Maximum image size is limited only by what the OpenAI vision API can process.
Response: 200 OK
A successful response is aTriageResponse JSON object. All denial lines from the remittance are present in items, sorted by descending priority_score.
remittance field contains the payer and provider header data extracted from the first claim on the remittance. Individual QueueItem entries carry the full claim context for each service line.
QueueItem
Each element of items represents one actionable service-line denial.
The complete parsed claim containing the
remittance header, claim metadata (claim ID, patient name, service date, received date), and the full lines array for that claim.The specific service line this queue item represents, including procedure code, billed/allowed/paid amounts, patient responsibility, and the denial codes (
group_code, carc, rarc).Triage output merged with scheduling data. Contains the
DenialTriage decision (lane, root cause, rationale, evidence needed, confidence, recovery probability, overrides), the calculated appeal deadline (ISO date string), a 0–1 urgency score, and a finite priority_score used to sort the queue.Present when
prioritized.triage.lane is "appeal", "corrected_claim", or "human_review". Contains the generated draft title, body content, lane tag, and a citations array pointing back to specific fields in the parsed claim. Omitted for patient_bill and write_off lanes. A draft failure does not fail the line — artifact will simply be absent.Error responses
A human-readable description of the failure, suitable for display in the UI.
A stable machine-readable error category. Use this to distinguish between client-correctable errors and server-side failures.
| Status | kind | Cause |
|---|---|---|
400 | "bad_file" | The eob field is missing from the form, or the uploaded bytes do not start with the PNG magic bytes. |
500 | "server_error" | Any unhandled pipeline failure — model errors, schema validation failures, claim mapping errors. |
PNG validation
Before any model call is made, the server reads the first 8 bytes of the uploaded file and compares them against the canonical PNG magic byte sequence. This prevents the pipeline from spending model tokens on non-image files and returns a clear400 immediately.
The PNG magic bytes are [137, 80, 78, 71, 13, 10, 26, 10] — the standard \x89PNG\r\n\x1a\n signature defined in the PNG specification.
isPng() returns false, the route immediately returns a 400 with kind: "bad_file" and does not call OpenAI.
runTriagePipeline()
The route handler delegates all pipeline logic to the exported runTriagePipeline() function. Separating the function from the Next.js handler makes every pipeline stage independently testable without a running HTTP server.
PipelineDependencies
All external collaborators can be replaced for testing via the optional second argument:
| Field | Default | Purpose |
|---|---|---|
ingest | ingest from lib/pipeline/ingest | Extracts structured claims from the image via the OpenAI vision API. |
triage | triage from lib/pipeline/triage | Classifies each denial line into a lane with rationale and confidence. |
draft | responseWithTextSchema from lib/openai | The model client used to generate appeal and corrected-claim drafts. |
today | () => new Date().toISOString().slice(0, 10) | Returns today’s UTC date string; override in tests for deterministic deadlines. |
dependencies is omitted (as in the live route handler), all four defaults use the real OpenAI Responses API.
All model calls — ingest, triage, prioritize, and draft — are executed server-side inside
runTriagePipeline(). The browser sends only the PNG file in a multipart/form-data POST and receives a single TriageResponse JSON object in return. No OpenAI API key or model output is ever exposed to the client.