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

# Alert rules

Link monitors to alert channels and control which events fire notifications.

# Alert rules

An alert rule ties one monitor to one [alert channel](/api/alerts/channels), and controls which events (down, recovery, degraded) trigger a notification. A single monitor can have multiple rules — one per channel.

**Auth:** Bearer token

## List rules

GET `/alerts/rules`

### Query parameters

Filter rules for a specific monitor.

### Request

```bash
curl -H "Authorization: Bearer hu_..." \
  "https://happyuptime.com/api/v1/alerts/rules?monitor_id=mon_abc123"
```

### Response

```json
{
  "data": [
    {
      "id": "rule_001",
      "monitor_id": "mon_abc123",
      "alert_channel_id": "ch_001",
      "on_down": true,
      "on_recovery": true,
      "on_degraded": false,
      "created_at": "2026-03-01T10:00:00Z"
    }
  ]
}
```

## Create a rule

POST `/alerts/rules`

**Scope:** `write`

### Body parameters

Monitor ID.

Alert channel ID.

Alert when monitor goes down.

Alert when monitor recovers.

Alert when monitor degrades (some regions down, not all).

### Request

```bash
curl -X POST -H "Authorization: Bearer hu_..." \
  -H "Content-Type: application/json" \
  -d '{
    "monitor_id": "mon_abc123",
    "alert_channel_id": "ch_001",
    "on_down": true,
    "on_recovery": true,
    "on_degraded": true
  }' \
  "https://happyuptime.com/api/v1/alerts/rules"
```

### Response

```json
{
  "data": {
    "id": "rule_002",
    "monitor_id": "mon_abc123",
    "alert_channel_id": "ch_001",
    "on_down": true,
    "on_recovery": true,
    "on_degraded": true,
    "created_at": "2026-03-07T16:00:00Z"
  }
}
```

## Delete a rule

DELETE `/alerts/rules/:id`

**Scope:** `write`

```bash
curl -X DELETE -H "Authorization: Bearer hu_..." \
  "https://happyuptime.com/api/v1/alerts/rules/rule_002"
```

```json
{
  "data": {
    "id": "rule_002",
    "deleted": true
  }
}
```

New monitors are automatically linked to any alert channels marked as `is_default: true`. Override this behavior per-monitor by deleting the auto-created rule or adding your own.