Anyone who knows a webhook address can call it. An HMAC signature therefore adds a check code to every message, calculated from the message content and a secret key. The receiving system recalculates it and processes the message only if the codes match.
What is a webhook signature
A webhook is a message one system sends to another when an event happens – for example a new order from a marketplace. So that the recipient knows the message is genuine, the sender signs it:
- The sender and the recipient share a secret signing key.
- From the message content and the key, the sender calculates an HMAC (Hash-based Message Authentication Code), most often with the SHA-256 algorithm.
- It sends the signature in a header together with the message.
- The recipient calculates the signature again from the received message and its own key and compares it with the header.
If the signatures differ, someone has forged or altered the message – and it is not processed.
Why a timestamp
A timestamp (the time of sending) is added to the signature. The string that is signed is "timestamp.body". This lets the recipient reject old messages that someone might have intercepted and sent again (a replay attack) – for example anything older than 5 minutes.
How to verify the signature
Messages from Sortyra come with:
- the
x-sortyra-timestampheader – the timestamp in seconds, - the
x-sortyra-signatureheader – the signature in the formsha256=<hex>.
How to verify:
- Take the raw body of the message exactly as it arrived (before any JSON processing).
- Join it into the string
timestamp.body. - Calculate HMAC-SHA256 with the signing key and write the result in hexadecimal with the prefix
sha256=. - Compare it with the header using a constant-time comparison function.
- Check that the timestamp is not too old.
What to watch out for
- The key is secret. Do not store it in public code or send it by email.
- Sign the raw body. If you parse the JSON and serialise it again, the order or whitespace changes and the signature will not match.
- Use https only.
How Sortyra helps
Sortyra signs alert webhooks as well as marketplace orders sent to the Shop URL for orders. The signing key is shown only once, when it is created – pass it on to whoever manages your shop. See Marketplaces: connection, offers, orders and Alerts.
Related terms
Frequently asked questions
What if I lose the signing key?
The key is shown only once and we cannot show it again. For alert webhooks, add a new channel, which gets a new key; for marketplace orders, write to us via the contact page.
Isn't a secret webhook address enough?
No. The address can turn up in logs or in a browser. The signature verifies the content of every message and also protects it against tampering.