# Update webhook

> Replaces the webhook's URL, event subscription and key scoping. The signing secret is unchanged.

`PUT /webhook/{id}`

**Auth:** API key or OAuth token

## Path parameters

- `id` (required, string) — The webhook to update. Example `"whk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.

## Request body

- `enabled` (required, boolean) — Whether the webhook is enabled. When disabled, no events will be sent to the webhook.
- `events` (required, array | string) — The events to send to the webhook. When 'all', all events will be sent to the webhook. One of: `"all"`.
- `url` (required, string) — The URL to send the webhook to. Must be a valid URL.
- `apiKeyIds` (string[] | null) — API keys this webhook is scoped to. When empty or null, every API key delivers to it. ≤ 1000 items.
- `oauthEnabled` (boolean) — Whether tasks authenticated with OAuth (playground and CLI sessions) deliver to this webhook.

## Response

### 200 — Webhook updated

- `data` (required, object)
  - `apiKeyIds` (required, string[] | null)
  - `enabled` (required, boolean)
  - `events` (required, string[] | null)
  - `id` (required, string)
  - `oauthEnabled` (required, boolean)
  - `url` (required, string)

```json
{
  "data": {
    "apiKeyIds": [
      "string"
    ],
    "enabled": false,
    "events": [
      "all"
    ],
    "id": "string",
    "oauthEnabled": false,
    "url": "string"
  }
}
```

## Request samples

### cURL

```bash
curl -X PUT https://api.mynth.io/webhook/whk_01KE7XWWEQ4MCGWKBQKJ1G47RP \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": false,
    "events": "all",
    "url": "string"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/webhook/whk_01KE7XWWEQ4MCGWKBQKJ1G47RP", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "enabled": false,
    "events": "all",
    "url": "string"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
