# Update notification destination

> Source: https://truto.one/docs/api-reference/admin/notification-destinations/update/

`PATCH /notification-destination/{id}`

Resource: **Notification destinations**

`config` is checked against `type`, or the stored type when `type` is left out. A `config` sent replaces the stored one, except that `webhook_url`, `to`, `cc` and `bcc` keep their stored values when left out (and a `webhook_url` sent as `********` does too).

## Path parameters

- **`id`** _(string, required)_

## Request body

- **`type`** _(string)_
  Allowed: `slack`, `email`
- **`config`** _(object)_
  Settings for the type. Each field is optional.
- **`label`** _(string)_
- **`is_active`** _(boolean)_
- **`event_types`** _(array<string>)_
  Replaces the destination's event types. An empty list, or leaving it out, keeps them. The response to this request still shows the previous event types; read the destination again to see the new ones.

## Response body

- **`id`** _(string)_
  The ID of the notification destination.
- **`environment_id`** _(string)_
- **`type`** _(string)_
  Allowed: `slack`, `email`
- **`label`** _(string)_
- **`config`** _(object)_
  The destination's settings. The shape depends on `type`.
  _One of:_
  - **Slack**
    - **`webhook_url`** _(string)_
      A Slack incoming webhook URL. Returned masked as `********`. A `PATCH` that sends `********` back, or leaves the field out, keeps the stored URL.
    - **`ignored_status_codes`** _(array<number>)_
      For `api_errors` events, HTTP status codes not to notify about.
  - **Email**
    - **`to`** _(array<string>)_
    - **`cc`** _(array<string>)_
    - **`bcc`** _(array<string>)_
    - **`subject_prefix`** _(string)_
- **`is_active`** _(boolean)_
  Whether notifications are sent to this destination.
- **`event_types`** _(array<string>)_
  The notification event types this destination receives. `all`: every type. `api_errors`: failed integration API requests. `api_token_events`: expired tokens and a daily digest of unused ones. `integrated_account_events`: accounts that went stale and deletion reminders, at most one message a day per environment. `webhook_deactivated`: Truto turned off a failing webhook. `api_usage`: the monthly usage report.
- **`created_at`** _(string)_
- **`updated_at`** _(string)_

## Errors

| Status | Description |
| :----- | :---------- |
| `400` | Invalid `config` for the type. |
| `404` | Notification destination not found |

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/notification-destination/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "slack",
  "config": {},
  "label": "your_label",
  "is_active": true,
  "event_types": []
}'
```

### JavaScript

```javascript
const body = {
  "type": "slack",
  "config": {},
  "label": "your_label",
  "is_active": true,
  "event_types": []
};

const response = await fetch('https://api.truto.one/notification-destination/{id}', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/notification-destination/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "type": "slack",
    "config": {},
    "label": "your_label",
    "is_active": True,
    "event_types": []
}

response = requests.patch(url, headers=headers, params=params, json=payload)
print(response.json())
```
