Source: https://datafa.st/docs/api/account/alerts
Markdown source: https://datafa.st/docs/api/account/alerts.md
Description: List, create, update, delete, and inspect alert trigger history.

# Alerts

Use these endpoints to manage email alerts that fire when a goal is reached.

Alerts are useful for founder workflows, sales notifications, and agent monitoring. An alert watches one goal and sends an email when that goal is triggered. History lets you inspect recent sent and failed alerts.

Base path: `https://datafa.st/api/v1/admin`

| Endpoint | Method | Path | Permission | Purpose |
|---|---|---|---|---|
| [List alerts](/docs/api/account/alerts/list) | GET | `/websites/{websiteId}/alerts` | `alerts:read` | List alerts |
| [Create alert](/docs/api/account/alerts/create) | POST | `/websites/{websiteId}/alerts` | `alerts:write` | Create an alert |
| [Update alert](/docs/api/account/alerts/update) | PUT | `/websites/{websiteId}/alerts/{alertId}` | `alerts:write` | Update an alert |
| [Delete alert](/docs/api/account/alerts/delete) | DELETE | `/websites/{websiteId}/alerts/{alertId}` | `alerts:write` | Delete an alert |
| [Get alert history](/docs/api/account/alerts/history) | GET | `/websites/{websiteId}/alerts/history` | `alerts:read` | Get recent alert trigger history |

## Create an alert

```sh
curl -X POST "https://datafa.st/api/v1/admin/websites/YOUR_WEBSITE_ID/alerts" \
  -H "Authorization: Bearer dft_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New signup",
    "trigger": { "goalName": "signup" },
    "template": {
      "subject": "New signup",
      "message": "A visitor completed signup."
    },
    "isEnabled": true
  }'
```

Alert history supports `alertId` and `limit` query parameters:

```txt
GET /api/v1/admin/websites/{websiteId}/alerts/history?alertId={alertId}&limit=50
```

Related docs: [tracked goals](/docs/api/account/tracked-goals), [authentication and scopes](/docs/api/authentication), [CLI alerts](/docs/cli-alerts).

## Code examples

### Create an alert

```bash
curl -X POST "https://datafa.st/api/v1/admin/websites/YOUR_WEBSITE_ID/alerts" \
  -H "Authorization: Bearer dft_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New signup",
    "trigger": { "goalName": "signup" },
    "template": {
      "subject": "New signup",
      "message": "A visitor completed signup."
    },
    "isEnabled": true
  }'
```

### Success response

```json
{
  "status": "success",
  "data": [
    {
      "id": "665f0b3c4d2e1a0012345678",
      "name": "New signup",
      "trigger": { "goalName": "signup" },
      "isEnabled": true
    }
  ]
}
```
