Skip to content

Rotate a webhook signing secret

Calling the rotate-secret endpoint issues a fresh signing secret for an existing webhook and returns the full webhook object with that secret included. Because the secret appears only in this response, the rotation call is also the only moment you can capture it. The endpoint is a POST with no request body, requires the webhooks:write scope, and takes the webhook ID as a path parameter.

What the endpoint does

The request path is /v2/webhooks/{id}/rotate-secret with the POST method. The only path parameter is id, a required string holding the webhook ID. There is no request body. On success the endpoint responds with 200 and a JSON body whose data object is the webhook, now carrying the new secret in the secret field. The secret value follows the whsec_ prefix pattern. The secretPrefix field updates to the first characters of the new secret so you can tell which secret is in use without exposing the full value.

Authorization and scope

Send the API key as a bearer token in the Authorization header. The key must carry the webhooks:write scope. The endpoint also checks the key owner's role, so a key with the right scope can still fail if the owner no longer exists or lacks permission. The Idempotency-Key and X-On-Behalf-Of headers are ignored on this endpoint: a retried rotation creates another secret rather than returning the first result.

The 24-hour dual-signing window

For 24 hours after rotation, every delivery is signed with both the new secret and the previous secret. During that window the VT-Signature header contains two v1 entries. This gives you time to deploy the new secret to your endpoint without dropping deliveries. After the 24 hours elapse, only the new secret is used. Plan the rollout so your verifier accepts either entry during the overlap, then remove the old secret from your configuration once the window closes.

Reading the response

The 200 response wraps a data object. The fields most relevant to rotation are secret, which holds the new signing secret and is returned only when the webhook is created and when the secret is rotated; secretPrefix, which shows the leading characters of the current secret; and updatedAt, which records the change timestamp. The rest of the object describes the webhook itself: webhookId, url, description, events, status, pausedReason, pausedAt, revokedAt, revocationReason, ownerId, lastDelivery, and createdAt. Store the secret securely as soon as the response arrives, because the secret is returned only on creation and rotation.

Error codes and retry behavior

The endpoint documents three specific failures: 403 FORBIDDEN when the key owner no longer exists, 404 WEBHOOK_NOT_FOUND when the webhook ID does not match a webhook, and 409 WEBHOOK_REVOKED when the webhook has been revoked. The shared error envelope also covers 400 validation failures, 401 authentication failures, 429 rate limiting, and 500 internal errors. Because rotation is not idempotent, a retried rotation creates another secret. The previous secret remains valid for the 24-hour dual-signing window, so a retry does not immediately break verification, but it does mean more than one secret is in play during the overlap.

Rotation decision checklist

Use this checklist before and after calling the endpoint:

  • Confirm the webhook status is active; a revoked webhook returns 409 WEBHOOK_REVOKED.
  • Confirm the API key has webhooks:write and that the key owner still exists.
  • Capture the secret from the 200 response immediately and store it in your secrets manager.
  • Update your endpoint verifier to accept both v1 entries in VT-Signature during the 24-hour overlap.
  • Record the new secretPrefix so you can tell the active secret apart from earlier ones.
  • After 24 hours, remove the previous secret from your configuration.
  • If a rotation call times out, remember that a retried call issues another secret because Idempotency-Key is ignored.

Example request

The following cURL example targets a webhook with ID wh_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93. Replace the bearer token with a full vt_live_ key that has the webhooks:write scope. The endpoint returns the webhook object with the new secret in the secret field.

Frequently asked questions

Does rotating the secret invalidate the old one immediately?

No. For 24 hours after rotation, every delivery is signed with both the new and the previous secret, so VT-Signature carries two v1 entries. After that window only the new secret is used.

Can I retrieve the new secret later with a GET request?

The secret is returned only when the webhook is created and when the secret is rotated. Store it securely as soon as the rotation response arrives.

What happens if I retry a rotation call?

The Idempotency-Key and X-On-Behalf-Of headers are ignored on this endpoint, so a retried rotation creates another secret. The previous secret stays valid for the 24-hour dual-signing window.

Why does rotation return 409 WEBHOOK_REVOKED?

The webhook has been revoked. The endpoint reports this as 409 WEBHOOK_REVOKED.

curl -X POST "$API_BASE_URL/v2/webhooks/wh_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93/rotate-secret" \
  -H "Authorization: Bearer "
{
  "data": {
    "webhookId": "wh_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93",
    "url": "https://example.com/vacation-tracker/webhooks",
    "description": "Example post details.",
    "events": [
      "leave.approved",
      "leave.cancelled"
    ],
    "status": "active",
    "pausedReason": null,
    "pausedAt": null,
    "revokedAt": null,
    "revocationReason": null,
    "ownerId": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14",
    "secretPrefix": "whsec_AbCd",
    "secret": "whsec_AbCdEfGhIjKlMnOpQrStUvWxYz0123456789-_AbCd",
    "lastDelivery": null,
    "createdAt": "2026-09-01T08:00:00.000Z",
    "updatedAt": "2026-09-01T08:00:00.000Z"
  }
}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "name": "ValidationError",
    "description": "Example post details.",
    "resolution": "Fix the fields listed in details.fields and send the request again.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
    "details": {
      "fields": [
        {
          "path": "startDate",
          "message": "\"startDate\" is required"
        }
      ]
    }
  }
}
{
  "error": {
    "code": "UNAUTHORIZED",
    "name": "Unauthorized",
    "description": "Example post details.",
    "resolution": "Send a valid API key in the Authorization header as Bearer followed by the full vt_live_ key.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}
{
  "error": {
    "code": "INSUFFICIENT_SCOPE",
    "name": "InsufficientScope",
    "description": "Example post details.",
    "resolution": "Add the scopes listed in details.requiredScopes to the key in the OnlyLeave dashboard.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
    "details": {
      "requiredScopes": [
        "leaves:write"
      ]
    }
  }
}
{
  "error": {
    "code": "WEBHOOK_NOT_FOUND",
    "name": "Webhook not found",
    "description": "Example post details.",
    "resolution": "Check the webhook ID.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}
{
  "error": {
    "code": "WEBHOOK_REVOKED",
    "name": "Webhook revoked",
    "description": "Example post details.",
    "resolution": "Delete the webhook and create a new one.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}
{
  "error": {
    "code": "RATE_LIMITED",
    "name": "RateLimited",
    "description": "Example post details.",
    "resolution": "Wait a few seconds and retry, using the same Idempotency-Key for writes.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}
{
  "error": {
    "code": "INTERNAL_ERROR",
    "name": "InternalError",
    "description": "Example post details.",
    "resolution": "Retry later, and if it keeps happening, contact OnlyLeave support and quote the requestId.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}

id

FieldTypeRequiredDescriptionConstraints
idstringYeswebhook ID.

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataobjectNo
response.data.webhookIdstringYeswebhook ID
response.data.urlstringYesthe HTTPS URL deliveries are sent toFormat: uri
response.data.descriptionstring | nullNoa description to help you recognize the webhook
response.data.description[variant1]stringa description to help you recognize the webhook
response.data.description[variant2]nulla description to help you recognize the webhook
response.data.eventsarray<WebhookEventType>Yesthe event types sent to this webhook
response.data.events[]stringthe event type. webhook.test is sent only by test deliveries and cannot be subscribed to.Allowed values: $72
response.data.statusstringYesactive webhooks receive events; paused and revoked webhooks do notAllowed values: "active" | "paused" | "revoked"
response.data.pausedReasonstring | nullNowhy the webhook is paused. manual means it was paused with the API or the dashboard, delivery-failures means every delivery failed for 72 hours, endpoint-gone means your endpoint returned 410.Allowed values: "manual" | "delivery-failures" | "endpoint-gone" | null
response.data.pausedReason[variant1]stringwhy the webhook is paused. manual means it was paused with the API or the dashboard, delivery-failures means every delivery failed for 72 hours, endpoint-gone means your endpoint returned 410.Allowed values: "manual" | "delivery-failures" | "endpoint-gone" | null
response.data.pausedReason[variant2]nullwhy the webhook is paused. manual means it was paused with the API or the dashboard, delivery-failures means every delivery failed for 72 hours, endpoint-gone means your endpoint returned 410."manual" | "delivery-failures" | "endpoint-gone" | null
response.data.pausedAtstring | nullNoa timestamp in the ISO 8601 format, set while the webhook is pauseddate-time
response.data.pausedAt[variant1]stringa timestamp in the ISO 8601 format, set while the webhook is pauseddate-time
response.data.pausedAt[variant2]nulla timestamp in the ISO 8601 format, set while the webhook is pauseddate-time
response.data.revokedAtstring | nullNoa timestamp in the ISO 8601 format, set when the webhook is revokeddate-time
response.data.revokedAt[variant1]stringa timestamp in the ISO 8601 format, set when the webhook is revokeddate-time
response.data.revokedAt[variant2]nulla timestamp in the ISO 8601 format, set when the webhook is revokeddate-time
response.data.revocationReasonstring | nullNowhy the webhook was revoked"manual" | "owner_permissions_reduced" | "owner_deactivated" | "owner_deleted" | null
response.data.revocationReason[variant1]stringwhy the webhook was revoked"manual" | "owner_permissions_reduced" | "owner_deactivated" | "owner_deleted" | null
response.data.revocationReason[variant2]nullwhy the webhook was revoked"manual" | "owner_permissions_reduced" | "owner_deactivated" | "owner_deleted" | null
response.data.ownerIdstringYesthe ID of the user who owns the webhook. Events are filtered by this user's current permissions.
response.data.secretPrefixstringYesthe first 10 characters of the signing secret, to help you tell secrets apart
response.data.lastDeliveryWebhookLastDelivery | nullNothe most recent delivery, null before the first delivery
response.data.lastDelivery[variant1]objectthe most recent delivery, null before the first delivery
response.data.lastDelivery[variant1].deliveryIdstringYesdelivery ID, the same as the VT-Delivery-Id header
response.data.lastDelivery[variant1].eventNamestringYesthe event type. webhook.test is sent only by test deliveries and cannot be subscribed to.Allowed values: $72
response.data.lastDelivery[variant1].statusstringYesdelivery status. SKIPPED means the webhook was paused, revoked or deleted before the delivery was sent."PENDING" | "RETRYING" | "SUCCEEDED" | "FAILED" | "SKIPPED"
response.data.lastDelivery[variant1].responseStatusintegerNothe HTTP status your endpoint returned on the latest attempt, absent when no response was received
response.data.lastDelivery[variant1].atstringYesa timestamp in the ISO 8601 format of the latest attemptdate-time
response.data.lastDelivery[variant2]nullthe most recent delivery, null before the first delivery
response.data.createdAtstringYesa timestamp in the ISO 8601 formatdate-time
response.data.updatedAtstringYesa timestamp in the ISO 8601 formatdate-time
response.data.secretstringYesthe signing secret. Returned only when the webhook is created and when the secret is rotated; store it securely.

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo