# Alerts API

## GET /api/v1/admin/alert-channels

`GET /api/v1/admin/alert-channels` · operation `listAlertChannels`

YAML and console alert channels with delivery counts. Webhook URLs and signing secrets are never returned; only the URL origin and whether a secret is configured. Requires alert_channels and alerts:read (admin, viewer).

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Channels, deliverable events and kinds | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `version` (integer (int64), required)
  - `data` (array of [AlertChannelView](/docs/api/schemas/a/#alertchannelview), required)
  - `events` (array of string, required)
  - `kinds` (array of string, required)
  - `max_attempts` (integer, required)
  - `alerting` ([AlertingSettings](/docs/api/schemas/a/#alertingsettings), required)


## PUT /api/v1/admin/alert-channels/{id}

`PUT /api/v1/admin/alert-channels/{id}` · operation `upsertAlertChannel`

Create or update a console channel. The URL is required on create and optional on update (empty keeps the stored, encrypted value); it must be https (http only to loopback when alerting.allow_loopback_http is set at boot). signing_secret (16-256 characters) applies only to generic webhooks and adds an HMAC-SHA256 X-Gateway-Signature header (t=&lt;unix&gt;,v1=&lt;hex of HMAC(t + "." + body)&gt;). YAML channels are operator-owned (409). Requires alert_channel_management, alerts:manage and the control-plane encryption key. Optional digest policy can be staged while alert_digests is off; digest materialization and dispatch require that separate flag and enabled per-channel policy. Existing individual deliveries remain immediate. Interval and size edits apply after the captured current window drains.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{0,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required)
  - `channel` (object, required)
    - `id` (string, required)
    - `name` (string, required, max length 80)
    - `kind` (string, required, one of `"webhook"`, `"slack"`, `"teams"`, `"email"`, `"pagerduty"`)
    - `events` (array of string, required, min items 1) — experiment_finished (T186.012, experiment_traces) is recorded once per experiment run that reaches completed, failed or canceled, for a team whose plan includes the flag, while a channel subscribes: the detail names run_id, name, team, organization, status, dataset_id, dataset_as_of, dataset_version, model, prompt_id and prompt_revision, items, done, failed, duration_ms, scores (each evaluator's mean, pass count and results, bounded) and, for a suite run, suite_id and verdict; realtime alert rules of the experiments signal match it for their own team or organization. prompt_created, prompt_version_published and prompt_deleted (T186.013, prompt_events) report changes of the prompt registry made through the console, the admin API, team-delegated writes or (prompt_created) the YAML file, once each, written in the transaction of the change; the detail carries prompt_id, team, organization, revision, previous_revision, name, path (console, api, yaml), actor and request_id, never the text. rate_limit_would_limit (T186.010 follow-up) is an observe-only rate policy past its limit, at most once per policy every 15 minutes. evaluation_monitor_alert and evaluation_monitor_recovered (T186.010) make the channel selectable by the evaluation monitors of the teams in rule_teams and of the organizations in rule_organizations; nothing is fanned out to it, a monitor delivers only to the channels it names. alert_rule (T202) makes the channel selectable by alert rules; nothing is fanned out to it, a rule delivers only to the channels it names. The seven before it are operational events (T117), recorded with features.operational_alerts on each state transition (detail state firing, then resolved), firing at most once per alerting.operational.cooldown per condition, subject and replica, resolved at once; guardrail_blocked is deduplicated per guardrail per minute and mcp_health_failed per server per 10 minutes; key lifecycle events never carry the secret; model_follow_changed (T149) is recorded once per moving-alias change and control version; events are recorded only while a channel subscribes to them
    - `disabled` (boolean)
    - `digest` ([AlertDigestPolicy](/docs/api/schemas/a/#alertdigestpolicy))
    - `rule_organizations` (array of string, max items 64) — T202: organizations whose administrators may attach this channel to their organization's and teams' alert rules. Needs the alert_rule event. Global rules may use any channel with that event.
    - `rule_teams` (array of string, max items 64) — T202: teams whose administrators may attach this channel to that team's alert rules. Needs the alert_rule event.
    - `headers` (array of [AlertHeader](/docs/api/schemas/a/#alertheader), max items 10) — Webhooks only (T186.010 follow-up): requires alert_webhook_headers to add or change (403 feature_disabled); the headers a channel already has may be sent back unchanged with the flag off. 422 for a refused name or value, or a value_env not listed in alerting.webhook_header_envs.
  - `url` (string (uri), write-only) — https webhook URL, or for email smtps://[user:pass@]host:465 or smtp://...:587 (STARTTLS mandatory) with from= and to= (up to 10, comma separated) query parameters; for pagerduty the Events API v2 URL with ?routing_key= (the key is sent in the body, not the URL)
  - `signing_secret` (string, min length 16, max length 256, write-only)
  - `clear_signing_secret` (boolean) — Removes the stored signing secret and any previous secret still overlapping it.
  - `rotate_signing_secret` (boolean) — T168, requires features.alert_signing_rotation (403 feature_disabled otherwise) and a new signing_secret: the stored secret becomes the previous one and keeps signing for alerting.signing_overlap (database clock), so each delivery carries two v1 entries (new, then previous). A second rotation retires the older previous secret. 409 no_signing_secret when nothing is stored. Without this field a new signing_secret replaces the current one at once and drops any overlap.
  - `end_signing_overlap` (boolean) — Stops signing with the previous secret now and keeps the current one. Allowed with the flag off, so an overlap can always be cut short.

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Saved; channel view (without secrets) and new version | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Forbidden, or rotate_signing_secret with alert_signing_rotation off (feature_disabled) | — |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version conflict, YAML-owned channel, or no stored signing secret to rotate (no_signing_secret) | — |
| `422` | Invalid channel, URL or signing secret | — |
| `503` | Storage or encryption key unavailable | — |


## DELETE /api/v1/admin/alert-channels/{id}

`DELETE /api/v1/admin/alert-channels/{id}` · operation `deleteAlertChannel`

Remove a console channel. Delivery history is kept. YAML channels cannot be removed here.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Removed; new version | — |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | No console channel with this ID, or feature disabled | — |
| `409` | Configuration version conflict | — |


## POST /api/v1/admin/alert-channels/{id}/test

`POST /api/v1/admin/alert-channels/{id}/test` · operation `testAlertChannel`

Send one synthetic message now (event test), bounded to 10 seconds and the shared heavy-operation admission. It does not touch the outbox. Destinations resolving to loopback, link-local, private (unless allowed at boot) or special-use addresses are refused before connecting, with every DNS answer checked.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Result; a failed send is still 200 with delivered=false | `application/json`: [AlertSendResult](/docs/api/schemas/a/#alertsendresult) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Channel not found or feature disabled | — |
| `503` | Operation capacity exhausted | — |

