Webhooks & HMAC Verification
Best practices for receiving and verifying webhook callbacks from Social Deck, Formx, and inbound mail pipelines.
Webhook Delivery Guidelines
- Respond Quickly (
2xx): Return200 OKwithin 3 seconds and process heavy work asynchronously in a queue. - Verify Signatures with Raw Bytes: Always verify HMAC signatures against the raw request buffer before JSON parsing.
- Handle Idempotency: Deduplicate retries using the event ID before triggering downstream CRM or billing actions.
js
import crypto from 'node:crypto';
export function verifyWebhookSignature(rawBody, signatureHeader, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(signatureHeader || '')
);
}Last updated on
