API Reference
Alerts
Threshold rules and the events they trigger.
GET
/api/alerts/rulesList all alert rules.
{
"rules": [
{
"id": "rule_001",
"name": "Pass rate drops below 70%",
"metric": "pass_rate",
"comparator": "lt",
"threshold": 0.7,
"scope": "global",
"enabled": true,
"createdAt": "2026-06-12T22:22:00.000Z"
}
]
}POST
/api/alerts/rulesCreate a new rule. It's enabled by default.
| Body field | Type | Required |
|---|---|---|
| name | string | yes |
| metric | "pass_rate" | "latency_ms" | "cost_usd" | "error_rate" | yes |
| comparator | "lt" | "gt" | yes |
| threshold | number | yes |
| scope | string | no — defaults to "global" |
curl -X POST https://preview.devx-ai.xyz/api/alerts/rules \
-H "Content-Type: application/json" \
-d '{
"name": "Support QA pass rate below 80%",
"metric": "pass_rate",
"comparator": "lt",
"threshold": 0.8,
"scope": "dataset:ds_001"
}'Returns 201 with { rule }. 400 if any required field is missing or invalid.
PATCH
/api/alerts/rules/:ruleIdToggle a rule on or off — this is what the Alerts page's switch calls.
| Body field | Type | Required |
|---|---|---|
| enabled | boolean | yes |
curl -X PATCH https://preview.devx-ai.xyz/api/alerts/rules/rule_004 \
-H "Content-Type: application/json" \
-d '{ "enabled": true }'Returns 200 with { rule }. 404 if ruleId doesn't exist.
GET
/api/alerts/eventsList triggered events, newest first, each linking back to the evaluation run or trace that caused it.
{
"events": [
{
"id": "evt_001",
"ruleId": "rule_003",
"triggeredAt": "2026-07-15T22:22:00.000Z",
"actualValue": 0.0115,
"message": "Trace \"summarize.ticket\" (gpt-4o-mini) cost $0.0115 — above the $0.01 threshold.",
"traceId": "trace_014"
}
]
}Data model
| Field | Type | Notes |
|---|---|---|
| comparator | "lt" | "gt" | Direction the rule checks in |
| scope | string | Free-form; the API doesn't enforce a format |
| evaluationRunId / traceId | string? | Exactly one is set on a given event, pointing at the source |