Receive webhooks
Mountaya sends each event your endpoint subscribes to as a signed POST. constructWebhookEvent checks the signature and gives you a typed event. Webhooks explains deliveries, and signatures the header.
Hand it the body exactly as it arrived, the Mountaya-Signature header and your endpoint's secret:
Read the body before any JSON parser touches it. A body decoded and encoded again is other bytes, which do not verify.
WebhookEvent has a case for each event type, so a switch reads what each one carries:
An event can arrive more than once and in any order. Act on each id once.
An event type newer than your build arrives as .unknown, with the raw envelope:
Answer it 200 like any other, so Mountaya does not send it again.
Rotate a secret in the Mountaya app, under Organization → Webhooks. For up to 7 days both secrets sign, and either one verifies, so deploy the new secret to your server before the overlap ends.
Check your receiver against the published test vectors, with now: pinned to each case's clock:
To try a real delivery, send your endpoint a test event from Organization → Webhooks, or with postOrganizationWebhookDelivery.