Skip to content

Webhooks

PacsPilot sends an HTTPS POST to your endpoint when something happens in the practice: a site goes offline, an upload fails, a report is signed. Owners and administrators add endpoints and choose event types on Admin, Webhooks; each endpoint gets its own whsec_ signing secret, shown once.

Payloads carry IDs, codes, counts and times only, never patient data. Fetch details with the API, or open links.app signed in.

The envelope

Field Type Description
id string Event ID. Repeats on retries and replays, so use it to drop duplicates; also sent as webhook-id
type "site.offline" Event type
version 1 Catalog version; a new version is announced in the changelog
tenantId string The practice the event is about
occurredAt integer When it happened, in Unix milliseconds
severity "critical" Severity; fixed per type
data object IDs, codes, counts and times only; never patient data
links object
{
  "id": "evt_01JA2Z6Q7Y9K3M5N8P0R2S4TWX",
  "type": "site.offline",
  "version": 1,
  "tenantId": "01JA2Z6Q7Y9K3M5N8P0R2S4TTV",
  "occurredAt": 1792161000000,
  "severity": "critical",
  "data": {
    "siteTokenId": "01JA2Z6Q7Y9K3M5N8P0R2S4T1A",
    "siteName": "Main campus",
    "kind": "agent",
    "lastSeenAt": 1792160100000
  },
  "links": {
    "app": "https://app.pacspilot.com/admin/sites"
  }
}

Headers

Deliveries follow the Standard Webhooks specification (standardwebhooks.com), so its libraries verify them as they are.

Header Description
webhook-id The event ID, the same as id in the body. Drop a delivery whose ID you already processed
webhook-timestamp When this attempt was signed, in Unix seconds. Reject one more than five minutes from your clock
webhook-signature Space-separated v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}"> signatures; two while a secret rotates. Accept when any one matches

Verify the signature

Verify before trusting the body, on the raw bytes as received. Reject a delivery whose timestamp is more than five minutes from your clock, and drop one whose webhook-id you already processed: retries and replays repeat it. While a secret rotates, both the old and the new secret sign each delivery for 24 hours.

Node, Standard Webhooks library

// npm install standardwebhooks express
import express from "express";
import { Webhook } from "standardwebhooks";

const wh = new Webhook(process.env.PACSPILOT_WEBHOOK_SECRET); // whsec_…
const app = express();

// Verify the raw body: parsing and re-serialising JSON changes the bytes that were signed.
app.post("/pacspilot", express.raw({ type: "application/json" }), (req, res) => {
  let event;
  try {
    event = wh.verify(req.body.toString("utf8"), req.headers);
  } catch {
    return res.status(400).end();
  }
  res.status(204).end(); // answer first, work afterwards
  handle(event); // drop it if event.id was already processed
});

Python, Standard Webhooks library

# pip install standardwebhooks flask
import os
from flask import Flask, request
from standardwebhooks.webhooks import Webhook

wh = Webhook(os.environ["PACSPILOT_WEBHOOK_SECRET"])  # whsec_...
app = Flask(__name__)

@app.post("/pacspilot")
def pacspilot():
    try:
        event = wh.verify(request.get_data(), dict(request.headers))
    except Exception:
        return "", 400
    handle(event)  # drop it if event["id"] was already processed
    return "", 204

Node, without a library

import { createHmac, timingSafeEqual } from "node:crypto";

/** True when one of the signatures matches and the timestamp is within five minutes. */
export function verifyPacsPilot(secret, headers, rawBody, nowSeconds = Date.now() / 1000) {
  const id = headers["webhook-id"];
  const timestamp = headers["webhook-timestamp"];
  const signatures = headers["webhook-signature"] ?? "";
  if (!id || !timestamp || Math.abs(nowSeconds - Number(timestamp)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const expected = createHmac("sha256", key).update(`${id}.${timestamp}.${rawBody}`).digest();
  return signatures.split(" ").some((s) => {
    const [version, sig] = s.split(",");
    const got = Buffer.from(sig ?? "", "base64");
    return version === "v1" && got.length === expected.length && timingSafeEqual(got, expected);
  });
}

Delivery and retries

  • Answer with any 2xx within 10 seconds, then do the work. Redirects are not followed.
  • A failed delivery is tried nine times in all over about a day. After 3 days of failures the endpoint is turned off and owners and administrators get a webhook.failing notice; turn it back on once the receiver is fixed.
  • Events can arrive out of order; order them by occurredAt.
  • Admin, Webhooks shows each delivery, and can replay one from the last 30 days with its original ID.

Test events

In your sandbox practice (Admin, Developer), Send test event sends the example payload of any type below to the sandbox's endpoints subscribed to it, signed like a real delivery. On Admin, Webhooks, Send test sends a ping event to one endpoint in any practice.

Event types

Type When Severity
site.offline A site is offline critical
site.recovered A site is back online info
site.disk_high A site's disk is almost full warning
site.cert_expiring A site agent certificate expires soon warning
ingest.failed An upload failed critical
ingest.stalled An upload stopped making progress warning
ingest.resumed A stalled upload is progressing again info
study.export_failed A study could not be prepared for viewing warning
hl7.held HL7 messages are waiting for mapping confirmation warning
hl7.confirmed An HL7 mapping was confirmed info
hl7.drift An HL7 sender changed its message layout warning
order.unmatched An order has no study yet info
quota.near The trial is close to its limit warning
quota.reached The trial limit is reached critical
billing.trial_ending The trial ends soon warning
billing.payment_failed A payment failed critical
billing.suspended The practice is read-only critical
billing.reinstated The subscription is active again info
study.stat_arrived A STAT study is ready to view critical
report.signed A report was signed info
finding.flagged A critical result was flagged warning
finding.escalated A critical result needs attention warning
finding.acknowledged A critical result was acknowledged info
share.opened A share link was opened info
webhook.failing A webhook endpoint was turned off warning
auth.failed_burst Repeated failed sign-ins warning
api.rate_limited Many requests were rate limited warning
store.busy The practice database was busy warning
upload.unsafe Uploads were refused as unsafe warning
retention.batch_requested A purge batch needs a second approval warning
ehr.delivery_failed A result could not be sent to the EHR warning
fax.delivery_failed A fax could not be delivered warning
fax.cap Fax pages are near or at the monthly limit warning
access.break_glass A member used emergency access warning
portal.account_locked A patient portal account was locked warning
patient.mrn_converted PacsPilot converted your patients' MRNs warning
ai.study_flagged An AI app flagged a study warning
ai.app_failing An AI app keeps failing warning
exchange.pull_failed An image exchange pull failed warning
ris.appointment_cancelled_by_order An appointment was cancelled by its order warning
ris.patient_arrived A patient was checked in info
ris.reminder_failed An appointment reminder could not be sent warning
ris.cancel_requested A patient asked to cancel or reschedule info
ris.form_flagged An intake form answer needs review warning
protocol.overdue An order is waiting for a protocol warning
protocol.changed A protocol changed after the patient arrived warning
portal.hold_review_due A report held from the patient portal is due for review warning
followup.due A recommended follow-up exam is due warning
followup.overdue A recommended follow-up exam is overdue warning
followup.closed A follow-up was closed info
breast.notice_overdue An MQSA letter or report is overdue critical
payments.gfe_overdue A Good Faith Estimate is overdue critical
payments.dispute_opened A patient disputed a card payment warning
payments.plan_failed A payment plan paused warning
case.callback.changed A call back changed info
sla.at_risk A study is close to its turnaround target warning
sla.breached A study missed its turnaround target critical
sla.resolved A late study was signed info
dose.exceeded A dose reference level was exceeded warning
dose.rdsr_missing A scanner stopped sending dose reports warning
charge.rejected The billing system rejected a charge warning
standby.primary_down The main PACS is not answering critical
standby.primary_up The main PACS is answering again info
charge.missed Exams are waiting to be charged info
vas.credential_expiring Staff credentials expire soon warning
credential.expiring A reader credential expires soon warning
credential.expired A reader credential expired warning
assignment.override A credential check was overridden info
assignment.stopper A study is waiting for a reader warning
tumor_board.recommendation A tumor board made a recommendation info
wound.consult_requested A telewound consult is waiting info
screening.urgent_referral An eye screen needs an urgent referral warning
wound.consult_answered A telewound consult was answered info
code.activated A code was activated critical
code.ai_flagged AI triage flagged a code's study critical
code.first_images First images for a code are ready critical
vascular.criteria_published A vascular criteria table was published info
schedule.published Your reading schedule was published info
schedule.time_off_requested Time off was requested info
schedule.time_off_decided Your time off request was answered info
schedule.swap_requested A shift swap needs an answer info
schedule.swap_decided A shift swap was answered info
schedule.gap A published shift is not covered warning
or.count_film_result An OR film was read warning
trial.visits_due Trial visits are due warning
rad_path.discordant Imaging and pathology disagree warning
gi.pathology_matched Pathology is back info
ent.navigation_sent Series sent to navigation info
pft.session_received A PFT session arrived info
marketing_authorization.revoked A marketing authorization was revoked warning
screening.overdue A lung screening patient is overdue warning
implant.recall_due Implant screening reminders are due info
pregnancy.edd_changed A pregnancy's due date was set or changed info
contrast.reaction Contrast reaction recorded warning
contrast.extravasation Contrast extravasation recorded warning
ed.overread_difference A final differs from the ED's read warning
study.overread_requested A study was sent for over-read info
access.token_expiring API tokens expire soon warning
access.review_open An access review needs decisions warning
sso.domain_unverified Single sign-on domain no longer verified warning
api.sunset_notice An API operation your practice uses is being retired warning
qc.task.overdue Equipment QC is overdue info
qc.accreditation.expiring An equipment certificate or accreditation expires soon warning
qc.task.failed An equipment QC test failed warning
qc.unit.out_of_service A unit is out of service warning
qc.unit.status_changed A unit's QC status changed info
pocus.qa_reviewed A POCUS exam was reviewed info