Outbound webhooks
Get signed HTTP callbacks when flags change, experiments start or stop, alerts fire, cohorts recalculate or an export run fails; verify the signature, retries and the delivery log.
A webhook endpoint is a URL in one project that Lucida calls when something happens. Manage endpoints with the API (scopes settings:read and settings:write).
curl -X POST "$API/v1/projects/$PROJECT/webhooks" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"name":"ops","url":"https://example.com/hooks/lucida","events":["flag.changed","alert.fired"]}'The response carries the signing secret (whsec_...) once; Lucida keeps it envelope-encrypted and never shows it again. You can supply your own secret (at least 16 characters); it is echoed back once in the same way. The url must be http or https and must resolve to a public address: a host that is, or resolves to, a loopback, private or link-local address is refused with 400 (target address is not public) when you save it, the same rule deliveries use. An empty events list subscribes to everything. GET .../webhooks/event-types lists what you can subscribe to.
Route | Purpose |
|---|---|
| list, create |
| read, change ( |
| issue a new signing secret (shown once); the old one keeps signing for an overlap window |
| send a |
| delivery log with status, attempts, last error, response time |
| subscribable event types |
Events
Event | When |
|
|---|---|---|
| a flag is created, updated, enabled, disabled, killed, rolled out or deleted |
|
| an experiment changes state (started, paused, stopped, ...) |
|
| an alert opens or closes | the alert's details; inspect a real delivery in the log |
| a cohort membership job finishes | the cohort and its new size |
| a scheduled, backfill or retry export run fails |
|
| see the event-types route |
Every delivery is a JSON envelope: {"id", "type", "created_at", "project_id", "data"}. Delivery is at least once: dedupe on id.
Verify the signature
Each request carries:
Lucida-Signature: t=<unix>,v1=<hex>, wherev1is HMAC-SHA256 of"<t>.<raw body>"with your endpoint secret. During a secret rotation the header carries onev1per active secret (t=..,v1=<new>,v1=<old>): accept the delivery when anyv1matchesLucida-Event: the event typeLucida-Delivery: the delivery id
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret, header, rawBody, toleranceSec = 300) {
const parts = header.split(",").map((s) => s.split("="));
const t = parts.find(([k]) => k === "t")?.[1];
if (Math.abs(Date.now() / 1000 - Number(t)) > toleranceSec) return false;
const mac = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
return parts.some(([k, v]) => k === "v1" && v?.length === mac.length && timingSafeEqual(Buffer.from(mac), Buffer.from(v)));
}Compute the MAC over the raw bytes, not a re-serialised object, and reject old timestamps.
Rotate the secret
POST .../webhooks/{id}/rotate-secret returns a new secret (shown once) and keeps signing with the replaced one until prev_secret_expires_at (the endpoint's field; default 24 hours). Send {"overlap_hours": 0} to cut the old secret off at once, up to 168 (a week). Roll your receiver to the new secret inside the window: the signature header carries both MACs, so a receiver that checks either one never misses a delivery.
Retries
A non-2xx answer or a network error is retried with exponential backoff: 30 s, doubling, capped at 6 h, up to 8 attempts, then the delivery is marked failed. The delivery log shows each attempt (attempts, last_status, last_error, next_attempt_at while pending). Pending deliveries retry on their own; failed ones stay in the log.