A bot can follow sources (RSS feeds, YouTube, Twitch, Bluesky) **server by server**: when something new appears, it posts in a channel and/or starts the "Automation alert" workflow. Inside a command, the script functions `$createAlert`, `$pauseAlert`, `$resumeAlert`, `$deleteAlert`, `$alertList`, `$alertCount`, `$alertInfo` (and `bc.alert` in JavaScript) manage the alerts of the current server. The public API reaches **the same alerts** from your own code. Create the key as described in the [Public API guide]({{ '/docs/public-api/' | relative_url }}).

## Scopes

| Scope | Allows |
|---|---|
| `read:bots` | List the alerts of a server |
| `write:settings` | Create, pause, resume and delete alerts |

## Rules

- The bot owner must have **turned alerts on** for the bot (Alerts by server, in the app or the Studio) and have a **paid plan**; otherwise `409 automation_not_enabled` or `403 automation_paid_required`.
- Every call names the server with `guild_id`. The key belongs to the bot owner: it is **not** checked against the Manage Server permission of a Discord user (the script functions do that check themselves).
- Limits follow the owner's plan: active alerts per server (3, 5, 8 or 12) and total alerts per bot. Beyond, `409 automation_limit_reached` or `409 automation_total_limit`.
- Twitch alerts need the owner's Twitch application.

## Routes at a glance

| Route | Scope | Description |
|---|---|---|
| `GET /v1/bots/{botId}/alerts?guild_id=` | `read:bots` | The alerts of the server and the limits that apply |
| `POST /v1/bots/{botId}/alerts` | `write:settings` | Create an alert and start it |
| `POST /v1/bots/{botId}/alerts/{alertId}/pause` | `write:settings` | Pause. Body `{ "guild_id" }` |
| `POST /v1/bots/{botId}/alerts/{alertId}/resume` | `write:settings` | Resume. Body `{ "guild_id" }` |
| `DELETE /v1/bots/{botId}/alerts/{alertId}?guild_id=` | `write:settings` | Delete. Answers `204` |

## Alert object

| Field | Type | Description |
|---|---|---|
| `id` | string | The alert ID |
| `guild_id` | string | The Discord server |
| `channel_id` | string | The channel where the bot posts |
| `action` | string | `workflow`, `message` or `both` |
| `name` | string | The name shown in lists |
| `source_kind` | string | `rss`, `youtube`, `twitch` or `bluesky` |
| `source` | object | One key: `url`, `channel`, `login` or `handle` |
| `status` | string | `active` or `paused` |
| `last_error` | string | The last error, empty when the last check went well |
| `last_sent_at` | string or null | ISO 8601 timestamp of the last item posted |

## Create an alert

`POST /v1/bots/{botId}/alerts` · scope `write:settings`

```json
{
  "guild_id": "123456789012345678",
  "name": "Live garder",
  "source_kind": "twitch",
  "source": { "login": "garder" },
  "channel_id": "223456789012345678",
  "action": "both"
}
```

`action` is `workflow` by default. Set `"start": false` to leave the alert paused. The answer is the alert object (`201`).

## List the alerts of a server

`GET /v1/bots/{botId}/alerts?guild_id=123456789012345678` · scope `read:bots`

```json
{
  "items": [ { "id": "a1", "name": "Live garder", "status": "active" } ],
  "limits": { "enabled": true, "paid": true, "active": 1 }
}
```
