HMAC Secret Keys
To enable HMAC, please reach out to us. We will enable it and securely send you two secret keys:- CURRENT: The active secret used to sign webhook messages.
- NEXT: The upcoming secret that will replace CURRENT if a secret key rotation should happen.
Verifying the HMAC Signature
Each webhook request includes theX-HMAC-SHA512-Signature header, which contains the base64-encoded HMAC signature of the request’s payload.
To verify the signature:
- Retrieve the Signature and Payload
- Extract
X-HMAC-SHA512-Signaturefrom the request headers. - Extract the raw request body (as a string).
- Extract
- Compute and verify the signature with the CURRENT secret key
- Compute an HMAC signature of the request body using SHA-512 and the CURRENT secret key.
- Convert the computed signature to a base64-encoded string.
- Compare it with the received
X-HMAC-SHA512-Signatureheader. If they match, the request is valid. If not, compute the HMAC signature with the NEXT secret key. If it still doesn’t match, the request should be rejected.
Sample implementation
Javascript
Java
Key Rotation Process
Here is the process for rotating keys:- On our side we sign the payload with NEXT instead of CURRENT. Your system continues working since you verify with both secrets.
- We generate a new NEXT secret and securely send it to you. CURRENT takes the value of NEXT and NEXT gets the new value you received from us.