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.When there are many documents, the payload is automatically split into multiple webhook pages to keep each under 200KB.
Each page shares the same requestId but has a unique messageId. Use the pagination field to determine the
current page number and total pages.
Download URLs are valid for 10 minutes
Pages are sent sequentially with a 50ms delay between them
If you’re receiving the legacy
medical.document-bulk-download-urls webhook, please
contact us to migrate to
medical.document-bulk-download-paged.
An array containing the patient data with document references. When there are many documents,
they are split into multiple webhook payloads (pages) to keep each payload under 200KB.
An array of objects describing the Documents that can be retrieved for the Patient along with the
downloadable URLs to retrieve them. Each document has two URL properties:
url: The presigned URL for direct download (expires in ~10 minutes)
downloadUrl: The Metriport API endpoint to retrieve a fresh presigned URL if the original has expired
The total number of documents across all webhook pages for this bulk download request.
When documents are split across multiple webhook pages,
all pages share the same requestId but each has a unique
messageId in the meta field. Use the pagination
field to determine the current page number and the total
number of pages (totalPages).
Webhooks are sent sequentially with a 50ms delay between
pages to avoid overwhelming your webhook endpoint.
Message events cover both directions of secure messaging - outbound delivery status for messages you send, and inbound notifications when another practitioner sends a message to you.
You’ll receive this webhook after invoking POST Send Message.
The payload reports the final delivery status of the message — either when the recipient acknowledges receipt, or when delivery fails.You will receive one webhook per send request, with a status of completed or failed based on the outcome of the operation.Recommended flow:
You’ll receive this webhook when another practitioner sends a secure message to your organization.
The payload includes the message metadata and a presigned URL to download the full message content and attachments.Recommended flow:
Receive this webhook
Download the message from the url in the payload
Process the message and associated patient data in your application
Patient Notification events provide real-time ADT (Admission, Discharge, Transfer), Pharmacy, and/or Laboratory updates.
These are part of Real-time Patient Notifications.
IAS-specific events are delivered to the same webhook URL you configure for the Medical API. For the
full Individual Access flow, see Individual Access (IAS).
Sent when the user successfully completes the hosted identity session started with
Create Identity Session. Store the
proofedIdentityId from this payload and pass it on
Start Network Query requests where the
purposeOfUse query parameter is ias.Example payload:
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.