Skip to main content
Anyone who knows your endpoint URL can send a request to it. The signature proves that the event came from Routa and that the body was not modified. Always verify it before you process the event.

The header

The signature is computed like this:

How to verify

1

Read the raw body

Use the bytes exactly as they arrived. If you parse and serialize the JSON again, the bytes change and the signature does not match.
2

Check the timestamp

Reject the delivery if t is more than 5 minutes away from the current time. This protects against a captured request being replayed.
3

Compute the HMAC

Compute the HMAC-SHA256 of "{t}.{raw_body}" with the endpoint secret.
4

Compare in constant time

Compare with each v1 value of the header using a constant-time comparison. One match is enough.

With the SDK

constructEvent does all of this, makes no network calls and returns the typed event.
See more in Webhooks in the SDK.

Without the SDK

Never compare signatures with ==. A comparison that stops at the first different byte lets someone find the correct signature by timing your responses.

Secret rotation

To change the secret without losing events, call POST /v1/webhook_endpoints/{id}/rotate_secret. The response carries the new secret.
  • For 24 hours, both secrets (the new one and the previous one) sign deliveries, and the header carries two v1= values.
  • During that time, validate with both secrets. The SDK accepts a list: constructEvent(rawBody, header, [newSecret, previousSecret]).
  • After the window, the old secret stops being valid.

Common problems

It is almost always the body: a middleware already parsed the JSON and you are using its serialization. Configure your framework to expose the raw body on the webhook route (express.raw({ type: 'application/json' }), for example).
Check that you use the secret of the right endpoint. Each one has its own. Also check that the server clock is synchronized, since the tolerance is 5 minutes.
Validate with both the new secret and the previous one until the 24-hour window ends.