
# Update a webhook endpoint

`PATCH /v1/webhook-endpoints/{endpoint_id}` · permission `webhook-endpoints:write` · all plans

Changes an endpoint with a JSON merge patch (RFC 7396, `Content-Type: application/merge-patch+json`). `If-Match` is required; the current value is the `ETag` header of [Get a webhook endpoint](get.md). A patch that changes nothing writes nothing and keeps the version.

- `status` accepts only `enabled` and `disabled_by_user`. Setting `enabled` counts against the plan's enabled-endpoint limit and clears `failing_since`; this is how an endpoint disabled after failures or by its receiver is re-enabled.
- `null` clears `description` and `event_schema_versions` (or one entry: `{"event_schema_versions": {"user.created": null}}`); on any other field it is `422 invalid`.
- `event_types` is replaced as a whole.

## Request

| Field | Type | Required | Description |
|---|---|---|---|
| `endpoint_id` | path | yes | Webhook endpoint ID (`whe_…`). |
| `If-Match` | header | yes | Current `ETag` of the endpoint (`*` matches any version). |
| `key`, `url`, `description`, `event_types`, `event_schema_versions`, `payload_mode`, `rate_limit_per_second` | | no | As in [Add a webhook endpoint](create.md). |
| `status` | string | no | `enabled` or `disabled_by_user`. |

```json
{
  "status": "enabled",
  "event_types": ["user.created", "user.updated", "user.deleted"]
}
```

## Response

`200 OK` with the endpoint (as in [Get a webhook endpoint](get.md)) and its new `ETag`.

## Errors

| HTTP | code | When |
|---|---|---|
| 400 | `malformed_request` | The body is not a JSON object. |
| 400 | `unknown_field` | The patch has a field that is not listed above. |
| 403 | `quota_exceeded` | `status: enabled` would exceed the plan's number of enabled endpoints. |
| 404 | `not_found` | No such endpoint in this environment. |
| 409 | `conflict` | Another endpoint of the environment has this `key`. |
| 412 | `precondition_failed` | `If-Match` does not match the current version (the endpoint changed since you read it). |
| 422 | `validation_failed` | A field is invalid (pointers as in [Add a webhook endpoint](create.md)); `/status invalid` for a status other than `enabled` or `disabled_by_user`. |
| 428 | `precondition_required` | `If-Match` is missing. |
| 401 | `unauthenticated` | The credential is missing, invalid or revoked. |
| 403 | `insufficient_permissions` | The credential lacks `webhook-endpoints:write`. |
| 503 | `service_unavailable` | Webhook administration is temporarily unavailable; retry after the `Retry-After` period. |

## Example

```bash
curl -X PATCH https://api.eu.keenauth.com/v1/webhook-endpoints/whe_01k8a3m5q7t9v1w3x5y7z9b2c4 \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/merge-patch+json" \
  -H 'If-Match: "3"' \
  -d '{"status":"enabled"}'
```

CLI: `keenauth webhook-endpoints update whe_01k8a3m5q7t9v1w3x5y7z9b2c4 --status enabled --if-match '"3"'`
