Verify webhooks
A project has one webhook in each mode: one address that Waitlo posts that mode’s signed events to. Point it at your own server, and you’ll hear about a new waitlist entry, an updated one, a new contact message, or a withdrawn consent as they happen, instead of polling for them.
What you get
Section titled “What you get”Every delivery’s body is one event: An entry joined a waitlist, An entry's status, name, locale or fields changed, A contact form message was sent and Consent was withdrawn for an address. Each carries id (its own id, stable across every retry of the same delivery), object: "event", type, created_at, mode, project_id, request_id, example (true only for a test event) and data: the entry, message or withdrawal itself, frozen at the moment the change happened. waitlist.entry.updated also carries data.previous_attributes, the prior value of each attribute the write changed.
New event types can appear at any time, so a receiver should acknowledge one it doesn’t recognize rather than reject it.
Write the receiver
Section titled “Write the receiver”Every receiver on this page shares one event handler. It dedupes on the event’s own id – Waitlo may send the same event more than once, whether a retry or a later resend – and acknowledges a type it doesn’t know yet:
/** * One event handler, shared by every receiver on this page. Waitlo may * send the same event more than once (a retry, or a later resend from the * delivery log), so this checks the event's own id before doing anything * with it. An event type this handler doesn't know yet is acknowledged, * not rejected -- Waitlo can add one at any time. */export function handleWebhookEvent(event: WebhookEvent, handled: HandledEventIds): HandleResult { if (handled.has(event.id)) { return { type: event.type, duplicate: true }; } handled.add(event.id);
switch (event.type) { case "waitlist.entry.created": // event.data.object is the new entry. break; case "waitlist.entry.updated": // event.data.object is the entry's current state; event.data.previous_attributes holds what changed. break; case "contact.message.created": // event.data.object is the new message. break; case "consent.withdrawn": // event.data.object is the withdrawal; event.data.entries lists the entries it applies to. break; default: break; }
return { type: event.type, duplicate: false };}A Fetch-standard handler, one function from Request to Response, needs nothing else. Paste it as a Next.js App Router route’s POST export, or call it from Hono, Bun, Deno or a Cloudflare Worker the same way:
/** * A Fetch-standard webhook receiver: one function from `Request` to * `Response`, nothing Next.js-specific. Paste it as a Next.js App Router * route's `POST` export, or call it straight from Hono, Bun, Deno or a * Cloudflare Worker -- each of those already hands a handler a `Request` * and expects a `Response` back. */export async function POST(request: Request): Promise<Response> { let event; try { event = await verifyWebhook(request.clone(), { secret: process.env.WAITLO_WEBHOOK_SECRET! }); } catch (error) { if (error instanceof WebhookVerificationError) { return new Response(error.message, { status: 400 }); } throw error; }
const result = handleWebhookEvent(event, handled); return Response.json(result);}An Express server needs express.raw on the route, so the body it hands verifyWebhook is still the exact bytes Waitlo signed – express.json() (or any other body parser) ahead of this route would reserialize the body first, breaking every signature:
/** * The Express variant: `express.raw` on this route alone, so the body * Express hands `verifyWebhook` is still the exact bytes Waitlo signed. * `express.json()` (or any other body parser) ahead of this route would * reserialize the body first, which breaks every signature. */export function createApp(): Express { const app = express();
app.post("/webhooks/waitlo", express.raw({ type: "application/json" }), async (request, response) => { let event; try { event = await verifyWebhook({ payload: request.body, headers: request.headers }, { secret: process.env.WAITLO_WEBHOOK_SECRET! }); } catch (error) { if (error instanceof WebhookVerificationError) { response.status(400).send(error.message); return; } throw error; }
const result = handleWebhookEvent(event, handled); response.status(200).json(result); });
return app;}Both read the signing secret from WAITLO_WEBHOOK_SECRET, an environment variable you set after pointing a webhook at the receiver. A bad signature throws WebhookVerificationError, which both receivers answer with 400; anything else is a bug in the receiver itself, so it’s left to throw.
Point a test-mode webhook at it
Section titled “Point a test-mode webhook at it”Setting the webhook replaces it whole, and – the first time, for this mode – mints its signing secret:
const webhook = await waitlo.webhook.set({ url: process.env.WAITLO_WEBHOOK_URL!, events: ["waitlist.entry.created", "waitlist.entry.updated", "contact.message.created", "consent.withdrawn"],});
// webhook.secret is only ever returned here, and on a roll below -- store it as WAITLO_WEBHOOK_SECRET.console.log(`Signing secret: ${webhook.secret}`);WAITLO_WEBHOOK_URL is the address your receiver is reachable at; WAITLO_SECRET_KEY and WAITLO_API_URL are the same test-mode credential and base URL every other example on this site uses. A loopback WAITLO_WEBHOOK_URL (http://localhost…) only works locally, because .env.test sets WEBHOOK_ALLOW_PRIVATE_URLS – Waitlo refuses to send a live webhook anywhere but a public address. The printed secret is the one value this script never repeats: copy it into WAITLO_WEBHOOK_SECRET now. The dashboard’s webhook settings and the MCP server’s set_webhook tool do the same thing without a script.
Send a test event
Section titled “Send a test event”A test event is a made-up event of a chosen type – it describes no real entry, message or person – that Waitlo sends to your webhook on demand, so you can check it’s reachable and verifying before anything real depends on it. Setting it up enqueues the send and answers with a pending delivery; read the delivery back until it settles:
let delivery = await waitlo.webhook.test({ type: "waitlist.entry.created" });
while (delivery.status === "pending") { await new Promise((resolve) => setTimeout(resolve, 500)); delivery = await waitlo.webhook.deliveries.retrieve(delivery.id);}
console.log(`Delivery ${delivery.id}: ${delivery.status}`);The dashboard’s webhook page has the same thing behind a Send test event button, and the MCP server exposes it as send_test_webhook.
Retries and the delivery log
Section titled “Retries and the delivery log”A delivery succeeds the moment your receiver answers with a 2xx status, within 15 seconds of Waitlo starting to connect – DNS, connect, send and your response all have to fit inside that window. Anything else counts as a failed attempt:
error |
What happened |
|---|---|
http_status |
Your receiver answered with an error status. |
timeout |
Your receiver didn’t answer in time. |
connection_failed |
Waitlo couldn’t connect to your receiver. |
address_not_allowed |
The webhook’s URL points at an address Waitlo won’t send to. |
webhook_disabled |
The webhook was disabled before this could be sent. |
Only a genuine event retries on failure – a test event or a resend makes exactly one attempt. A genuine event’s first attempt happens at once; a failed one retries after 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 10 hours, 8 attempts in all, spanning about 27.5 hours, with some random jitter on each wait so retries from many deliveries don’t land on your receiver all at once.
The delivery log keeps every delivery for 7 days: its event, trigger (a genuine event, a test or a resend), status, attempt count and, for a settled attempt, the response status and an excerpt of its body. Reading one delivery back also returns the exact event it carried, which is what a resend sends again, byte for byte.
Replay protection
Section titled “Replay protection”verifyWebhook checks webhook-timestamp against the time it runs, by default allowing 5 minutes either way; outside that window, verification fails even with a correct signature. That bounds how long a captured delivery stays replayable, but it doesn’t rule out a genuine redelivery landing twice – a retry, a resend, or your own receiver retrying a request it believes failed. Dedupe on the event’s own id instead, the way the shared handler above does, since Waitlo gives every redelivery of the same event the same id. If more than one event ever touches the same entry, apply only the one with the greater id – delivery order isn’t guaranteed.
Rolling the secret
Section titled “Rolling the secret”Rolling the secret mints a fresh one at once. Give the old one a grace period and Waitlo signs with both until it expires, so you can update WAITLO_WEBHOOK_SECRET without ever dropping a delivery:
const rolled = await waitlo.webhook.rollSecret({ expires_in: 300 });
// The previous secret (held in WAITLO_WEBHOOK_SECRET until now) still verifies for 300 seconds.console.log(`New signing secret: ${rolled.secret}`);At most two secrets are ever valid for a webhook: the current one and, during a grace period, the one before it.
Without the SDK
Section titled “Without the SDK”Every signature on this page follows the Standard Webhooks spec: three headers (webhook-id, webhook-timestamp, webhook-signature), HMAC-SHA256 over id.timestamp.body, keyed by the signing secret. A receiver in another language, or one that can’t take @waitlo/sdk as a dependency, verifies the same way with any Standard Webhooks library – here, standardwebhooks:
/** * The same signature Waitlo's own `verifyWebhook` checks (ADR 0044: three * `webhook-*` headers, HMAC-SHA256 over `id.timestamp.body`), verified here * with the `standardwebhooks` library alone, for a receiver that can't take * `@waitlo/sdk` as a dependency. Any Standard Webhooks library for another * language verifies the same way. */export function verifyWithStandardWebhooks(payload: string, headers: Record<string, string>, secret: string): VerifiedWebhookEvent { const webhook = new Webhook(secret); return webhook.verify(payload, headers) as VerifiedWebhookEvent;}It rejects exactly what verifyWebhook rejects: a missing header, a tampered signature, or a timestamp outside tolerance.