Alerts on insights
Create an alert on a trend, funnel or retention insight, replay it with simulate, pick a check interval and notification channels, and see when it fires.
An alert watches a saved insight and tells you when its value crosses a rule. Authenticate as in Queries and insights over the API; the schemas are in GET /v1/openapi.json.
Create one
curl -X POST https://<your-host>/v1/projects/$PROJECT/insights/$INSIGHT/alerts \
-H "Authorization: Bearer $LUCIDA_KEY" -H "Content-Type: application/json" \
-d '{"name": "Signups dropped", "condition": {"op": "below", "threshold": 100},
"check_interval": "hourly",
"channels": [{"type": "email", "to": "team@example.com"}]}'condition.op is one of above, below, pct_up, pct_down, delta_up, delta_down (percent or absolute change from the previous point). An unknown op is a 400 that names the valid ones. Funnels use {"kind": "funnel_conversion", ...}, retention {"kind": "retention", ...}, and any trend can use {"kind": "anomaly", "sensitivity": "medium"}. hysteresis keeps a value hovering at the threshold from flapping.
Simulate before you save
POST /v1/projects/$PROJECT/insights/$INSIGHT/alerts/simulate with {"condition": {...}, "days": 30} replays the rule over the last 1 to 365 days and returns every point with its state, plus fires and resolves: each fire is one notification you would have received. Use it to tune the threshold. The llm detector is not replayed.
Check intervals
check_interval is one of every_1m, every_5m, every_15m, hourly, daily, weekly, monthly (default daily). Alerts are evaluated on a schedule: a new alert starts as ok with last_checked_at empty until the first scheduled pass reaches it, which for a coarse interval can take up to that interval. The every_1m and every_5m alerts run on a faster tick. To check an alert right away, use Check now in the alerts dialog or POST /v1/projects/$PROJECT/insights/$INSIGHT/alerts/{id}/check (write access; an alert on another insight or project is a 404). It runs the same evaluation as the schedule, so it updates state and last_checked_at, records history, and notifies on a state change (respecting snooze), then returns the updated alert.
Channels
channels is a list: {"type":"email","to":"..."}, {"type":"slack","url":"..."} or {"type":"webhook",...}. Slack URLs are sealed at rest and never returned. The alert's creator also gets a notification in the notification center.
Firing
When the value crosses the rule the alert moves from ok to firing, notifies every channel once and emits alert.fired; when it recovers it emits alert.resolved and notifies again. It does not repeat while it stays in the same state. History is at GET /v1/projects/$PROJECT/alerts/{id}/events (add ?transitions=true for only the state changes). PATCH and DELETE on /v1/projects/$PROJECT/alerts/{id} change or remove it.