Platform
Webhooks
Signed notifications for account events and clinical data changes
Set up the SDK client as esus to manage webhooks. Use the app UUID as appId.
Webhooks let your backend react to changes without polling. Each webhook belongs to one of your organization’s apps, points to an HTTPS URL, and subscribes to a closed list of events. Deliveries are signed and retried.
Access: managing webhooks requires the admin role (or an API key with TenantApp permissions).
Events
Account events (users of that app): user.created, user.email_verified, user.password_changed, user.password_reset, user.email_changed, user.deleted, user.mfa_enabled, user.mfa_disabled, user.webauthn_registered, user.webauthn_removed, user.locked, user.refresh_reuse, user.role_assigned, user.role_removed, user.deactivated, user.reactivated, user.patient_linked, user.patient_unlinked, and consent.revoked.
Clinical data changes (<resource>.created, <resource>.updated, <resource>.deleted) for these resources:
| Resource | Event prefix |
|---|---|
| Patient | patient |
| Encounter | encounter |
| Observation | observation |
| Condition | condition |
| AllergyIntolerance | allergy_intolerance |
| Procedure | procedure |
| Immunization | immunization |
| MedicationRequest | medication_request |
| DiagnosticReport | diagnostic_report |
| ServiceRequest | service_request |
| DocumentReference | document_reference |
| Appointment | appointment |
- They fire after a successful write on
/fhir/<Type>, from anyone in the organization (console, API key, or app user), including writes inside a batch Bundle. A failed write sends nothing. POST /fhir/<Type>and$booksendcreated;PUT,PATCH, and instance operations such as$cancelsendupdated;DELETEsendsdeleted.- They go to every app of the organization whose webhook subscribes to that event. There is no filtering by patient or by search criteria.
- The FHIR
Subscriptionresource is not available; these webhooks replace it.
Payload
{
"id": "evt_9f1c2d...",
"type": "observation.created",
"createdAt": "2026-11-13T10:30:00.000Z",
"appId": "aa11bb22-cc33-dd44-ee55-ff6677889900",
"data": { "resourceType": "Observation", "id": "b1c2d3e4-...", "versionId": "1" }
}
Clinical events carry only identifiers, never clinical content. To get the data, fetch the resource with your own credentials (GET /fhir/Observation/b1c2d3e4-...): permissions and patient consent still apply. deleted events have no versionId.
Create a Webhook
curl -X POST https://api.esus.health/tenant-apps/APP_ID/webhooks \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.example.com/webhooks/esus",
"events": ["observation.created", "appointment.updated"],
"description": "Lab results and agenda"
}'
const result = await esus.webhooks(appId).create({
"url": "https://your-app.example.com/webhooks/esus",
"events": [
"observation.created",
"appointment.updated"
],
"description": "Lab results and agenda"
});
The response includes the signing secret. It is shown only once; you can rotate it later with PATCH /tenant-apps/APP_ID/webhooks/WEBHOOK_ID and { "rotateSecret": true }. You can also do all of this from the console, under the app’s Webhooks tab.
Other routes on /tenant-apps/APP_ID/webhooks: GET / (list), GET /:webhookId, PATCH /:webhookId (url, events, description, active), DELETE /:webhookId, POST /:webhookId/ping (sends a test event), and GET /:webhookId/deliveries (recent delivery attempts).
Verify the Signature
Each delivery is a POST with these headers:
| Header | Content |
|---|---|
X-Esus-Timestamp | Unix time in milliseconds |
X-Esus-Delivery-Id | Unique per delivery, stable across retries: use it as the idempotency key |
X-Esus-Signature | sha256=<hex> |
X-Esus-Event / X-Esus-Event-Id | Event type and event id (the id is shared by all subscribers of the same event) |
The signature is an HMAC-SHA256 with your secret over ${timestamp}.${deliveryId}.${rawBody}:
import { createHmac, timingSafeEqual } from 'node:crypto'
function verify(secret, headers, rawBody) {
const ts = headers['x-esus-timestamp']
const timestamp = Number(ts)
if (!ts || !Number.isSafeInteger(timestamp) || Math.abs(Date.now() - timestamp) > 5 * 60 * 1000) return false
const mac = createHmac('sha256', secret)
.update(`${ts}.${headers['x-esus-delivery-id']}.${rawBody}`)
.digest('hex')
const expected = Buffer.from(`sha256=${mac}`)
const received = Buffer.from(headers['x-esus-signature'] ?? '')
return expected.length === received.length && timingSafeEqual(expected, received)
}
import { verifyWebhook } from "@esushealth/sdk/server";
const rawBody = new Uint8Array(await request.arrayBuffer());
const delivery = await verifyWebhook(request.headers, rawBody, {
appId,
secret: webhookSecret,
});
Verify the raw bytes before parsing the event. In the SDK, verifyWebhook returns null when verification fails.
Delivery and Retries
- Answer with any
2xxwithin 10 seconds. Redirects are not followed. - Esus makes up to 6 attempts in total, including the first. Retries use exponential backoff starting at 1 minute. Once attempts are exhausted, delivery is marked
dead. - The same delivery can arrive more than once: deduplicate by
X-Esus-Delivery-Id. - The URL must be public HTTPS. Private or loopback addresses are rejected.