Skip to main content

List Anomalies

GET /anomalies
ParameterTypeDescription
statusstringopen, acknowledged, resolved
typestringcost_spike, reliability_decay, behavioral_drift, security_threat
agent_idstringFilter to a specific agent
severitystringlow, medium, high, critical
pageintegerPage number
limitintegerResults per page
curl "https://api.meshai.dev/anomalies?status=open&type=cost_spike" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": [
    {
      "id": "ano_abc123",
      "agent_id": "agt_xyz789",
      "agent_name": "production-summarizer",
      "anomaly_type": "cost_spike",
      "severity": "high",
      "status": "open",
      "description": "Token spend increased 340% vs 7-day average",
      "detected_at": "2026-03-17T09:45:00Z",
      "details": {
        "current_cost_usd": 45.20,
        "baseline_cost_usd": 10.30,
        "deviation_percent": 338.8
      }
    }
  ],
  "meta": { "total": 3, "page": 1, "limit": 20 }
}

Get an Anomaly

GET /anomalies/{anomaly_id}
curl https://api.meshai.dev/anomalies/ano_abc123 \
  -H "Authorization: Bearer msh_YOUR_API_KEY"

Anomaly Summary

GET /anomalies/summary
Get counts by status and type.
curl https://api.meshai.dev/anomalies/summary \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
{
  "success": true,
  "data": {
    "total": 12,
    "by_status": { "open": 3, "acknowledged": 5, "resolved": 4 },
    "by_type": {
      "cost_spike": 6,
      "reliability_decay": 3,
      "behavioral_drift": 2,
      "security_threat": 1
    }
  }
}

Acknowledge an Anomaly

POST /anomalies/{anomaly_id}/acknowledge
curl -X POST https://api.meshai.dev/anomalies/ano_abc123/acknowledge \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "note": "Expected spike — batch processing job" }'

Resolve an Anomaly

POST /anomalies/{anomaly_id}/resolve
curl -X POST https://api.meshai.dev/anomalies/ano_abc123/resolve \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "resolution": "Batch job completed. Cost back to normal." }'

Anomaly Rules

Custom rules let you define thresholds and conditions for anomaly detection beyond the built-in ML algorithms.

List Rules

GET /anomalies/rules
curl https://api.meshai.dev/anomalies/rules \
  -H "Authorization: Bearer msh_YOUR_API_KEY"

Create a Rule

POST /anomalies/rules
curl -X POST https://api.meshai.dev/anomalies/rules \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "high-cost-alert",
    "description": "Alert when daily cost exceeds $100",
    "condition": {
      "metric": "daily_cost_usd",
      "operator": "greater_than",
      "threshold": 100
    },
    "severity": "high",
    "scope": "global",
    "enabled": true
  }'
{
  "success": true,
  "data": {
    "id": "rule_abc123",
    "name": "high-cost-alert",
    "condition": {
      "metric": "daily_cost_usd",
      "operator": "greater_than",
      "threshold": 100
    },
    "severity": "high",
    "scope": "global",
    "enabled": true,
    "created_at": "2026-03-17T10:00:00Z"
  }
}

Update a Rule

PATCH /anomalies/rules/{rule_id}
curl -X PATCH https://api.meshai.dev/anomalies/rules/rule_abc123 \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "condition": { "threshold": 150 } }'

Delete a Rule

DELETE /anomalies/rules/{rule_id}
curl -X DELETE https://api.meshai.dev/anomalies/rules/rule_abc123 \
  -H "Authorization: Bearer msh_YOUR_API_KEY"