# POST /agent-ops/alert-rules

**Resource:** [Agent Ops](./agent-ops.md)  
**Scopes:** `agent-ops:write`  
**Write operation:** yes

Create an alert rule. Types: consecutive_failures, duration_exceeded, no_run_since, error_rate.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `rule_type` | body | string | yes | consecutive_failures \| duration_exceeded \| no_run_since \| error_rate |
| `threshold` | body | object | yes | e.g. {"max_failures": 2} or {"max_duration_ms": 300000} |
| `agent_name` | body | string | no | Target agent name (null for global rule) |
| `notify_channel` | body | string | no | slack \| email \| both |
| `enabled` | body | boolean | no | Default: true |

## Response example

```json
{ "data": { "id": "rule-uuid", "rule_type": "consecutive_failures", "threshold": {"max_failures": 2}, "enabled": true } }
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`