Skip to content

Webhooks

Sunny sends a signed HTTPS POST to your endpoint when a request changes. Webhooks are notifications; GET /v1/scheduling/requests/{id} is always the authority.

In the dashboard, open Webhooks and add an endpoint. You have one endpoint for sandbox requests and one for live requests.

  • The URL must be HTTPS with a public host name. IP addresses are refused, and redirects are not followed.
  • You choose which events it receives. The default is all of them.
  • You get a signing secret, shown once: whsec_…. Store it with your other secrets.

Sunny follows the Standard Webhooks convention, so existing libraries work.

Header Value
webhook-id The event’s event_id.
webhook-timestamp Unix seconds when this delivery was sent.
webhook-signature v1,<base64 HMAC-SHA256>. Two, separated by a space, while a secret is being rotated.

The signed content is {webhook-id}.{webhook-timestamp}.{raw body}. By hand, in Node:

import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret, headers, rawBody) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false; // older than 5 minutes
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = "v1," + createHmac("sha256", key).update(`${id}.${timestamp}.${rawBody}`).digest("base64");
// The header can hold two signatures, space-separated, while a secret is being rotated.
return headers["webhook-signature"].split(" ").some((given) =>
given.length === expected.length && timingSafeEqual(Buffer.from(given), Buffer.from(expected)));
}
  • Verify against the raw body, before parsing it.
  • Reject a timestamp more than 5 minutes old.
  • Compare in constant time.

Answer with any 2xx within 10 seconds. Do the real work after you have answered. Anything else counts as a failure and is retried.

  • At least once. Deduplicate on webhook-id, which is the same as event_id in the body.
  • In order, per request. An event is not sent until the one before it for the same request has succeeded or been given up on. sequence counts 1, 2, 3… per request, so you can see a gap. Different requests are independent.
  • Retries. After 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours, then every 24 hours, until 72 hours after the first try. Then the event is marked failed and the next event for that request goes ahead.
  • Paused endpoints. After 20 failures in a row, across requests, the endpoint is paused. Events queue while it is paused. Unpause it in the dashboard once it is fixed.
  • No fixed source addresses. Deliveries have no fixed IP list. Trust the signature, not the address.

In the dashboard you can replay any event. A replay has the same webhook-id and body, and a new timestamp and signature, so your deduplication treats it as the event you already know unless you have cleared it.

Rotate an endpoint’s secret in the dashboard. For 24 hours every delivery is signed with both the old secret and the new one, so you can switch without missing an event. Then the old one stops being used.

Payloads carry no patient name, date of birth, phone, address or member id. Match an event to your records with request_id or your own reference_id.

New events and new fields are added without a version change. Ignore the ones you do not know.

Every event and its payload is listed in Webhook events.