Alerts API
This page documents the 8 gateway endpoints tagged alerts in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| GET | /alerts/baselines | Usage baselines per user or per key |
| GET | /alerts/inbox | List alerts in the inbox |
| POST | /alerts/scan | Scan for usage anomalies now |
| GET | /alerts/inbox/{alert_id} | Read one alert |
| POST | /alerts/inbox/{alert_id}/acknowledge | Acknowledge an alert |
| POST | /alerts/inbox/{alert_id}/assign | Assign an alert |
| POST | /alerts/inbox/{alert_id}/resolve | Resolve an alert |
| GET | /health/deployments | Live speed and rate limits per deployment |
Endpoints
GET /alerts/baselines
Usage baselines per user or per key
For every user or key with usage today (UTC), today's requests, tokens, spend and error rate next to the mean and p95 of its own past days, the threshold that counts as unusual and whether today crosses it. Flagged rows come first. Proxy admins and admin viewers may call it and it changes nothing.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
entity_type | query | enum: "user", "key" | No | Compare users or virtual keys |
Example request:
curl -X GET "http://localhost:4000/alerts/baselines" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Today's usage next to each user's or key's own baseline | application/json BaselineReport |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer key and no custom role grants the route | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
entity_type | enum: "user", "key" | Yes | Entity Type |
day | string | Yes | Day |
baseline_days | integer | Yes | Baseline Days |
multiplier | number | Yes | Multiplier |
entities | array of EntityBaseline | Yes | Entities |
GET /alerts/inbox
List alerts in the inbox
Alerts newest first, one page at a time, by default only the ones still open or acknowledged. Proxy admins and admin viewers may call it and it changes nothing.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
status | query | enum: "active", "open", "acknowledged", "resolved", "all" | No | active is open plus acknowledged, all includes resolved |
page | query | integer | No | |
page_size | query | integer | No |
Example request:
curl -X GET "http://localhost:4000/alerts/inbox" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One page of alerts, newest first | application/json AlertList |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer key and no custom role grants the route | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alerts | array of InboxAlert | Yes | Alerts |
total | integer | Yes | Total |
page | integer | Yes | Page |
page_size | integer | Yes | Page Size |
POST /alerts/scan
Scan for usage anomalies now
Runs the usage anomaly scan now instead of waiting for the scheduled run. A flag that is already in the inbox for today is updated, not added twice. Proxy admins only, and the run and every new alert go to the audit log.
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/alerts/scan" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | How many flags today's scan found and how many became new alerts | application/json ScanResult |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin key and no custom role grants the route | application/json ErrorDetail |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
day | string | Yes | Day |
flagged | integer | Yes | Flagged |
created | integer | Yes | Created |
GET /alerts/inbox/{alert_id}
Read one alert
One alert with who acknowledged, owns and resolved it. Proxy admins and admin viewers may call it.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
alert_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/alerts/inbox/alert_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The alert | application/json InboxAlert |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer key and no custom role grants the route | application/json ErrorDetail |
| 404 | No alert has that id | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alert_id | string | Yes | Alert Id |
kind | enum: "usage_anomaly", "eval_regression" | Yes | Kind |
severity | enum: "warning", "critical" | Yes | Severity |
entity_type | enum: "user", "key", "online_eval_rule" | Yes | Entity Type |
entity_id | string | Yes | Entity Id |
metric | enum: "requests", "tokens", "spend", "error_rate", "pass_rate" | Yes | Metric |
day | string | Yes | Day |
observed | number | Yes | Observed |
baseline_p95 | number | Yes | Baseline P95 |
threshold | number | Yes | Threshold |
summary | string | Yes | Summary |
status | enum: "open", "acknowledged", "resolved" | Yes | Status |
assigned_to | string or null | Yes | Assigned To |
acknowledged_by | string or null | Yes | Acknowledged By |
acknowledged_at | string or null | Yes | Acknowledged At |
resolved_by | string or null | Yes | Resolved By |
resolved_at | string or null | Yes | Resolved At |
resolution_note | string or null | Yes | Resolution Note |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
POST /alerts/inbox/{alert_id}/acknowledge
Acknowledge an alert
Marks an open alert as seen so others know someone is on it. Proxy admins only, and the before and after values go to the audit log.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
alert_id | path | string | Yes |
Request body (application/json, object):
Example request:
curl -X POST "http://localhost:4000/alerts/inbox/alert_id-123/acknowledge" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The alert marked acknowledged | application/json InboxAlert |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin key and no custom role grants the route | application/json ErrorDetail |
| 404 | No alert has that id | application/json ErrorDetail |
| 409 | The alert is not open | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alert_id | string | Yes | Alert Id |
kind | enum: "usage_anomaly", "eval_regression" | Yes | Kind |
severity | enum: "warning", "critical" | Yes | Severity |
entity_type | enum: "user", "key", "online_eval_rule" | Yes | Entity Type |
entity_id | string | Yes | Entity Id |
metric | enum: "requests", "tokens", "spend", "error_rate", "pass_rate" | Yes | Metric |
day | string | Yes | Day |
observed | number | Yes | Observed |
baseline_p95 | number | Yes | Baseline P95 |
threshold | number | Yes | Threshold |
summary | string | Yes | Summary |
status | enum: "open", "acknowledged", "resolved" | Yes | Status |
assigned_to | string or null | Yes | Assigned To |
acknowledged_by | string or null | Yes | Acknowledged By |
acknowledged_at | string or null | Yes | Acknowledged At |
resolved_by | string or null | Yes | Resolved By |
resolved_at | string or null | Yes | Resolved At |
resolution_note | string or null | Yes | Resolution Note |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
POST /alerts/inbox/{alert_id}/assign
Assign an alert
Sets who looks after an alert that is not resolved yet, or clears it with null. Proxy admins only, and the before and after values go to the audit log.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
alert_id | path | string | Yes |
Request body (application/json, schema AssignAlert):
| Field | Type | Required | Description |
|---|---|---|---|
assigned_to | string or null | Yes | Who looks after the alert, a user id or email; null clears the assignment |
Example request:
curl -X POST "http://localhost:4000/alerts/inbox/alert_id-123/assign" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"assigned_to": "oncall@example.com"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The alert with its new owner | application/json InboxAlert |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin key and no custom role grants the route | application/json ErrorDetail |
| 404 | No alert has that id | application/json ErrorDetail |
| 409 | The alert is resolved | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alert_id | string | Yes | Alert Id |
kind | enum: "usage_anomaly", "eval_regression" | Yes | Kind |
severity | enum: "warning", "critical" | Yes | Severity |
entity_type | enum: "user", "key", "online_eval_rule" | Yes | Entity Type |
entity_id | string | Yes | Entity Id |
metric | enum: "requests", "tokens", "spend", "error_rate", "pass_rate" | Yes | Metric |
day | string | Yes | Day |
observed | number | Yes | Observed |
baseline_p95 | number | Yes | Baseline P95 |
threshold | number | Yes | Threshold |
summary | string | Yes | Summary |
status | enum: "open", "acknowledged", "resolved" | Yes | Status |
assigned_to | string or null | Yes | Assigned To |
acknowledged_by | string or null | Yes | Acknowledged By |
acknowledged_at | string or null | Yes | Acknowledged At |
resolved_by | string or null | Yes | Resolved By |
resolved_at | string or null | Yes | Resolved At |
resolution_note | string or null | Yes | Resolution Note |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
POST /alerts/inbox/{alert_id}/resolve
Resolve an alert
Closes an open or acknowledged alert with an optional note. A resolved alert stays resolved for the rest of its day even when the scan flags the same user or key again. Proxy admins only, and the before and after values go to the audit log.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
alert_id | path | string | Yes |
Request body (application/json, schema ResolveAlert):
| Field | Type | Required | Description |
|---|---|---|---|
note | string or null | No | What was found or done, kept on the alert and in the audit log |
Example request:
curl -X POST "http://localhost:4000/alerts/inbox/alert_id-123/resolve" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"note": "A batch job looped, the key owner fixed the retry setting."
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The alert marked resolved | application/json InboxAlert |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin key and no custom role grants the route | application/json ErrorDetail |
| 404 | No alert has that id | application/json ErrorDetail |
| 409 | The alert is already resolved | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
alert_id | string | Yes | Alert Id |
kind | enum: "usage_anomaly", "eval_regression" | Yes | Kind |
severity | enum: "warning", "critical" | Yes | Severity |
entity_type | enum: "user", "key", "online_eval_rule" | Yes | Entity Type |
entity_id | string | Yes | Entity Id |
metric | enum: "requests", "tokens", "spend", "error_rate", "pass_rate" | Yes | Metric |
day | string | Yes | Day |
observed | number | Yes | Observed |
baseline_p95 | number | Yes | Baseline P95 |
threshold | number | Yes | Threshold |
summary | string | Yes | Summary |
status | enum: "open", "acknowledged", "resolved" | Yes | Status |
assigned_to | string or null | Yes | Assigned To |
acknowledged_by | string or null | Yes | Acknowledged By |
acknowledged_at | string or null | Yes | Acknowledged At |
resolved_by | string or null | Yes | Resolved By |
resolved_at | string or null | Yes | Resolved At |
resolution_note | string or null | Yes | Resolution Note |
created_at | string | Yes | Created At |
updated_at | string | Yes | Updated At |
GET /health/deployments
Live speed and rate limits per deployment
For every deployment that served traffic in the last 30 minutes: latency, time to first token on streamed answers, total duration, output tokens per second, successes, provider side failures and 429 rate limit answers. Percentiles are bucket upper bounds, and a null percentile means slower than the largest bucket. The numbers are shared across gateway instances when Redis is configured. Proxy admins and admin viewers may call it.
Example request:
curl -X GET "http://localhost:4000/health/deployments" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Latency, time to first token, duration, throughput and 429 counts over the last 30 minutes | application/json DeploymentSpeedReport |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer key and no custom role grants the route | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
generated_at | string | Yes | Generated At |
window_minutes | integer | Yes | Window Minutes |
deployments | array of DeploymentSpeedRow | Yes | Deployments |