Skip to content

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.

FieldMeaning
event_idUnique id. Use it to deduplicate.
event_typeDotted name, e.g. diagnostic-result.available (pattern ^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$).
schema_versionVersion of the payload schema (see Versioning).
occurred_atWhen it happened (ISO 8601, UTC).
jurisdiction_id, organization_idWhere it happened.
aggregate_id, aggregate_versionThe record that changed and its version.
correlation_id, causation_idTrace a chain of events back to the request that started it.
data_classificationSensitivity class; it controls which subscribers may receive the event.
payloadIdentifiers, 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, 429 or any 5xx is retried with exponential backoff (default: base 30 s, cap 1 hour, at most 8 attempts within 72 hours). Any other 4xx or a 3xx is final.
  • After the last attempt the delivery goes to the dead-letter queue and a delivery.failed event 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:

HeaderValue
x-ohn-event-idThe event’s event_id. Check it matches the body.
x-ohn-signaturesha256=<hex HMAC-SHA256 of the raw body>
x-ohn-signature-notehmac, 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/).

ServiceEvent typesSchemas
OHN-04identifier.mapping.changed, patient.merged, patient.unmerged1
OHN-05facility.branding.changed, facility.logo.approved, facility.logo.rejected, facility.logo.uploaded, facility.logo.withdrawn, facility.registered, facility.suspended, facility.verified1
OHN-06affiliation.changed, practitioner.license.expired, practitioner.suspended, practitioner.suspension.lifted, practitioner.verified1
OHN-08clinical-summary.updated, health-chart.projection.refreshed1
OHN-09encounter.corrected, encounter.timeline.updated1
OHN-10clinical-summary.observations-recorded, clinical-summary.published, reconciliation.requested1
OHN-11critical-result.acknowledged, critical-result.detected, critical-result.escalated, diagnostic-result.amended, diagnostic-result.available1
OHN-12birth.event.linked, child-health.age-transition.completed, immunization.record.updated1
OHN-13document.registered, document.revoked, document.versioned3
OHN-14emergency-summary.accessed, ips.generated1
OHN-15consent.expired, consent.granted, consent.revoked1
OHN-16access.denied, access.policy-version.changed, document_mark.issued, policy.published4
OHN-17emergency-access.ended, emergency-access.reviewed, emergency-access.started1
OHN-18audit.export.generated, audit.integrity.failure2
OHN-19delegation.revoked, dependent.age-transition, representation.verified1
OHN-20privacy.assessment.approved, privacy.policy.changed, transfer.authorized3
OHN-21fhir.transaction.accepted, fhir.transaction.rejected2
OHN-22legacy.message.accepted, legacy.message.quarantined1
OHN-23terminology.mapping.disputed, terminology.version.published1
OHN-25connector.connected, connector.degraded, connector.upgraded1
OHN-26edge.conflict.detected, edge.lease.expired, edge.sync.completed3
OHN-27referral.accepted, referral.completed, referral.declined, referral.sent1
OHN-28clinical-notification.acknowledged, clinical-notification.escalated, clinical-notification.needs-supervisor, clinical-notification.sent1
OHN-29aggregate.approved, aggregate.rejected, aggregate.submitted1
OHN-30coverage.eligibility.received, coverage.eligibility.requested1
OHN-31patient.portal-accessed, patient.request.submitted1
OHN-32clinician.emergency-requested, clinician.patient-accessed1
OHN-33developer.application.approved, developer.credential.rotated1
OHN-34quality.issue.detected, stewardship.case.resolved2
OHN-35ops.incident.closed, ops.incident.opened, ops.slo.breached1
OHN-36federation.request.denied, federation.transfer.approved2
OHN-37assurance.changed, proofing.completed, proofing.failed3
OHN-38auth.risk.detected, auth.session.revoked, client.credential.rotated3
OHN-39trust.enrollment.approved, trust.status.revoked2
OHN-40record-location.expired, record-location.registered2
OHN-41fhir.profile.published, fhir.resource.versioned2
OHN-42resource.classified, resource.reclassified1
OHN-43record.correction.proposed, rights.request.closed, rights.requested3
OHN-44clinical.hazard.detected, clinical.release.approved, clinical.release.blocked1
OHN-45crypto.key.revoked, crypto.key.rotated, crypto.signature.failed3
OHN-46partner.conformance.failed, partner.conformance.passed1
OHN-47backup.failed, failover.initiated, restore.drill.passed3
OHN-48disposal.completed, legal-hold.placed, retention.policy.changed3
OHN-49order.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.changed1
OHN-50medication.dispensed, prescription.signed2
OHN-52digitisation.item.written, digitisation.job.completed, digitisation.job.ready_for_review, digitisation.job.rejected, digitisation.job.uploaded, digitisation.page.sent_to_external_engine1
OHN-54appointments.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.recorded1
OHN-56public_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_changed1
OHN-57insurance.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_routed1