Webhook payload
Webhook delivery format, complete payload example, and field specifications.
How Webhooks Work
When a report finishes processing, Terra delivers one event to your configured webhook destination: lab_report.completed with the results, or lab_report.failed with the reason. Each run sends exactly one. A reprocess is a new run and sends a new event.
Configure your webhook URL in the Terra Dashboard
Upload a lab report via the API
Terra processes the report and delivers the event via HTTP POST to your endpoint
Your endpoint should return a
2xxstatus code to acknowledge receipt
Every webhook is an event envelope: event metadata (type, event_id, occurred_at, upload_id) wraps the report itself under data:
{
"type": "lab_report.completed",
"event_id": "evt_9f1c…",
"occurred_at": "2026-03-28T14:23:45Z",
"upload_id": "upl_4a2b…",
"data": { "session_id": "…", "panels": [ … ], "results": [ … ] }
}typeis the event:lab_report.completed(success) orlab_report.failed(failure). Branch on it in your handler.event_idis unique per event. Use it to deduplicate redeliveries.upload_idties every event from the same upload together. An upload is one report, so its events are the original run and any reprocesses.datais a focused event resource: the report's identity, metadata,panels, and standardizedresults. It is not the full session. For the full session (status history, file/byte counts, presigned files) callGET /v2/reports/{session_id}and its sub-resources.
Terra-Reference header
Webhook requests include a Terra-Reference header containing the session ID. You can use this for logging and deduplication before parsing the body.
X-Terra-Version header
Webhook requests include an X-Terra-Version header with your environment's pinned API version. An X-Terra-Version header on your upload request does not change it.
Complete payload example
Verifying webhooks
Lab-report webhooks are signed exactly like every other Terra webhook. Each request carries an X-Terra-Signature header, an HMAC-SHA256 of <timestamp>.<raw-request-body> keyed on the webhook's signing secret, of the form:
Verify this signature before trusting a payload. Verification must run against the raw, unaltered request body. Many web frameworks re-serialize the body by default, which changes the bytes and makes verification fail. Terra's SDKs ship a helper for this; see Payload signing for full verification examples in each language.
Failure webhook
If a report can't be processed, Terra delivers a failure webhook to the same destinations instead of the success payload, so you're notified rather than left waiting.
Success and failure are distinguished by the envelope type: lab_report.completed for a completed report, lab_report.failed for a failure. Branch on type in your handler. A failure event is the same envelope. Its data carries the session_id, reference_id, and an error object.
The same error object is on the session from GET /v2/reports/{session_id} while its status is failed.
A report that was processed but could not be delivered to any destination is not a failure. It ends in delivery_failed, with no error and its results available over the API.
Error object
code
string
Machine-readable failure code (see below)
message
string
Human-readable description. Not stable: branch on code.
retriable
boolean
true if reprocessing the report may succeed with no change to the file. false means the file must change first: upload a new one.
document_class
string?
Only with unsupported_report_type: what the file was judged to be instead. other_medical or non_medical.
Error codes
unsupported_report_type
false
The file is not a lab report or a DXA scan. document_class says whether it is another medical document (other_medical, such as a DNA test or an imaging report) or not medical at all (non_medical). If it is a valid medical document you want to keep, store the original file yourself.
file_unreadable
false
The file could not be read: a blurry or cropped photo, or a corrupt file. Ask the user for a clearer photo or the original document.
no_results_found
false
The file was readable, but has no test results in it.
file_too_large
false
The files are more than can be read as one report, or an image is over its pixel limit. Upload fewer or smaller files.
extraction_failed
false
The results could not be extracted from the file.
standardization_failed
true
Reserved for a failure to standardize the extracted results.
internal
Usually true
A problem on Terra's side. Reprocess the report when retriable is true.
Reports that fail are not billed.
New codes may be added over time. Treat an unknown code like internal, and use retriable to decide whether to reprocess.
Field specifications
Event envelope
type
string
lab_report.completed or lab_report.failed
event_id
string
Unique per event. Deduplicate redeliveries on it
occurred_at
string
When the event occurred (ISO-8601, UTC)
upload_id
string
Correlates every event produced from the same upload
data
object
The report resource: the Data Object below (completed) or an error (failed)
Data object
The data of a lab_report.completed event. This is a focused event resource with the report's identity, metadata, and standardized results. It is not the full session. For the full session (status history, file/byte counts, presigned files) call GET /v2/reports/{session_id} and its sub-resources. Input files, the thumbnail, and per-destination delivery state are not here. Fetch them on demand from the /files, /artifacts, and /deliveries sub-resources.
session_id
string
Snowflake int64 ID (as string), always present
reference_id
string
Your external identifier (from upload query param)
report_type
string
"lab" or "dexa", always present. Branch on this before reading results: dexa results carry biomarker.region and source.region_name; lab results carry biomarker.specimen.
report_date
string
Date from the lab report (YYYY-MM-DD)
report_time
string
Time from the lab report (HH:MM 24-hour)
report_locale
string
Locale of the report (e.g. "ja-JP", "pt-BR")
results_count
integer
Number of biomarker results, always present
panels
object[]
Report-level panels that results reference by panel_id (omitted if the report has no panel grouping)
results
object[]
Array of biomarker result objects, always present
report_notes
string
Free-text notes extracted from the report
Panel object
A panel is a report-level grouping (e.g. "CBC"). Results point at a panel by panel_id; join on it to group results under their panel.
id
integer
Report-local panel id, matches biomarker.panel_id on results
name
string
Verbatim panel header as printed on the report
key
string?
Normalized dedup key for the panel (a stable text key, not a LOINC code)
Result object
Each result is grouped into four layers plus its reference ranges. source is what the report literally printed, biomarker is the normalized identity, measurement is the single typed value, and interpretation is the coded abnormality signal.
source: verbatim provenance:
name
string
Exact biomarker name as printed on the report
panel
string?
Verbatim panel header (omitted if the result isn't panelled)
value
string?
The value exactly as printed on the report
units
string?
Units as printed on the report
flag
string?
Raw flag text as printed (e.g. "H", "↑", "Négatif")
method
string?
Lab methodology (e.g. "ECLIA")
notes
string?
Additional lab comments
reference_text
string?
Human-readable reconstruction of the printed reference range
region_name
string?
Anatomical site exactly as printed, in the report's own language (e.g. "L1-L4", "Bras gauche"). Present whenever the report shows a site, including when it matched no canonical region.
collection_date
string?
Date this measurement was taken (YYYY-MM-DD). On a scan with a trend table this is the date of the scan that row came from, which may be earlier than the report-level report_date.
collection_time
string?
Time this measurement was taken (HH:MM 24-hour)
biomarker: normalized identity:
key
string | null
Canonical biomarker slug; always present, null when unmatched
display_name
string?
Standardized English name
loinc_code
string?
LOINC code (omitted if not mapped). On a scan this identifies the (measure, site) pair, not the measure alone. Read it off each result rather than caching it against key. Coverage is partial on scans.
panel_id
integer?
References the panels[].id this result belongs to
panel_key
string?
Normalized panel key (see Panel Object)
specimen
string?
"blood", "serum", "plasma", "urine", "saliva", "stool", or "other". Omitted on scan results, which are scoped by region instead. A result carries one or the other, never both.
region
string?
Canonical anatomical site key on scan results (e.g. "l1_l4", "femur_neck_left", "android"). Together with key it forms the identity of the result. See Scans (DEXA) for the vocabulary.
measurement: one typed value. Read type, then the matching field:
type
string
"numeric", "bounded", "qualitative", "text", or "absent"
numeric
number?
Present when type is "numeric"
bounded
object?
Present when type is "bounded": { "operator": "lt"|"gt", "value": number }
qualitative
object?
Present when type is "qualitative": { "text": string }
text
string?
Present when type is "text"
absent_reason
string?
Present when type is "absent" (why the value is missing; may be null)
units
string?
Units of the numeric/bounded magnitude
ucum_code
string?
UCUM-compliant unit code
interpretation: the coded "is this abnormal" signal:
flag
string | null
Coded abnormality (see Interpretation Flag enum); null when there is no signal
flag_raw
string?
The lab's verbatim flag text the code was derived from
source
string
Where the flag came from: "report" (normalized from the printed flag) or "none"
applied_range
object?
The reference range the flag was judged against: { "lower": number?, "upper": number? }, populated when exactly one range applies to the patient
reference_ranges
object[]
Array of reference range objects
Reference range object
lower
number?
Lower limit (omitted for one-sided ranges like "< 4.0")
upper
number?
Upper limit (omitted for one-sided ranges like "> 1.0")
type
string?
Coded range type. See enum values below. A lossy coding of label, judged from the report's wording and where the band sits among the result's ranges: a prediabetes band between the no-diabetes and diabetes bands is borderline_high. Omitted when nothing in the enum fits.
label
string?
The classification exactly as the report printed it, such as "Optimal", "Moderate", "Consistent with increased risk for diabetes (prediabetes)".
context
object?
Demographic context for when this range applies
Context object
sex
string
"male", "female", or omitted (applies to all)
age_lower
integer?
Minimum age in years this range applies to
age_upper
integer?
Maximum age in years (omitted = no upper limit)
pregnancy_status
object?
Pregnancy status: "trimester_1", "trimester_2", or "trimester_3" (or omitted)
cycle_phase
object?
Menstrual cycle phase (or omitted)
gestational_week_lower
integer?
Lower gestational week bound (omitted if not applicable)
gestational_week_upper
integer?
Upper gestational week bound (omitted if not applicable)
reference_population
object?
Reference population (e.g. "nhanes_iii", "young_adult"; omitted if not set)
modifiers
string[]
Additional qualifiers (e.g. ["fasting", "supine"])
Enum reference
Status
processing
Extracting biomarker data from the file
processed
Extraction complete
standardizing
Matching biomarkers and normalizing units
standardized
Standardization complete, results queryable
sending
Delivering payload to webhook
retry_scheduled
Waiting to retry after a temporary problem upstream
sent
Delivered to all configured destinations
partially_sent
Delivered to at least one destination, but failed others
delivery_failed
Processed, but delivery to every destination failed
failed
The report could not be processed. See error.
cancelled
Processing was cancelled
deleted
Session has been deleted
Reference range type
Values for reference_ranges[].type: a coded description of the range, not a verdict on the result. It is derived from label and is omitted whenever the report's wording has no counterpart here (most banded footnotes: risk categories, diabetes screening bands, vitamin-D sufficiency tiers). label is always the report's own words.
normal
Within normal range
low
Below normal
high
Above normal
borderline_low
Borderline low
borderline_high
Borderline high
critical_low
Critically low
critical_high
Critically high
abnormal
Abnormal
therapeutic
Within therapeutic range
subtherapeutic
Below therapeutic range
toxic
Toxic level
Interpretation flag
Values for interpretation.flag: the coded per-result abnormality signal (null when there is no signal).
normal
Not flagged
low
Below range
high
Above range
borderline_low
Borderline low
borderline_high
Borderline high
critical_low
Critically low
critical_high
Critically high
abnormal
Flagged, direction unspecified
Specimen type
blood
Blood
serum
Serum
plasma
Plasma
urine
Urine
saliva
Saliva
stool
Stool
other
Other
Result type
numeric
Numeric measurement
qualitative
Categorical outcome
text
Free-text observation
Biological sex
male
Male
female
Female
Report type
lab
Clinical laboratory report: blood, serum, urine or another specimen. Results scoped by specimen.
dexa
DXA/DEXA body-composition or bone-density scan. Results scoped by region.
You may also see unspecified on a session fetched over REST while it is still being classified. A delivered webhook always carries lab or dexa.
Last updated
Was this helpful?