---
title: "Rotate a webhook secret"
description: "Generates a new signing secret. The new secret takes effect immediately, so update your server right away to avoid failed verifications."
---

**POST** `https://api.respan.ai/api/webhooks/{id}/rotate/`

Generates a new signing secret. The new secret takes effect immediately, so update your server right away to avoid failed verifications.

## Servers

`https://api.respan.ai`: Respan API Server

## Authentication

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


## Path parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| `id` | `integer` | Required | Webhook ID.<br />Example: `25` |


## Examples

### Rotate a webhook secret

#### Headers


```json
{
  "Authorization": "Bearer YOUR_RESPAN_API_KEY"
}
```


#### Path parameters


```json
{
  "id": 25
}
```


#### Response


```json
{
  "body": {
    "id": 25,
    "name": "Log sink",
    "secrets": "whsec_9b1c...",
    "message": "Secret rotated successfully. Update your server immediately."
  }
}
```


## Responses

### 200

The new secret.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `id` | `integer` | Required in parent | - |
| `name` | `string` | Required in parent | - |
| `secrets` | `string` | Required in parent | The new signing secret. |
| `message` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "id",
    "name",
    "secrets",
    "message"
  ],
  "properties": {
    "id": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "secrets": {
      "type": "string",
      "description": "The new signing secret."
    },
    "message": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "id": 25,
  "name": "Log sink",
  "secrets": "whsec_9b1c...",
  "message": "Secret rotated successfully. Update your server immediately."
}
```


### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 404

No webhook with that ID in this project.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Optional | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "No Webhook matches the given query."
}
```


## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Rotate a webhook secret",
  "operationId": "rotateWebhookSecret",
  "tags": [
    "Webhooks"
  ],
  "description": "Generates a new signing secret. The new secret takes effect immediately, so update your server right away to avoid failed verifications.",
  "parameters": [
    {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
        "type": "integer"
      },
      "description": "Webhook ID.",
      "example": 25
    }
  ],
  "responses": {
    "200": {
      "description": "The new secret.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "id",
              "name",
              "secrets",
              "message"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "secrets": {
                "type": "string",
                "description": "The new signing secret."
              },
              "message": {
                "type": "string"
              }
            }
          },
          "example": {
            "id": 25,
            "name": "Log sink",
            "secrets": "whsec_9b1c...",
            "message": "Secret rotated successfully. Update your server immediately."
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "404": {
      "description": "No webhook with that ID in this project.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "No Webhook matches the given query."
          }
        }
      }
    }
  },
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "x-fern-examples": [
    {
      "name": "Rotate a webhook secret",
      "headers": {
        "Authorization": "Bearer YOUR_RESPAN_API_KEY"
      },
      "path-parameters": {
        "id": 25
      },
      "response": {
        "body": {
          "id": 25,
          "name": "Log sink",
          "secrets": "whsec_9b1c...",
          "message": "Secret rotated successfully. Update your server immediately."
        }
      }
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
