Events and webhooks
Subscribe to network events (OHN-24), receive them as signed webhooks or pull them, and verify every delivery.
When something happens that another system should know about (a result is available, a referral is accepted, a claim is decided), the service that owns it publishes an event. OHN-24 (event and subscription infrastructure) delivers it to subscribers by webhook (push) or lets them pull it.
The envelope
Every event has the same envelope; the payload differs by event type.
| Field | Meaning |
|---|---|
event_id | Unique id. Use it to deduplicate. |
event_type | Dotted name, e.g. diagnostic-result.available (pattern ^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$). |
schema_version | Version of the payload schema (see Versioning). |
occurred_at | When it happened (ISO 8601, UTC). |
jurisdiction_id, organization_id | Where it happened. |
aggregate_id, aggregate_version | The record that changed and its version. |
correlation_id, causation_id | Trace a chain of events back to the request that started it. |
data_classification | Sensitivity class; it controls which subscribers may receive the event. |
payload | Identifiers, codes and states, as each event schema defines. Payloads are kept minimal (for example, OHN-11 result events carry no result values): fetch the record through the API, where access is checked. |
Subscribing
Subscriptions are managed through OHN-24 (/api/ohn/v1/subscriptions, /api/ohn/v1/endpoints, /api/ohn/v1/event-schemas; see the OHN-24 contract). Rules that always apply:
- A subscription only receives events of its own organisation.
- Fan-out is deny by default by data classification; the ceiling for subscriptions is
internal. - Redirects are never followed when a webhook is delivered.
Delivery
- At least once. The same event can arrive more than once: deduplicate on
event_id. - Ordering is guaranteed only per
aggregate_id. - Retries. A timeout, a network error,
408,425,429or any5xxis retried with exponential backoff (default: base 30 s, cap 1 hour, at most 8 attempts within 72 hours). Any other4xxor a3xxis final. - After the last attempt the delivery goes to the dead-letter queue and a
delivery.failedevent is published. Operators can replay events (/api/ohn/v1/events/{id}/replay). - Pull mode: instead of a webhook, take events with
/api/ohn/v1/subscriptions/{id}/pull(leased) and acknowledge each with/api/ohn/v1/deliveries/{id}/acknowledge.
Answer a webhook with any 2xx as soon as you have stored the event; do the work afterwards.
Verifying a webhook
Each delivery is a POST with content-type: application/json and these headers:
| Header | Value |
|---|---|
x-ohn-event-id | The event’s event_id. Check it matches the body. |
x-ohn-signature | sha256=<hex HMAC-SHA256 of the raw body> |
x-ohn-signature-note | hmac, or local-unsigned on a local development deployment. Refuse local-unsigned in any real environment. |
Verify the signature on the raw bytes, before parsing JSON, with a constant-time comparison. During a secret rotation, accept any of the current secrets. At present a deployment signs every delivery with one webhook secret that the network operator gives you; keep it in your secret manager.
// Node.js 18+
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyOhnWebhook(rawBody, headers, secrets) {
if (headers['x-ohn-signature-note'] !== 'hmac') return false;
const got = Buffer.from(String(headers['x-ohn-signature'] ?? ''));
const ok = secrets.some((s) => {
const want = Buffer.from('sha256=' + createHmac('sha256', s).update(rawBody).digest('hex'));
return want.length === got.length && timingSafeEqual(want, got);
});
if (!ok) return false;
return JSON.parse(rawBody.toString('utf8')).event_id === headers['x-ohn-event-id'];
}
// Java 17+
static boolean verify(byte[] rawBody, String signature, List<String> secrets) throws Exception {
for (String s : secrets) {
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(s.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
String want = "sha256=" + HexFormat.of().formatHex(mac.doFinal(rawBody));
if (MessageDigest.isEqual(want.getBytes(StandardCharsets.US_ASCII), signature.getBytes(StandardCharsets.US_ASCII))) return true;
}
return false;
}
The SDKs include this check (verifyWebhook, verify_webhook, Webhooks.verify) and a SeenEvents helper for deduplication.
Event catalogue
192 event types published by 49 services, read from the event schemas in the repository (modules/OHN-XX/events/).
| Service | Event types | Schemas |
|---|---|---|
| OHN-04 | identifier.mapping.changed, patient.merged, patient.unmerged | 1 |
| OHN-05 | facility.branding.changed, facility.logo.approved, facility.logo.rejected, facility.logo.uploaded, facility.logo.withdrawn, facility.registered, facility.suspended, facility.verified | 1 |
| OHN-06 | affiliation.changed, practitioner.license.expired, practitioner.suspended, practitioner.suspension.lifted, practitioner.verified | 1 |
| OHN-08 | clinical-summary.updated, health-chart.projection.refreshed | 1 |
| OHN-09 | encounter.corrected, encounter.timeline.updated | 1 |
| OHN-10 | clinical-summary.observations-recorded, clinical-summary.published, reconciliation.requested | 1 |
| OHN-11 | critical-result.acknowledged, critical-result.detected, critical-result.escalated, diagnostic-result.amended, diagnostic-result.available | 1 |
| OHN-12 | birth.event.linked, child-health.age-transition.completed, immunization.record.updated | 1 |
| OHN-13 | document.registered, document.revoked, document.versioned | 3 |
| OHN-14 | emergency-summary.accessed, ips.generated | 1 |
| OHN-15 | consent.expired, consent.granted, consent.revoked | 1 |
| OHN-16 | access.denied, access.policy-version.changed, document_mark.issued, policy.published | 4 |
| OHN-17 | emergency-access.ended, emergency-access.reviewed, emergency-access.started | 1 |
| OHN-18 | audit.export.generated, audit.integrity.failure | 2 |
| OHN-19 | delegation.revoked, dependent.age-transition, representation.verified | 1 |
| OHN-20 | privacy.assessment.approved, privacy.policy.changed, transfer.authorized | 3 |
| OHN-21 | fhir.transaction.accepted, fhir.transaction.rejected | 2 |
| OHN-22 | legacy.message.accepted, legacy.message.quarantined | 1 |
| OHN-23 | terminology.mapping.disputed, terminology.version.published | 1 |
| OHN-25 | connector.connected, connector.degraded, connector.upgraded | 1 |
| OHN-26 | edge.conflict.detected, edge.lease.expired, edge.sync.completed | 3 |
| OHN-27 | referral.accepted, referral.completed, referral.declined, referral.sent | 1 |
| OHN-28 | clinical-notification.acknowledged, clinical-notification.escalated, clinical-notification.needs-supervisor, clinical-notification.sent | 1 |
| OHN-29 | aggregate.approved, aggregate.rejected, aggregate.submitted | 1 |
| OHN-30 | coverage.eligibility.received, coverage.eligibility.requested | 1 |
| OHN-31 | patient.portal-accessed, patient.request.submitted | 1 |
| OHN-32 | clinician.emergency-requested, clinician.patient-accessed | 1 |
| OHN-33 | developer.application.approved, developer.credential.rotated | 1 |
| OHN-34 | quality.issue.detected, stewardship.case.resolved | 2 |
| OHN-35 | ops.incident.closed, ops.incident.opened, ops.slo.breached | 1 |
| OHN-36 | federation.request.denied, federation.transfer.approved | 2 |
| OHN-37 | assurance.changed, proofing.completed, proofing.failed | 3 |
| OHN-38 | auth.risk.detected, auth.session.revoked, client.credential.rotated | 3 |
| OHN-39 | trust.enrollment.approved, trust.status.revoked | 2 |
| OHN-40 | record-location.expired, record-location.registered | 2 |
| OHN-41 | fhir.profile.published, fhir.resource.versioned | 2 |
| OHN-42 | resource.classified, resource.reclassified | 1 |
| OHN-43 | record.correction.proposed, rights.request.closed, rights.requested | 3 |
| OHN-44 | clinical.hazard.detected, clinical.release.approved, clinical.release.blocked | 1 |
| OHN-45 | crypto.key.revoked, crypto.key.rotated, crypto.signature.failed | 3 |
| OHN-46 | partner.conformance.failed, partner.conformance.passed | 1 |
| OHN-47 | backup.failed, failover.initiated, restore.drill.passed | 3 |
| OHN-48 | disposal.completed, legal-hold.placed, retention.policy.changed | 3 |
| OHN-49 | order.accepted, order.amended, order.cancelled, order.in_progress, order.performed, order.placed, order.protocoled, order.rejected, order.resulted, order.reviewed, order.scheduled, order.specimen_collected, orders.config.changed | 1 |
| OHN-50 | medication.dispensed, prescription.signed | 2 |
| OHN-52 | digitisation.item.written, digitisation.job.completed, digitisation.job.ready_for_review, digitisation.job.rejected, digitisation.job.uploaded, digitisation.page.sent_to_external_engine | 1 |
| OHN-54 | appointments.appointment.booked, appointments.appointment.cancelled, appointments.appointment.checked_in, appointments.appointment.completed, appointments.appointment.in_consultation, appointments.appointment.no_show, appointments.appointment.rescheduled, appointments.booking_settings.changed, appointments.encounter.linked, appointments.followup.booked, appointments.followup.cancelled, appointments.followup.created, appointments.reminder.requested, appointments.request.accepted, appointments.request.confirmed, appointments.request.created, appointments.request.declined, appointments.request.expired, appointments.request.proposal_rejected, appointments.request.proposed, appointments.request.withdrawn, appointments.schedule.published, appointments.schedule.retired, appointments.waitlist.added, appointments.waitlist.slot_offered, teleconsult.call.ended, teleconsult.call.started, teleconsult.consent.recorded | 1 |
| OHN-56 | public_health.adr.reviewed, public_health.adr.submitted, public_health.alert.raised, public_health.alert.triaged, public_health.alert.updated, public_health.civil_notice.registered, public_health.civil_notice.rejected, public_health.civil_notice.sent, public_health.config.changed, public_health.registry.enrolled, public_health.registry.status_changed | 1 |
| OHN-57 | insurance.fraud_flag.raised, insurance.fraud_flag.resolved, research.access_request.decided, research.access_request.submitted, research.contact.outcome_recorded, research.extract.released, research.study.registered, research.study.state_changed, research.trial.contacts_routed | 1 |