Signature Verification
Every webhook delivery includes an HMAC-SHA256 signature in the X-BitByBit-Webhook-Signature header. Always verify this signature to ensure the request is genuinely from bitbybit.
t — Unix timestamp when the signature was generated
v1 — HMAC-SHA256 hex digest
How to Verify
The signature is computed as:
Node.js
The signature is computed over the raw request body bytes, exactly as received. A re-serialized JSON object (for example JSON.stringify(req.body) after express.json()) can produce different bytes and fail verification. Capture the raw body before parsing — in Express, use express.raw({ type: 'application/json' }).
Python
Replay Attack Prevention
Always check the t (timestamp) value in the signature header. Reject any webhook where the timestamp is more than 5 minutes old. This prevents replay attacks where an attacker resends a previously captured webhook request.
Secret Rotation
You can rotate your signing secret at any time from Settings > Developer > Webhook Details > Rotate. When you rotate:
- A new signing secret is generated immediately
- The old secret is invalidated
- All subsequent deliveries use the new secret
- You must update your verification code with the new secret
Rotating a secret takes effect immediately. Make sure to update your server before rotating to avoid rejecting valid webhooks.