Rotate a Webhook subscription's secret
POST /v1/webhooks/{webhook_id}/rotate-secret
| Property | Value |
|---|---|
| Operation | rotate_webhook_secret |
| Group | Webhooks |
| Scope | webhooks:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited webhooks.subscription.rotate_secret (mutation) |
| Released in | 1.63.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Mints a new secret and answers it once (1.63.0, FR-webhooks-5). The previous secret keeps signing for previous_secret_expires_in_s, 86,400 by default and at most 604,800 (targets), and every delivery of that window carries two v1 values, the new one first; a rotation inside the window retires the oldest secret. From 1.64.0, stated as the api built it: a request repeated under the same Idempotency-Key by the same credential answers the stored answer with the secret again while it is still the subscription's current secret, and writes the Audit event webhooks.subscription.secret_read; once the subscription is deleted the repeat is not_found, and once the secret is rotated it is 409 idempotency_key_reused, the secret never shown again.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the webhooks:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/webhooks/whk_.../rotate-secret" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'const response = await fetch(`${process.env.VOCAL_API}/v1/webhooks/whk_.../rotate-secret`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/webhooks/whk_.../rotate-secret",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
webhook_id | path | WebhookId | yes | The id of a Webhook subscription: whk_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log. |
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: WebhookSecretRotationRequest.
| Field | Type | Required | Description |
|---|---|---|---|
previous_secret_expires_in_s | integer | no | How long the current secret keeps signing beside the new one: 86,400 when omitted, at most 604,800 (targets); 0 retires it at once. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | WebhookSecretRotation | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is WebhookSecretRotation.
| Field | Type | Required | Description |
|---|---|---|---|
object | "webhook_secret_rotation" | yes | |
previous_secret_expires_at | Timestamp or null | yes | Until when each delivery also carries a v1 signature under the previous secret, the new one first; null when it was retired at once. |
secret | WebhookSecret | yes | The new secret, shown in this answer only. |
secret_hint | string | yes | |
webhook_id | WebhookId | yes |