post
https://example.com/
Verifying signatures
- Base64-decode the
signature_keyreturned on subscription creation (standard alphabet, no=padding) to get the raw key bytes. - Compute HMAC-SHA256 over the raw request body bytes exactly as received. Do not re-serialize the JSON.
- Hex-encode the result in lowercase (64 characters). Do not Base64-encode it.
- Compare it with the
X-Spoton-Webhook-Signatureheader using a constant-time comparison.
Java (17+)
byte[] key = Base64.getDecoder().decode(signatureKey);
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(key, "HmacSHA256"));
String expected = HexFormat.of().formatHex(mac.doFinal(rawBody));
boolean valid = MessageDigest.isEqual(
expected.getBytes(StandardCharsets.US_ASCII),
signatureHeader.getBytes(StandardCharsets.US_ASCII));Node.js
const crypto = require('crypto');
const key = Buffer.from(signatureKey, 'base64');
const expected = crypto.createHmac('sha256', key).update(rawBody).digest('hex');
const valid = expected.length === signatureHeader.length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signatureHeader));Python
import base64, hashlib, hmac
# The key has no padding, and b64decode requires it.
key = base64.b64decode(signature_key + '=' * (-len(signature_key) % 4))
expected = hmac.new(key, raw_body, hashlib.sha256).hexdigest()
valid = hmac.compare_digest(expected, signature_header)Recent Requests
Log in to see full request history
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
Loading…