Skip to main content

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
}
}
  • upsertWebhook creates the webhook for an action, or replaces its URL. The URL must use https.
  • webhook returns the webhook registered for an action.
  • deleteWebhook removes it. Deleting an action with no webhook returns WEBHOOK_NOT_FOUND.

Payload​

Every webhook is an HTTP POST with a JSON body containing at least:

FieldDescription
jobIdThe job that changed.
actionjob-available, job-published, job-updated or job-unclaimed.
sourcenatera 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:

ValueMeaning
statusThe job moved to a new status.
startTimeThe scheduled time changed.
assigneeThe assigned technician changed.
patientPatient details changed.
attachmentsAn attachment was added or removed.
notesA note was added.
jobTypesThe job's test types changed.
addressesThe service address changed.
timeslotsThe 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 jobConnection so 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.