# Update Alert Webhook

## Update Webhook

The Update Webhook endpoint allows customers to modify an existing webhook configuration, including its URL, secret, description, and enabled status. Since webhooks and alerts are now managed separately, you cannot modify alert rules through this endpoint.

### Authentication

Include the following headers in your requests:

```
Access-Token: <your-access-token>
```

### Permissions

Ensure your API user has a role with `admin` or `edit-alert-webhook-endpoint` permission.

### Endpoint

* **URL**: `https://api.genlogs.io/alerts/webhook/{webhook_id}`
* **Method**: `PATCH`

### URL Parameters

| Parameter    | Type          | Required | Description                                                  |
| ------------ | ------------- | -------- | ------------------------------------------------------------ |
| `webhook_id` | string (UUID) | Yes      | The unique identifier of the webhook configuration to update |

### Request Body

All fields are optional. Only provide the fields you want to change.

| Field         | Type    | Required | Description                                               |
| ------------- | ------- | -------- | --------------------------------------------------------- |
| `webhook_url` | string  | No       | The new HTTPS endpoint URL                                |
| `secret`      | string  | No       | The new secret key (minimum 16 characters)                |
| `description` | string  | No       | The new description                                       |
| `enabled`     | boolean | No       | Set to `true` to enable or `false` to disable the webhook |

#### Field Requirements

* **webhook\_url**: Must be a valid HTTPS URL if provided. Cannot be a URL already registered by this customer.
* **secret**: Must be at least 16 characters long if provided.
* **enabled**: When set to `false`, the webhook will not receive any notifications until re-enabled.

#### Generating a New Secret

If you need to update your webhook secret, refer to the secret generation commands from the Create Webhook documentation.

### Response Codes

| Code                        | Description                                                                    |
| --------------------------- | ------------------------------------------------------------------------------ |
| `200 OK`                    | Successfully updated the webhook configuration                                 |
| `400 Bad Request`           | Missing or invalid parameters (e.g., URL already registered, secret too short) |
| `401 Unauthorized`          | Authentication credentials missing or incorrect                                |
| `403 Forbidden`             | User lacks permission to update webhook configurations                         |
| `404 Not Found`             | Webhook configuration with the specified ID was not found                      |
| `500 Internal Server Error` | Server error occurred                                                          |

### Response Body

The response body has the same structure as the Create Webhook endpoint response, reflecting the updated data.

| Field         | Type              | Description                                      |
| ------------- | ----------------- | ------------------------------------------------ |
| `id`          | string (UUID)     | Unique identifier for the webhook configuration  |
| `webhook_url` | string            | The URL where notifications will be sent         |
| `description` | string\|null      | The description for the webhook                  |
| `enabled`     | boolean           | Indicates if the webhook is active               |
| `created_at`  | string (datetime) | ISO timestamp when the configuration was created |

### Request Examples

```bash
curl -L \
  --request PATCH \
  --url 'https://api.genlogs.io/alerts/webhook/{webhook_id}' \
  --header 'Access-Token: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "webhook_url": "https://example.com",
    "secret": "text",
    "description": "text",
    "enabled": true
  }'
```

## Update Webhook

> Update webhook settings

```json
{"openapi":"3.1.0","info":{"title":"Alert API","version":"0.0.1"},"security":[{"APIKeyHeader":[]}],"components":{"securitySchemes":{"APIKeyHeader":{"type":"apiKey","description":"JWT Access Token required for authentication","in":"header","name":"Access-Token"}},"schemas":{"WebhookSettingsUpdateSchema":{"properties":{"webhook_url":{"anyOf":[{"type":"string","maxLength":2083,"minLength":1,"format":"uri"},{"type":"null"}],"title":"Webhook Url"},"secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Secret"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"enabled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Enabled"}},"additionalProperties":false,"type":"object","title":"WebhookSettingsUpdateSchema","description":"Schema for updating webhook settings"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/alerts/webhook/{webhook_id}":{"patch":{"tags":["Webhook Alerts"],"summary":"Update Webhook","description":"Update webhook settings","operationId":"update_webhook_alerts_webhook__webhook_id__patch","parameters":[{"name":"webhook_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Webhook Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookSettingsUpdateSchema"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

###
