Webhook verification
This guide walks through verifying the webhooks Latitude sends to your endpoint. Latitude signs every webhook with the Standard Webhooks scheme, so you can confirm that it came from Latitude. You’ll learn how to get a signing secret, verify each webhook, handle retries, and rotate your secret without failing any deliveries.
Summary
The high-level steps are as follows:
- Get a signing secret for your webhook subscription and store it securely
- Verify the signature of every webhook
- Respond with a
2xxstatus, and usewebhook-idto ignore duplicate deliveries - Rotate the signing secret when needed, without failing any deliveries
Detailed Steps
Step 1: Get a signing secret
Each webhook subscription has its own signing secret: whsec_ followed by a Base64 string. It is returned only once, so store it securely. If you lose it, add a new one as described in Step 4.
a) New subscriptions
Creating a subscription also creates one secret and returns it as signing_secret in the response.
Request:
Response:
b) Existing subscriptions
Subscriptions created before webhook signing was available (11/18/2026) will send unsigned webhooks until you add a secret. To add one, call POST /v1/webhook_subscriptions/{id}/signing_secrets. Immediately after secret creation, the next webhook delivered will be signed.
Step 2: Verify every webhook
Each signed webhook includes these headers:
Using a Standard Webhooks library (recommended)
The Standard Webhooks libraries will verify the signature for you, and are available for most languages. Pass the secret exactly as Latitude returned it, including the whsec_ prefix.
JavaScript
Python
Ruby
Libraries are also available for C#, Elixir, Go, Java, PHP and Rust.
Verifying without a library
If you can’t use a library, compute the signature yourself using the Standard Webhooks signature scheme:
Compare your signature with each v1, entry in the webhook-signature header using a constant-time comparison, and check that the timestamp is recent. See verifying signatures for the full list of checks.
Step 3: Respond and handle retries
Respond with any 2xx status within 10 seconds to acknowledge a webhook. If your endpoint returns another status, times out or can’t be reached, Latitude retries the delivery up to 5 times. A retried delivery for the same event will have the same webhook-id header.
Step 4: Rotate your signing secret
In order to support secret rotation, a subscription can have at most 2 active secrets at once. Having 2 lets you switch to a new secret, while still supporting the orginial secret for a period of up to 24 hours. While both are active, Latitude signs every webhook with each secret and sends both signatures in the webhook-signature header, newest first:
A webhook is valid if any one of its signatures matches, so it verifies with either secret.
To rotate, add a new secret with POST /v1/webhook_subscriptions/{id}/signing_secrets. The new secret becomes the current secret and never expires. The previous secret keeps signing for expire_previous_in seconds, which is an optional field in the request for a new secret. It must be between 0 (expire now) and 86400 (24 hours), and defaults to 86400.
For example, this request adds a new secret at 09:00 UTC, and the old secret expires 12 hours later, at 21:00 UTC.
Request:
Response:
Example rotation
Here is the webhook-signature header during that rotation:
Replacing a leaked secret
Add a new secret with expire_previous_in set to 0. Your previous secret stops signing immediately, so deploy the new secret as soon as possible. Otherwise, webhooks will fail verification with the old secret until the new secret is implemented into your verification.
Number of secrets
A subscription can’t have more than 2 active secrets. To create a new secret when you have 2 active secrets for a subscription, you need to call POST /v1/webhook_subscriptions/{id}/signing_secrets, with expire_previous_in set to 0. This will immediately expire the 2 old secrets, and all new webhooks will be signed with the secret returned from the request. If expire_previous_in is not set to 0, a 422 error code will be returned, and no new secret will be created.

