Metriport sends webhook messages to your app as data becomes available in our system. This allows you to react to events in real-time rather than polling for updates.For information on how to set up webhooks, see Implementing Webhooks.
When you receive a webhook message, you should respond with a 200 status code within 4 seconds.
We recommend processing the webhook request asynchronously.
Network Query events are emitted when you start a Network Query to retrieve patient data from health networks. You receive one webhook per source as each completes.Recommended flow:
HIE data (documents from Health Information Exchanges) is ready
network-query.pharmacy
Pharmacy data (medication prescription and pickup history) is ready
network-query.lab
Laboratory data (lab results) is ready
Each webhook includes a consolidatedDataUrl - a presigned S3 URL to download the patient’s
aggregated record, i.e. their ‘consolidated data’. This allows you to reingest the record as soon as any data source is ready.
Medical Data events are emitted for consolidated data queries, bulk operations, and document downloads. Unlike Network Query events which are triggered automatically after data retrieval, these events are triggered by explicit API calls.
You’ll receive this webhook after invoking a Consolidated Query via POST Start Consolidated Data Query.
The payload contains the patient’s consolidated medical record as deduplicated, standardized FHIR data. This includes all converted documents from network queries plus any FHIR data your application has inserted directly.Note that inside the Bundle you’ll find a DocumentReference resource with attachments in the content array:
The first item contains an attachment with a url which can be used to download the data.
If requested conversionType is json, an additional attachment with contentType: "application/gzip" provides a gzip-compressed copy for faster downloads.
Download URLs are valid for 3 minutes
If there was no data available for the Patient, the Bundle will be empty (the entry array will have no elements).
You’ll receive this webhook after invoking a bulk patient creation via POST Bulk Create Patient.
The payload reports the status of the bulk creation job, allowing you to process large CSV files of patient demographics asynchronously.Note that you’ll receive multiple webhooks for a single bulk create request:
First, a webhook with status: "processing" confirming the job started
Then, a webhook with status: "completed" containing a presigned URL to download the results CSV with created patient IDs
Or, a webhook with status: "failed" containing a reason explaining what went wrong
You’ll receive this webhook after invoking a bulk document download via POST Bulk Get Document URL.
The payload provides presigned download URLs for all documents belonging to the specified patients, allowing you to efficiently download multiple documents in bulk.Note that the payload contains a patients array with results for each patient:
Each patient entry includes a status (completed or failed) and a documents array
Each document includes metadata (id, fileName, mimeType, etc.) and a presigned url
Patient Notification events provide real-time ADT (Admission, Discharge, Transfer) updates as patients move through healthcare facilities. These are part of Real-time Patient Notifications.
You can pass metadata when calling endpoints that support webhooks. This metadata will be returned in the meta.data field of the webhook. You may use this to attach whatever metadata is relevant for your use-case - for example, external IDs.
Below is an example payload you could send in the request body of one of those endpoints and how you would use the sdk:Note that the metadata param supports up to 50 custom string key-value pairs, with keys up to 40 chars, and values of up to 500 chars.