Verify a webhook (signature)
1 min read
Every webhook message is signed, so you can prove it comes from DanskAdresseAPI and isn't forged.
When you create a webhook, you get a secret key that starts with whsec_. It's shown only once. Here's how your server verifies a message:
- Read the
X-Addr-Signatureheader. It looks like this:t=1727690000,v1=5f2c…—tis a Unix timestamp,v1is the signature. - Compute an HMAC-SHA256 (hex) of the string
t+.+ the raw request body yourself, using your whole secret (includingwhsec_) as the key. - Compare your computed value with
v1from the header — use a constant-time comparison (e.g.timingSafeEqual). - If they match, the message is genuine. Otherwise: reject it. It's a good idea to also check that
tis recent, so old messages can't be replayed.
Store your secret safely (like a key), and always reject messages whose signature doesn't match. If you lose it, you'll need to create a new webhook. You'll find a code example under Verify the signature on the Webhooks page.
Was this helpful?
