VocalDocscontracts 1.65.0

Rotate a Webhook subscription's secret

POST /v1/webhooks/{webhook_id}/rotate-secret

PropertyValue
Operationrotate_webhook_secret
GroupWebhooks
Scopewebhooks:write
Route classcontrol
IdempotencyIdempotency-Key accepted: a retry with the same key replays the first answer
AuditAudited webhooks.subscription.rotate_secret (mutation)
Released in1.63.0
Phase 0 hostServed (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 '{}'

Parameters

NameInTypeRequiredDescription
webhook_idpathWebhookIdyesThe id of a Webhook subscription: whk_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log.
idempotency-keyheaderstringnoA 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.

FieldTypeRequiredDescription
previous_secret_expires_in_sintegernoHow 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

StatusContent typeShapeError codes
200application/jsonWebhookSecretRotation
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden, org_suspended
404application/jsonErrorEnvelopenot_found
409application/jsonErrorEnvelopeidempotency_in_progress, idempotency_key_reused
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 200 answer

The shape is WebhookSecretRotation.

FieldTypeRequiredDescription
object"webhook_secret_rotation"yes
previous_secret_expires_atTimestamp or nullyesUntil when each delivery also carries a v1 signature under the previous secret, the new one first; null when it was retired at once.
secretWebhookSecretyesThe new secret, shown in this answer only.
secret_hintstringyes
webhook_idWebhookIdyes