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.

Embed
Preview of the card
<a href="https://lucidace.com/help/outbound-webhooks"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/e1497ea7-e77a-45de-8b1d-32b51253c70d/social-card.svg?v=3e7ae33eec8b" alt="Outbound webhooks" width="600" height="315"></a>

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

GET, POST /v1/projects/{project_id}/webhooks

list, create

GET, PATCH, DELETE .../webhooks/{id}

read, change (name, url, events, enabled), delete; any other field in a PATCH is a 422 with errors[] naming it (a secret changes only through rotate-secret)

POST .../webhooks/{id}/rotate-secret

issue a new signing secret (shown once); the old one keeps signing for an overlap window

POST .../webhooks/{id}/test

send a webhook.test delivery now (logged once, never retried)

GET .../webhooks/{id}/deliveries

delivery log with status, attempts, last error, response time

GET .../webhooks/event-types

subscribable event types

Events

Event

When

data

flag.changed

a flag is created, updated, enabled, disabled, killed, rolled out or deleted

key, change (what happened, such as create or delete), enabled, version

experiment.state_changed

an experiment changes state (started, paused, stopped, ...)

experiment_id, name, status, action

alert.fired, alert.resolved

an alert opens or closes

the alert's details; inspect a real delivery in the log

cohort.recalculated

a cohort membership job finishes

the cohort and its new size

export.run_failed

a scheduled, backfill or retry export run fails

run_id, export_id, name, kind, data_from, data_to, error

annotation.created, digest.ready, health.*, vision.*, replay.notification, intervention.fired, webhook.test

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>, where v1 is HMAC-SHA256 of "<t>.<raw body>" with your endpoint secret. During a secret rotation the header carries one v1 per active secret (t=..,v1=<new>,v1=<old>): accept the delivery when any v1 matches

  • Lucida-Event: the event type

  • Lucida-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.

Updated