# Update an alert rule

> **PUT** `https://api.us.nylas.com/v3/alerts/send/{rule_id}`

Source: https://developer.nylas.com/docs/reference/api/send-alerts/update-send-alert-rule/

Updates the specified alert rule. Include only the fields you want to change. Changing a rule
starts its alerts over, so a domain that's still past the new threshold gets a new
`alert.triggered` notification.

**Authentication:** NYLAS_API_KEY

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `rule_id` | string, format: uuid | Yes | The ID of the alert rule. |

## Request body

Content-Type: application/json

- `metric` (string, one of: `bounce_rate`, `complaint_rate`, `delivery_rate`) - The rate to watch. `bounce_rate` and `complaint_rate` fire when the rate goes above the
threshold, and `delivery_rate` fires when it goes below.
- `threshold` (number) - The threshold, as a percentage with up to 2 decimal places. For `bounce_rate` and
`complaint_rate`, at least 0 and less than 100. For `delivery_rate`, more than 0 and at most
100. The rule fires only when the rate is past the threshold, not equal to it.
- `window_hours` (integer, min: 1, max: 24) - How many hours of sending the rate covers, from 1 to 24.
- `min_volume` (integer, min: 0, max: 1000000000, default: `0`) - The minimum number of messages a sending domain must send in the window before the rule can
fire. Use it to avoid alerts on low volume, where one bounce is a high rate.

## Responses

### 200 - Success. Returns the alert rule.

- `request_id` (string) - The request ID.
- `data` (object) - A rule that sends an `alert.triggered` webhook when a sending domain's rate crosses a threshold.
  - `id` (string, format: uuid) - The ID of the alert rule.
  - `application_id` (string) - The ID of your Nylas application.
  - `metric` (string, one of: `bounce_rate`, `complaint_rate`, `delivery_rate`) - The rate the rule watches. `bounce_rate` is hard bounces as a percentage of sent messages,
`complaint_rate` is complaints as a percentage of delivered messages, and `delivery_rate` is
delivered messages as a percentage of sent messages.
  - `direction` (string, one of: `above`, `below`) - Whether the rule fires when the rate goes above or below the threshold. Set by the metric:
`above` for `bounce_rate` and `complaint_rate`, `below` for `delivery_rate`.
  - `threshold` (number) - The threshold, as a percentage.
  - `window_hours` (integer) - How many hours of sending the rate covers.
  - `min_volume` (integer) - The minimum number of messages a sending domain must send in the window before the rule can fire.
  - `created_at` (integer, format: int64) - When the rule was created, as a Unix timestamp in seconds.
  - `updated_at` (integer, format: int64) - When the rule was last updated, as a Unix timestamp in seconds.

### 400 - Bad request. The request body isn't valid, or your application already has 20 alert rules.

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

### 401 - Unauthorized

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 403 - Forbidden. These endpoints need your application's API key, not a grant access token.

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

### 404 - Not found. Your application has no alert rule with this ID.

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

## Code samples

### cURL

```bash
curl --request PUT \
  --url "https://api.us.nylas.com/v3/alerts/send/<RULE_ID>" \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "threshold": 3
  }'
```
