Webhooks
MPX can POST a JSON notification to your server when a job you care about changes. You register one URL per WebhookAction.
Managing webhooks
mutation {
upsertWebhook(webhook: { action: JOB_UPDATED, url: "https://example.com/mpx/webhooks" }) {
id
action
url
}
}
upsertWebhookcreates the webhook for an action, or replaces its URL. The URL must usehttps.webhookreturns the webhook registered for an action.deleteWebhookremoves it. Deleting an action with no webhook returnsWEBHOOK_NOT_FOUND.
Payload
Every webhook is an HTTP POST with a JSON body containing at least:
| Field | Description |
|---|---|
jobId | The job that changed. |
action | job-available, job-published, job-updated or job-unclaimed. |
source | natera if the change was made by Natera (for example, in the MPX dashboard), or vendor if it was made through a vendor integration. |
Payloads contain identifiers only, not job data. Call the job query to get the job's current state.
Actions
JOB_AVAILABLE
Sent when a job becomes AVAILABLE and your vendor is in its network, meaning you have a technician within 100 miles of the job.
{
"jobId": "s@mp!3ID",
"source": "natera",
"action": "job-available"
}
source is always natera.
JOB_PUBLISHED
Added in 1.4.0. Sent when a job is published (assigned directly) to your vendor.
{
"jobId": "s@mp!3ID",
"source": "natera",
"action": "job-published"
}
source: natera or vendor.
JOB_UPDATED
Sent when a job that belongs to your vendor is updated. This includes updates you made yourself through the API.
{
"jobId": "s@mp!3ID",
"changed": ["notes"],
"source": "vendor",
"action": "job-updated"
}
changed lists what was updated:
| Value | Meaning |
|---|---|
status | The job moved to a new status. |
startTime | The scheduled time changed. |
assignee | The assigned technician changed. |
patient | Patient details changed. |
attachments | An attachment was added or removed. |
notes | A note was added. |
jobTypes | The job's test types changed. |
addresses | The service address changed. |
timeslots | The patient's availability changed. |
source: natera or vendor.
JOB_UNCLAIMED
Added in 1.4.0. Sent to your vendor when you're removed from a job or you unclaim it.
{
"jobId": "s@mp!3ID",
"source": "natera",
"action": "job-unclaimed"
}
source: natera or vendor.
Receiving webhooks
- Respond with a 2xx status quickly. Any other status counts as a failed delivery.
- Don't rely on delivery. MPX doesn't retry failed deliveries. Reconcile periodically with
jobConnectionso a missed webhook doesn't leave you out of date. - Treat payloads as hints. Webhook requests aren't signed. Re-fetch the job with your access token, and don't act on the payload contents alone.
- Be idempotent. You may receive more than one notification for related changes.