Skip to content

Webhooks

A webhook tells your system that something changed, so it does not have to poll. Deliveries are signed, carry identifiers and states only, and are retried when your endpoint does not answer.

Create an endpoint#

In your workspace, open API and add a webhook endpoint. This needs the Owner, Administrator or Developer role.

  • The address must be a public https host name. An IP address, localhost, a .local or .internal name, or an address with credentials in it is refused.
  • Choose at least one event type.
  • A workspace can have up to 10 endpoints.

The signing secret, starting with whsec_, is shown once when the endpoint is created. The platform stores it sealed and cannot show it again: to change it, remove the endpoint and add it again.

Events#

TypeSent whenSubjectData
requisition.receivedA new requisition arrived from a connection.requisitionsource, priority
requisition.updatedA requisition changed in the source system, or was closed there.requisitionstatus, and reason when it was closed at the source
suggestion.createdA suggestion was prepared for a requisition.requisitionengine, confidence
decision.recordedA radiologist approved, modified, rejected or asked for more information.requisitionaction, submitted
submission.confirmedThe approved protocol was written to the source system and read back as saved.requisitionnone
submission.failedThe write failed or could not be confirmed. The requisition needs attention.requisitionerrorKind
connection.status_changedA connection was activated, paused, or moved to error after repeated failures.connectionstatus
job.failedA queued job ended in failure and will not be retried.jobkind, errorKind

The same events are available, newest first, from GET /v1/events with the events:read scope. Use it to catch up after downtime.

Payload#

POST to your endpoint
{
  "id": "p27z9x7c5v3b1n8m6q4w2e0r9t",
  "type": "submission.confirmed",
  "created": 1795787404,
  "organization": "example",
  "subject": { "type": "requisition", "id": "k57c2q9x4m1v8b3n6z0d5f7h2j" },
  "data": {}
}
FieldMeaning
idThe event's id. The same on every retry, so use it to ignore a delivery you have already handled.
typeOne of the types above. Also sent as the Epic-Direct-Event header.
createdWhen the event happened, in Unix seconds.
organizationThe workspace's short name, as in its address.
subjectWhat the event is about: a type and an id.
dataA few states or flags. Never patient data.

Verify the signature#

Every delivery carries a signature header. Check it before you trust the body.

Header
Epic-Direct-Signature: t=1795787404,v1=5f2b…c9e1
  1. Take t and v1 from the header.
  2. Compute HMAC-SHA256 over t, a full stop, and the raw request body, using the whole signing secret (including whsec_) as the key. Encode the result as lower-case hex.
  3. Compare it with v1 using a constant-time comparison.
  4. Reject a delivery whose t is too old. The platform does not set this window for you; five minutes is a reasonable choice.
Node
import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody must be the exact bytes received, before any JSON parsing.
export function verify(rawBody, signatureHeader, secret, toleranceSeconds = 300) {
  const parts = Object.fromEntries(signatureHeader.split(",").map((p) => p.split("=")));
  const t = parts.t ?? "";
  if (!/^\d+$/.test(t) || Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false;

  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const given = String(parts.v1 ?? "");
  return given.length === expected.length && timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}
Python
import hashlib, hmac, time

# raw_body must be the exact bytes received, before any JSON parsing.
def verify(raw_body: bytes, signature_header: str, secret: str, tolerance: int = 300) -> bool:
    parts = dict(p.split("=", 1) for p in signature_header.split(",") if "=" in p)
    t = parts.get("t", "")
    if not t.isdigit() or abs(time.time() - int(t)) > tolerance:
        return False
    expected = hmac.new(secret.encode(), t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))

Verify against the bytes you received. Parsing the JSON and serialising it again changes the bytes and the check will fail.

Delivery and retries#

RequestPOST, Content-Type: application/json, User-Agent: Epic.direct-Webhooks/1
SuccessAny 2xx status.
Timeout10 seconds. Answer first, then do the work.
RedirectsNot followed. A redirect counts as a failure.
AttemptsUp to 5 for each delivery.
Wait between attempts30 seconds, 2 minutes, 8 minutes, 32 minutes.
  • After the fifth failed attempt the delivery is marked failed and is not sent again.
  • When 20 attempts in a row have failed across an endpoint’s deliveries, the endpoint is paused and the pause is written to the audit trail. Nothing is sent to a paused endpoint. Resume it on the API page once it is fixed; a successful delivery resets the count.
  • Deliveries are not guaranteed to arrive in the order the events happened. Use the API as the source of truth for current state.
  • The API page shows the most recent deliveries for each endpoint with their status and response code.