> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meshai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Anomalies API

> List, inspect, acknowledge, and resolve anomalies. Manage anomaly rules.

## List Anomalies

```
GET /anomalies
```

| Parameter  | Type    | Description                                                              |
| ---------- | ------- | ------------------------------------------------------------------------ |
| `status`   | string  | `open`, `acknowledged`, `resolved`                                       |
| `type`     | string  | `cost_spike`, `reliability_decay`, `behavioral_drift`, `security_threat` |
| `agent_id` | string  | Filter to a specific agent                                               |
| `severity` | string  | `low`, `medium`, `high`, `critical`                                      |
| `page`     | integer | Page number                                                              |
| `limit`    | integer | Results per page                                                         |

```bash theme={null}
curl "https://api.meshai.dev/api/v1/anomalies?status=open&type=cost_spike" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
```

<ResponseExample>
  ```json Response theme={null}
  {
    "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 }
  }
  ```
</ResponseExample>

## Get an Anomaly

```
GET /anomalies/{anomaly_id}
```

```bash theme={null}
curl https://api.meshai.dev/api/v1/anomalies/ano_abc123 \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
```

## Anomaly Summary

```
GET /anomalies/summary
```

Get counts by status and type.

```bash theme={null}
curl https://api.meshai.dev/api/v1/anomalies/summary \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
```

<ResponseExample>
  ```json Response theme={null}
  {
    "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
      }
    }
  }
  ```
</ResponseExample>

## Acknowledge an Anomaly

```
POST /anomalies/{anomaly_id}/acknowledge
```

```bash theme={null}
curl -X POST https://api.meshai.dev/api/v1/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
```

```bash theme={null}
curl -X POST https://api.meshai.dev/api/v1/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 /anomaly-rules
```

```bash theme={null}
curl https://api.meshai.dev/api/v1/anomaly-rules \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
```

### Create a Rule

```
POST /anomaly-rules
```

| Field                 | Type    | Description                                                              |
| --------------------- | ------- | ------------------------------------------------------------------------ |
| `anomaly_type`        | string  | `cost_spike`, `reliability_decay`, `behavioral_drift`, `security_threat` |
| `enabled`             | boolean | Defaults to `true`                                                       |
| `threshold_config`    | object  | Threshold parameters for the rule                                        |
| `notification_config` | object  | Optional. Set `webhook_url` to receive delivery notifications            |

```bash theme={null}
curl -X POST https://api.meshai.dev/api/v1/anomaly-rules \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "anomaly_type": "cost_spike",
    "enabled": true,
    "threshold_config": { "daily_cost_usd": 100 },
    "notification_config": { "webhook_url": "https://example.com/webhooks/meshai" }
  }'
```

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "id": 12,
      "anomaly_type": "cost_spike",
      "enabled": true,
      "threshold_config": { "daily_cost_usd": 100 },
      "notification_config": { "webhook_url": "https://example.com/webhooks/meshai" },
      "created_at": "2026-03-17T10:00:00Z",
      "updated_at": "2026-03-17T10:00:00Z"
    }
  }
  ```
</ResponseExample>

### Update a Rule

```
PATCH /anomaly-rules/{rule_id}
```

```bash theme={null}
curl -X PATCH https://api.meshai.dev/api/v1/anomaly-rules/12 \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "threshold_config": { "daily_cost_usd": 150 } }'
```

### Delete a Rule

```
DELETE /anomaly-rules/{rule_id}
```

```bash theme={null}
curl -X DELETE https://api.meshai.dev/api/v1/anomaly-rules/12 \
  -H "Authorization: Bearer msh_YOUR_API_KEY"
```
