> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voyantcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rotate Webhook Secret

> Generate a new signing secret for a webhook subscription.

## Method

`POST` `/v1/webhooks/subscriptions/:id/rotate-secret`

## Path Parameters

<ParamField path="id" type="uuid" required>Webhook subscription ID.</ParamField>

## Headers

<ParamField header="Authorization" type="string">Bearer token (requires `webhooks:write`).</ParamField>

## Request Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.voyantcloud.com/v1/webhooks/subscriptions/whsub_01J0J3Y3TFX2V22Y7DQ0A6J5G5/rotate-secret" \
    -H "Authorization: Bearer $VOYANT_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const id = "whsub_01J0J3Y3TFX2V22Y7DQ0A6J5G5"
  const res = await fetch(
    `https://api.voyantcloud.com/v1/webhooks/subscriptions/${id}/rotate-secret`,
    {
      method: "POST",
      headers: { Authorization: `Bearer ${process.env.VOYANT_API_KEY}` },
    },
  )
  const { data } = await res.json()
  // Persist data.secret securely and update your HMAC verification logic
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.post(
    "https://api.voyantcloud.com/v1/webhooks/subscriptions/whsub_01J0J3Y3TFX2V22Y7DQ0A6J5G5/rotate-secret",
    headers={"Authorization": f"Bearer {os.environ['VOYANT_API_KEY']}"},
  )
  rotation = resp.json()["data"]
  ```
</RequestExample>

## Response Example

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "secret": "52a2e84247a064d7a2d91b0f4d12d8a22a9fc68bfb9984f0b1d03cc9093f02eb",
      "subscription": {
        "id": "whsub_01J0J3Y3TFX2V22Y7DQ0A6J5G5",
        "workspace_id": "ws_4a82d5bd-3330-4ad3-bf46-1b6a9a5d5d6a",
        "url": "https://example.com/webhooks/voyant",
        "events": ["product.*", "booking.created"],
        "active": true,
        "max_retries": 5,
        "headers": {"X-Env": "production"},
        "description": "Primary catalog listener",
        "created_at": "2025-03-01T09:12:33.000Z",
        "updated_at": "2025-03-15T12:05:22.000Z",
        "last_delivery_at": "2025-03-15T11:59:10.000Z",
        "failure_count": 0
      }
    }
  }
  ```

  ```json 404 Not Found theme={null}
  { "error": "Webhook subscription not found" }
  ```
</ResponseExample>

<Warning>
  Rotating the secret invalidates the old key immediately. Update your webhook consumer before triggering new events to avoid signature mismatches.
</Warning>
