Prompt
What should I use for webhook signing and verification?
Latest observation
Nov 20, 2026
OpenAI APIWeb search: off
For webhook signing and verification, the standard choice is:
Use an HMAC with SHA-256
- Signing algorithm:
HMAC-SHA256 - Shared secret: a strong random secret known only to the sender and receiver
- Payload: the exact raw request body
- Header: send the signature in a custom header, e.g.
X-Signature
Recommended pattern
- Sender computes:
signature = HMAC_SHA256(secret, raw_body)
- Sender includes:
X-Signature: <hex-or-base64 signature>
- Receiver:
- reads the raw body exactly as received
- recomputes HMAC with the same secret
- compares signatures using a constant-time comparison
Best practices
- Do not use plain hashes like SHA-256 alone; they are not keyed and don’t prove authenticity.
- Use HTTPS always, but don’t rely on HTTPS alone for webhook authenticity.
- Include a timestamp and/or nonce to prevent replay attacks.
- Rotate secrets periodically if possible.
- Reject old timestamps if you include one, e.g. older than 5 minutes.
- Verify before parsing/acting on the payload.
If you want a practical convention
A common format is:
X-Webhook-Timestamp: <unix timestamp>X-Webhook-Signature: v1=<HMAC-SHA256(timestamp + "." + raw_body)>
This makes replay protection easier.
If you want, I can also show you a concrete implementation in Python, Node.js, Go, or Java.