API Reference

Alerts

Threshold rules and the events they trigger.

GET/api/alerts/rules

List 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/rules

Create a new rule. It's enabled by default.

Body fieldTypeRequired
namestringyes
metric"pass_rate" | "latency_ms" | "cost_usd" | "error_rate"yes
comparator"lt" | "gt"yes
thresholdnumberyes
scopestringno — 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/:ruleId

Toggle a rule on or off — this is what the Alerts page's switch calls.

Body fieldTypeRequired
enabledbooleanyes
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/events

List 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

FieldTypeNotes
comparator"lt" | "gt"Direction the rule checks in
scopestringFree-form; the API doesn't enforce a format
evaluationRunId / traceIdstring?Exactly one is set on a given event, pointing at the source