# Change a webhook endpoint

> Send only the fields to change: `url`, `name`, `events`, `format` or `enabled`.

Source: https://docs.spicrawl.com/api-reference/webhooks/webhooks-update

## PATCH /v1/webhooks/{webhookID}

Operation ID: `webhooksUpdate`. API key scope: `webhooks`.

Send only the fields to change: `url`, `name`, `events`, `format` or `enabled`. Any other field is a 400.
The signing secret does not change here; use `rotate-secret`.

Setting `enabled` to `true` also clears `disabled_reason` and resets `consecutive_failures` to 0. An
endpoint is disabled automatically after 100 consecutive failed deliveries; re-enable it only once the
receiver is fixed.

### Example

```bash
curl -X PATCH "https://api.spicrawl.com/v1/webhooks/{webhookID}" \
  -H "Authorization: Bearer $SPICRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled":true}'
```

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `webhookID` | path | string | yes | The endpoint `id` returned by `POST /v1/webhooks`. An id of another organization answers 404. |

### Request body

`application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string (uri) | no |  |
| `name` | string | no |  |
| `events` | array of string: `batch.completed`, `batch.failed`, `monitor.changed`, `monitor.failed` (`WebhookEvent`) | no |  |
| `format` | string: `json`, `slack`, `discord` | no | Body shape. `json` is the signed JSON document. `slack` posts `{"text": summary}` and `discord` posts `{"content": summary}` (at most 2,000 characters) for incoming-webhook URLs. Signature headers are sent in every format. |
| `enabled` | boolean | no |  |

Example `reenable`: Re-enable after fixing the receiver

```json
{
  "enabled": true
}
```

### Responses

#### 200

The endpoint after the change.

Headers: `X-Request-Id`.

`application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | Endpoint id. Use it in the `webhookID` path parameter and as `webhook_endpoint_id` on a batch. |
| `name` | string \| null | no |  |
| `url` | string (uri) | yes | HTTPS URL that receives the deliveries. |
| `events` | array of string: `batch.completed`, `batch.failed`, `monitor.changed`, `monitor.failed` (`WebhookEvent`) | yes |  |
| `format` | string: `json`, `slack`, `discord` | yes | Body shape. `json` is the signed JSON document. `slack` posts `{"text": summary}` and `discord` posts `{"content": summary}` (at most 2,000 characters) for incoming-webhook URLs. Signature headers are sent in every format. |
| `enabled` | boolean | yes | False once the endpoint was disabled, by a failure streak or by `enabled: false`. |
| `disabled_reason` | string \| null | no | Why the endpoint is disabled, when it is. Null while enabled. |
| `consecutive_failures` | integer | yes | Failed deliveries in a row. Reset by a success, and by re-enabling. At 100 the endpoint is disabled. |
| `last_success_at` | string \| null (date-time) | no |  |
| `last_failure_at` | string \| null (date-time) | no |  |
| `secret_version` | integer | yes | Starts at 1 and goes up by one on each rotation. Also the `kid` in signature headers. |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |

#### 400

The request is invalid. Not retryable; fix the request using `code` and `diagnostics.hint`.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 401

Missing, invalid, revoked or expired key. Not retryable with the same key.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 403

The key lacks the scope this route requires (`ERR::AUTH::INSUFFICIENT_SCOPE`), or the action is not permitted.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 404

No such resource for this key's organization.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

#### 500

Internal error. Retryable when `retryable` is true.

Headers: `X-Request-Id`.

`application/problem+json` (`Problem` schema).

Full OpenAPI spec: https://docs.spicrawl.com/openapi.yaml
