# Change a webhook endpoint, or switch it on or off.

> Switching a disabled endpoint on starts it from now; events from the time it was off are not sent.
> https://koi.dog/docs/api/webhooks/update-webhook/

`PATCH /api/v1/webhooks/{id}` · Scope: `config`

When an API key calls it, the timeline records who did what and the outcome. No query parameters.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The webhook endpoint's id. |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | `string` | no | Where deliveries are POSTed: https, and not a private address. At most 2000 characters. A URL. |
| `description` | `string` | no | A note for you; Koidog does not use it. At most 200 characters. |
| `events` | `array` | no | Which events to send. Each entry is `*` (every event), an event kind such as `run.started`, or a prefix ending in `.*` that matches at least one kind, such as `run.*`. `webhook.test` is also taken. Anything else is refused with `422 validation_failed`. 1 to 50 items. |
| `projectId` | `string \| null` | no | Only events of this project's crews. Events that belong to no crew are then not sent. At least 5 characters. |
| `enabled` | `boolean` | no | Off: the endpoint is saved but nothing is sent. |

## Response.

200 OK: a `Webhook`. The example has placeholder values.

- **422 validation_failed**: The body does not match its schema; each problem is in `details`.

## Request.

```sh
curl -X PATCH "https://app.koi.dog/api/v1/webhooks/$ID" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{}'
```

```js
const res = await fetch(`https://app.koi.dog/api/v1/webhooks/${process.env.ID}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({}),
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.patch(
    f"https://app.koi.dog/api/v1/webhooks/{os.environ['ID']}",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
    json={},
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "url": "string",
  "urlShortened": false,
  "description": "string",
  "events": [],
  "projectId": "string",
  "enabled": false,
  "disabledReason": "string",
  "disabledAt": "string",
  "secretPrefix": "string",
  "consecutiveFailures": 0,
  "lastSuccessAt": "string",
  "lastFailureAt": "string",
  "createdAt": "string"
}
```
