# Change what a channel sends, replace its token, or switch it on or off.

> A new token is checked with Notify as on create.
> https://koi.dog/docs/api/notifications/update-notification-channel/

`PATCH /api/v1/notifications/channels/{id}` · Scopes: `config`, `approve`

Replacing the token or switching the channel on retries its pending sends at once. The timeline records the key ID, action and outcome.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The notification channel's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | no | A new name. 1 to 80 characters. |
| `token` | `string` | no | A new Notify agent token, checked with Notify before it replaces the old one. Pending sends are retried at once. 8 to 2000 characters. |
| `send` | `array` | no | What to send from now on: `approvals`, `questions`, `crew_finished`, `crew_failed`, `budget`, `digest`. Any of `approvals`, `questions`, `crew_finished`, `crew_failed`, `budget`, `digest`. 1 to 6 items. |
| `digestMinutes` | `15–10080` | no | The digest is sent at most once in this many minutes. |
| `maxPerHour` | `1–120` | no | At most this many messages and prompts an hour, the digest not counted. |
| `enabled` | `boolean` | no | False switches the channel off; true switches it on again, from now. |

## Response.

200 OK · JSON object

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X PATCH "https://api.koi.dog/api/v1/notifications/channels/$ID" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "send": [
        "approvals",
        "questions"
      ],
      "digestMinutes": 240
    }'
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/notifications/channels/${process.env.ID}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    send: [
      "approvals",
      "questions",
    ],
    digestMinutes: 240,
  }),
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.patch(
    f"https://api.koi.dog/api/v1/notifications/channels/{os.environ['ID']}",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
    json={
        "send": [
            "approvals",
            "questions",
        ],
        "digestMinutes": 240,
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "kind": "notify",
  "name": "string",
  "send": [],
  "digestMinutes": 0,
  "maxPerHour": 0,
  "state": "active",
  "stateReason": "string",
  "tokenPrefix": "string",
  "consecutiveFailures": 0,
  "lastSuccessAt": "string",
  "lastFailureAt": "string",
  "lastDigestAt": "string",
  "pendingSends": 0,
  …
}
```
