Receive webhook deliveries
Build an endpoint that accepts the events Monark sends and processes each one once. An admin registers your endpoint's URL and picks its events; see Webhooks.
- Expose an HTTPS URL that accepts
POSTwith a JSON body. Plainhttp://is accepted only on a development instance, forlocalhostand private network addresses. - Parse the body. Every delivery has the same envelope:
{ "type": "kanban.card-created", "data": { "type": "kanban.card-created", "occurredAt": "…", "cardId": "…", "organizationId": "…" } }datais the event's full payload. The event type is also in theWebhook-Event-Typeheader. - Verify the signature before you trust anything in the body.
- Skip deliveries you've already processed. Store each
Webhook-Delivery-Idempotency-Keyheader you handle; a retry of the same delivery carries the same key. - Respond with any
2xxstatus within 10 seconds. Do slow work after responding, from a queue of your own.
Test it locally
- Start the bundled receiver, which logs each request and checks signatures:
pnpm webhook-receiver --port 4123 --secret <signing-secret> - Register
http://127.0.0.1:4123/hookas an endpoint on your development instance and trigger one of its events. - Fetch what arrived with
curl http://127.0.0.1:4123/inbox. Add--fail-onceto the receiver to watch a retry.
Good to know:
- Anything other than a
2xxwithin 10 seconds counts as a failure, including redirects, which aren't followed. A failed delivery is retried up to five attempts in all, after about 30 seconds, then 1, 2 and 4 minutes. - When attempts keep failing with no success in between, the delivery is marked failed and Monark turns the endpoint off. An admin can retry failed deliveries and turn the endpoint back on.
- Deliveries can arrive out of order. Use
occurredAtin the payload when order matters.