---
title: "Rotate Webhook Secret"
description: "Generates and returns a new HMAC secret for generic webhooks."
---

> Documentation Index
> Fetch the complete documentation index at: https://staging.threadapi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

Path: ThreadAPI API › Monitors

`POST /v1/monitors/{id}/rotate-secret`

Generates and returns a new HMAC secret for generic webhooks.

## Authentication

Requires one of the following:

- `bearerAuth`, http, header `Authorization`
- `apiKeyAuth`, apiKey, in header, header `x-api-key`

## Path parameters

- `id` (`rotateMonitorSecret.path.id`; string, required)

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.threadapi.dev/v1/monitors/<id>/rotate-secret' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.threadapi.dev/v1/monitors/<id>/rotate-secret';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.threadapi.dev/v1/monitors/<id>/rotate-secret"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
```

## Responses

### 200

New secret

#### Example

```json
{
  "webhook_secret": "string"
}
```

- `webhook_secret` (`rotateMonitorSecret.response.200.webhook_secret`; string, optional)

### 401

Missing or invalid API key or OAuth access token

#### Example

```json
{
  "error": "unauthorized: missing or invalid credentials",
  "error_code": "insufficient_credits"
}
```

One of:

- `ErrorResponse`
- `Error`

### 404

Requested user or resource not found

#### Example

```json
{
  "error": "unauthorized: missing or invalid credentials",
  "error_code": "insufficient_credits"
}
```

One of:

- `ErrorResponse`
- `Error`


Source: https://staging.threadapi.dev/api/Monitors/rotateMonitorSecret/index.md
