Source: https://datafa.st/docs/api/account/alerts/update
Markdown source: https://datafa.st/docs/api/account/alerts/update.md
Description: Update an alert.

# Update alert

`PUT https://datafa.st/api/v1/admin/websites/{websiteId}/alerts/{alertId}`

Update an alert name, watched goal, email template, or enabled state. Send only the fields you want to change.

Disabling an alert (`isEnabled: false`) stops emails without deleting the configuration.

> **Related:** [Alerts announcement](/changelog/alerts-mobile-wordpress) · [Custom goals](/docs/custom-goals)

## Request

#### Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `websiteId` | string | — | Website ObjectId. From [List websites](/docs/api/account/websites/list) (`_id` field). Example: `665f0b3c4d2e1a0012345678`. |
| `alertId` | string | — | Alert ObjectId from [List alerts](/docs/api/account/alerts/list). |

#### Body parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | Human-readable name for the resource or event. The exact meaning depends on the endpoint. |
| `trigger.goalName` | string | No | Goal that fires the alert. Example: `"purchase"`. Lowercased when saved. Pick from [List tracked goals](/docs/api/account/tracked-goals/list). |
| `template.message` | string | No | Plain-text email body. Min 10, max 2000 characters. Example: `"Someone just signed up on your site."` |
| `template.subject` | string | No | Optional custom subject. Example: `"New signup on example.com"`. Defaults to a standard alert subject when omitted. |
| `isEnabled` | boolean | No | `true` to enable; `false` to pause emails. |

#### Example request body

```json
{
  "name": "New signup alert",
  "trigger": { "goalName": "signup" },
  "template": {
    "subject": "New signup!",
    "message": "A visitor just completed the signup goal."
  },
  "isEnabled": true
}
```

## Response

Returns a JSON object with `status: "success"` and endpoint-specific fields in `data`.

#### Response fields

| Field | Type | Description |
| --- | --- | --- |
| `data[]._id` | string | Alert ObjectId. |
| `data[].websiteId` | string | Website ObjectId used by account tokens to choose which website to query or manage. |
| `data[].name` | string | Human-readable name for the resource or event. The exact meaning depends on the endpoint. |
| `data[].trigger.type` | string | Trigger type. Currently `goal`. |
| `data[].trigger.goalName` | string | Goal watched by the alert. |
| `data[].destination.type` | string | Destination type. Currently `email`. |
| `data[].template.subject` | string\|null | Custom subject when configured. |
| `data[].template.message` | string | Human-readable confirmation or status message for the operation. |
| `data[].isEnabled` | boolean | Whether the alert is enabled. |
| `data[].recentLogs` | object[] | Recent trigger logs. |

### Authentication

Use a `dft_` account token with `alerts:write`.

A `df_` website API key for the same website can also call this route when the path `websiteId` matches the key's website. Write access with a `df_` key is capped at **member** level — owner-only actions such as [team management](/docs/api/account/team) require a `dft_` token and owner role.

### Errors

See [API errors](/docs/api#errors) for the standard error envelope, auth failures, validation errors, permission errors, and rate limits.

## Code examples

### Example request

```bash
curl -X PUT "https://datafa.st/api/v1/admin/websites/{websiteId}/alerts/{alertId}" \
  -H "Authorization: Bearer dft_xxx" \
  -H "Content-Type: application/json" \
  -d '{"isEnabled":false}'
```

### Success response

```json
{
  "status": "success",
  "data": [{
    "_id": "665f0b3c4d2e1a0012345678",
    "websiteId": "665f0b3c4d2e1a0012345678",
    "name": "New signup",
    "trigger": { "type": "goal", "goalName": "signup" },
    "destination": { "type": "email" },
    "template": { "subject": "New signup", "message": "A visitor signed up." },
    "isEnabled": true,
    "recentLogs": []
  }]
}
```
