# Update an alert

Launch stage: GA

`PATCH /api/2.0/sql/alerts/{id}`

Updates an alert.

API scopes: sql

## Path parameters

- `id` (string, required)

## Request body

- `alert` (object, optional)
  - `display_name` (string, optional)
    The display name of the alert.
    Example: `Example alert`
  - `query_id` (string, optional)
    UUID of the query attached to the alert.
    Example: `dee5cca8-1c79-4b5e-a711-e7f9d241bdf6`
  - `seconds_to_retrigger` (int32, optional)
    Number of seconds an alert must wait after being triggered to rearm itself. After rearming, it can be triggered again. If 0 or not specified, the alert will not be triggered again.
    Example: `0`
  - `custom_body` (string, optional)
    Custom body of alert notification, if it exists. See [here](https://docs.databricks.com/sql/user/alerts/index.html) for custom templating instructions.
    Example: `custom body`
  - `custom_subject` (string, optional)
    Custom subject of alert notification, if it exists. This can include email subject entries and Slack notification headers, for example. See [here](https://docs.databricks.com/sql/user/alerts/index.html) for custom templating instructions.
    Example: `custom subject`
  - `condition` (object, optional)
    Trigger conditions of the alert.
    - `op` (string, optional)
      Operator used for comparison in alert evaluation.
      Possible values:
      - `GREATER_THAN`
      - `GREATER_THAN_OR_EQUAL`
      - `LESS_THAN`
      - `LESS_THAN_OR_EQUAL`
      - `EQUAL`
      - `NOT_EQUAL`
      - `IS_NULL`
    - `operand` (object, optional)
      Name of the column from the query result to use for comparison in alert evaluation.
      - `value` (object, optional)
        - `string_value` (string, optional)
          Example: `foo`
        - `double_value` (double, optional)
          Example: `1.25`
        - `bool_value` (boolean, optional)
          Example: `true`
      - `column` (object, optional)
        - `name` (string, optional)
          Example: `col`
    - `threshold` (object, optional)
      Threshold value used for comparison in alert evaluation.
      - `value` (object, optional)
        - `string_value` (string, optional)
          Example: `foo`
        - `double_value` (double, optional)
          Example: `1.25`
        - `bool_value` (boolean, optional)
          Example: `true`
      - `column` (object, optional)
        - `name` (string, optional)
          Example: `col`
    - `empty_result_state` (string, optional)
      Alert state if result is empty.
      Possible values:
      - `UNKNOWN`
      - `OK`
      - `TRIGGERED`
  - `owner_user_name` (string, optional)
    The owner's username. This field is set to "Unavailable" if the user has been deleted.
    Example: `user@acme.com`
  - `notify_on_ok` (boolean, optional)
    Whether to notify alert subscribers when alert returns back to normal.
- `update_mask` (string, required)
- `auto_resolve_display_name` (boolean, optional)
  If true, automatically resolve alert display name conflicts. Otherwise, fail the request if the alert's display name conflicts with an existing alert's display name.
  Default: `true`

## Returns

Returns the Alert object.

## Request

```json
{
  "alert": {
    "condition": {
      "op": "EQUAL",
      "operand": {
        "column": {
          "name": "bar"
        }
      },
      "threshold": {
        "value": {
          "bool_value": true
        }
      }
    },
    "display_name": "Renamed alert"
  },
  "update_mask": "display_name,condition"
}
```

## Response

```json
{
  "condition": {
    "op": "EQUAL",
    "operand": {
      "column": {
        "name": "bar"
      }
    },
    "threshold": {
      "value": {
        "bool_value": true
      }
    }
  },
  "create_time": "2019-08-24T14:15:22Z",
  "display_name": "Renamed alert",
  "id": "fe25e731-92f2-4838-9fb2-1ca364320a3d",
  "lifecycle_state": "ACTIVE",
  "owner_user_name": "user.name@acme.com",
  "parent_path": "/Workspace/Users/user.name@acme.com",
  "query_id": "dee5cca8-1c79-4b5e-a711-e7f9d241bdf6",
  "seconds_to_retrigger": 0,
  "state": "OK",
  "update_time": "2019-08-24T14:15:22Z"
}
```

