Webhooks
Signed, retried, thin events for resource writes, consent changes and finalized documents, with signature verification in TypeScript, Dart and Python.
Anpheros Platform can call your server when something happens in your project: a resource was written, a person granted or revoked access, a document was finalized. Events are thin: ids, type, version — never clinical content. Read the resource through the API if you need it. Every delivery is signed; verify the signature before trusting it.
Register an endpoint
curl -X POST $BASE/v1/webhooks -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"url": "https://your.app/anpheros/hook", "events": ["resource.created", "consent.revoked"], "description": "prod"}'
The response contains secret (whsec_…) once. Store it; you need it to verify signatures.
events accepts ["*"] or any of:
| type | when | data |
|---|---|---|
resource.created / resource.updated / resource.deleted |
your project wrote a FHIR resource (REST v1, FHIR API or a bundle) — or another project wrote into a record you have access to (you created the patient, or you hold an active grant); then data.external is true and data.source says who wrote it: author_type (patient / practitioner / device / import / ai), organization (the display name the writer acted on behalf of), practitioner (name from the directory, when known), source_system, and since 8 Nov 2026 kind (anpheros_app / clinic / ai / third_party_app / patient), client_id, app_name, at |
resource_type, id, patient (the id you see), version, last_updated, and for external writes external, source |
consent.granted |
a person granted your app access from the consent page (or a trusted app linked its record) | grant_id, patient, application_id, scopes, purpose, expires_at |
consent.revoked |
the person (or the platform) ended a grant | same as above plus revoked_at, reason |
document.finalized |
a document upload was finalized and checksummed | id, patient, content_type, size, sha256 |
proposal.created |
an AI agent proposed a write into a record you can see; it waits for the person's approval | id, patient, action, resource_type |
patterns.updated |
the stored health-pattern findings of a record changed after a background run (only for the trusted first-party project the person gave the anpheros/patterns feature consent to) |
patient, engine_version, trigger (dirty, reconcile, upgrade, manual), findings_total, supported_total, changed[] with finding_key (stable, per project), event (appeared, supported, unsupported, gone, plus shown and hidden from the display rule) and statistically_supported, and display (the display rule: version, tick_days, show_after_days, hide_after_days); shown and hidden are sent for every method, also experimental ones and those that may not notify: notify a person on shown only (never on supported), and only when GET /v1/patients/{id}/patterns/current returns that finding with shown, method.patient_facing and method.notify all true; no values, codes or text: read GET /v1/patients/{id}/patterns/current |
result.released |
a clinic result that was held until a doctor saw it is now visible to the person (only the person's app gets it) | the same fields as an external resource.* event, plus release_reason, discuss (true when the doctor wants to discuss it) and released_at |
access_request.created |
a clinic asked the person for access to their record (only the person's app gets it, so it can show the request) | id, patient, application, organization, scopes_text (en, ro), purpose, message, expires_at, specialties, email_url |
ping |
you asked for a test delivery | endpoint |
Endpoints are per project and environment: a sk_test_ key manages sandbox endpoints,
a sk_live_ key production ones. URLs must be public https:// endpoints. Registration (and any later change of url) refuses local, private, link-local, metadata and other reserved addresses — localhost, 127.0.0.1, ::1, 10.0.0.0/8, 192.168.0.0/16, fd00::/8 and the like — and names that resolve to them, with 400 invalid on the field url; this applies in the sandbox too. Every delivery checks the address again and connects only to the IP addresses it has just checked, so a name that later points into a private network (DNS rebinding) gets nothing. To receive events on your own machine while developing, expose it through a public HTTPS tunnel and register the tunnel's address.
Up to 10 endpoints per project and environment.
The delivery
POST https://your.app/anpheros/hook
Content-Type: application/json
User-Agent: Anpheros-Webhooks/1.0
Anpheros-Event: resource.created
Anpheros-Event-Id: evt_…
Anpheros-Delivery: whd_…
Anpheros-Signature: t=1789800000,v1=5f3a…
{"id":"evt_…","type":"resource.created","created_at":"2026-09-19T12:00:00.000Z","environment":"production",
"project":"proj_…","data":{"resource_type":"Observation","id":"…","patient":"…","version":1,"last_updated":"…"}}
Respond with any 2xx within 10 seconds. Anything else (or a timeout) is a failure and the
delivery is retried with backoff for up to 24 hours (10 attempts), then marked exhausted.
Deliveries are at-least-once and may arrive out of order: use Anpheros-Event-Id to
de-duplicate and data.version to ignore stale updates.
Verify the signature
v1 is HMAC-SHA256 with your secret over <t>.<raw body>; reject if t is older than 5 minutes.
import { verifyWebhookSignature } from '@anpheros/sdk';
app.post('/anpheros/hook', express.raw({ type: 'application/json' }), async (req, res) => {
const ok = await verifyWebhookSignature({ secret: process.env.ANPHEROS_WEBHOOK_SECRET!, header: req.header('anpheros-signature'), body: req.body });
if (!ok) return res.status(400).end();
const event = JSON.parse(req.body.toString());
// … enqueue and return quickly
res.status(204).end();
});
import 'package:anpheros_sdk/anpheros_sdk.dart';
final ok = verifyWebhookSignature(secret: secret, header: request.headers['anpheros-signature'], body: rawBodyBytes);
import hmac, hashlib, time
def verify(secret: str, header: str, body: bytes, tolerance=300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
if abs(time.time() - int(parts["t"])) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts["v1"])
Operate
GET /v1/webhooks/{id}/deliveries?status=failed— the log, newest first, with status code and error.POST /v1/webhooks/{id}/deliveries/{delivery_id}/redeliver— send one again now.POST /v1/webhooks/{id}/ping— a test event.POST /v1/webhooks/{id}/rotate— new secret (the old one stops immediately; update your server first if you can't afford a gap: register a second endpoint, then delete the old one).PATCH /v1/webhooks/{id}with{"active": false}pauses deliveries; pending ones are dropped when you delete the endpoint.
Both SDKs expose this under webhooks (create, list, get, update, delete, rotateSecret, ping, deliveries, redeliver).
Ask your AI
Paste this into Claude, ChatGPT, Cursor or Claude Code. Your assistant reads this guide and adapts it to your code.
Read https://developers.anpheros.com/guides/webhooks.md and help me apply this guide to my own project. Use the Anpheros sandbox (base URL https://platform.anpheros.com) with my API key from the ANPHEROS_KEY environment variable, never written in the code. Give me complete, runnable code, the response I should expect, and how to fix the errors in https://developers.anpheros.com/guides/troubleshooting.md if a call fails.Open in ClaudeOpen in ChatGPTThis guide as MarkdownBuild the whole integration with an AI coding tool
Try it free in the sandbox · first FHIR call in 5 minutesFree · 30 synthetic patients · no cardYour first API call in 2 minutes →
