Alerts
Detection-only alert rules evaluated on a 5-minute cron, plus firing history. Notifications are delivered through the project's channels.
These endpoints accept a Bearer API key or a dashboard session cookie (requireSession) — see Authentication. They’re mounted twice: at the plain paths below (key-scoped to the key’s own project) and at /api/orgs/:orgSlug/projects/:projectSlug/alerts (session-scoped, used by the dashboard). Both mounts run the same handler.
Alert rules are detection-only — they define a condition, threshold, and window. When a rule fires it opens/reopens an issue, and that issue is delivered through the project’s notification channels (Discord / Slack / email / push) configured via the project notification settings. Rules have no per-rule notify target.
GET /api/alerts
List alert rules for the project. Also available at /api/orgs/:orgSlug/projects/:projectSlug/alerts.
Auth: API key (Bearer) or session cookie
Response 200
{
"rules": [
{
"id": "alr_01hxyz",
"project_id": "proj_01abc",
"name": "High error rate",
"condition_field": "level",
"condition_value": "error",
"threshold": 20,
"window_minutes": 15,
"cooldown_minutes": 15,
"enabled": 1,
"last_triggered_at": 1720478000000,
"created_by": "user_01abc",
"created_at": 1720392000000
}
]
}
enabled is 0/1 (D1 has no boolean type).
POST /api/alerts
Create an alert rule. Also available at /api/orgs/:orgSlug/projects/:projectSlug/alerts.
Auth: API key (Bearer) or session cookie · Content-Type: application/json
Request body
| field | type | required | description |
|---|---|---|---|
| name | string | yes | |
| condition_field | string | yes | One of level, type, service, environment, device_type |
| condition_value | string | yes | |
| threshold | number | yes | |
| window_minutes | number | yes | |
| cooldown_minutes | number | no | Default 15 |
Response 201
{ "id": "alr_01hxyz" }
Errors: 400, shape { "error": "<message>" }:
"Missing required fields"— one ofname/condition_field/condition_value/threshold/window_minutesis absent
PATCH /api/alerts/:id
Update an alert rule. Also available at /api/orgs/:orgSlug/projects/:projectSlug/alerts/:id.
Auth: API key (Bearer) or session cookie
Request body — any subset of: name, condition_field, condition_value, threshold, window_minutes, cooldown_minutes, enabled.
Response 200
{ "ok": true }
Errors:
404—{ "error": "Not found" }if no rule with that ID exists in this project404—{ "error": "Not found or no changes" }if the update matched the rule but touched zero columns (e.g. an empty body)
DELETE /api/alerts/:id
Delete an alert rule. Also available at /api/orgs/:orgSlug/projects/:projectSlug/alerts/:id.
Auth: API key (Bearer) or session cookie
Response 200
{ "ok": true }
Errors: 404 — { "error": "Not found" } if no rule with that ID exists in this project
GET /api/alerts/history
Recent alert firings for the project. Also available at /api/orgs/:orgSlug/projects/:projectSlug/alerts/history.
Auth: API key (Bearer) or session cookie
Response 200
{
"history": [
{
"id": "alh_01hxyz",
"project_id": "proj_01abc",
"rule_id": "alr_01hxyz",
"triggered_at": 1720478000000,
"event_count": 23
}
]
}
Returns the most recent 20 firings for the project, ordered by triggered_at descending — there is no limit/offset query param on this route.
Common responses (401; 402 and 429 don’t apply to these endpoints) — see Authentication.