Skip to main content

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.

Signature Format

  • 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

Go

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:
  1. A new signing secret is generated immediately
  2. The old secret is invalidated
  3. All subsequent deliveries use the new secret
  4. 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.