Lab uploads
Upload a person's lab report and Health Nexus reads it: the results become biomarkers with ranges and statuses, and the report appears in the person's records. An upload made through the API is treated exactly like one the person makes in the Health Nexus app.
One PDF per upload, up to 20 MB. The endpoints need the write scope.
1. Ask for an upload link
curl -s "$HN_BASE/api/patient/lab/uploads" \
-H "X-Api-Key: $HN_KEY" -H "X-Subject-Email: jane@example.com" \
-H "Content-Type: application/json" \
-d '{"filename":"Quest CBC 2026-11.pdf","size":482113}'
| Field | Required | Meaning |
|---|---|---|
filename | yes | Must end in .pdf. |
size | yes | The file size in bytes, exactly. |
fileType | no | LAB_RESULTS (default), IMAGING, GENETICS, REPORTS or AUTO. |
{
"uploadId": "6b10aa1f2c3d4e5f60718293",
"uploadUrl": "https://…",
"method": "PUT",
"headers": { "Content-Type": "application/pdf" },
"expiresInSec": 900,
"maxBytes": 20971520
}
2. Send the file
PUT the bytes to uploadUrl. This request goes to the storage service, not to the Health Nexus API, so it takes no API key and no X-Subject-* header.
curl -s -X PUT "$UPLOAD_URL" \
-H "Content-Type: application/pdf" \
--data-binary "@Quest CBC 2026-11.pdf"
The file must be exactly the size you declared; a different size is refused with 403. The link works for 15 minutes. A 200 with an empty body means the file is stored.
3. Complete the upload
curl -s -X POST "$HN_BASE/api/patient/lab/uploads/6b10aa1f2c3d4e5f60718293/complete" \
-H "X-Api-Key: $HN_KEY" -H "X-Subject-Email: jane@example.com"
{ "uploadId": "6b10aa1f2c3d4e5f60718293", "jobId": "6b10ab…", "status": "processing", "fileName": "Quest CBC 2026-11.pdf", "fileType": "LAB_RESULTS" }
The file is checked before anything starts:
| Reply | Meaning |
|---|---|
409 UPLOAD_NOT_FOUND | The file is not in storage yet. Send it, then call this again. |
400 NOT_A_PDF | The file is not a PDF. Start a new upload. |
409 SIZE_MISMATCH | The stored file is not the declared size. Start a new upload. |
409 UPLOAD_IN_PROGRESS | Another complete call is running. Try again in a moment. |
503 START_UNCONFIRMED | We could not confirm that processing started. Call again after Retry-After; the same job is used. |
Completing is safe to repeat: a second call returns the same jobId with HTTP 200.
4. Follow it
curl -s "$HN_BASE/api/patient/lab/uploads/6b10aa1f2c3d4e5f60718293" \
-H "X-Api-Key: $HN_KEY" -H "X-Subject-Email: jane@example.com"
status | Meaning |
|---|---|
awaiting_upload | The link was issued; the upload is not completed yet. |
processing | The report is being read. Usually under a minute. |
done | Finished. The results are in the lab summary and the report is in the reports list. |
failed | The file could not be read. failure.code and failure.message say why, in plain words. |
blocked | Stored, waiting on the person's clinic. It runs once the clinic's setup is complete. |
Poll every few seconds while processing. When it is done, read GET /api/patient/lab/user-summary and POST /api/patient/reports/list.
Why uploads fail
A failed upload names its reason, for example a password-protected PDF, an empty file, or pages that are photos too large to read. Show failure.message to the person as it is. They are also told in the Health Nexus app.