Guides
Verify webhook signatures
Authenticate the exact request body and reject stale or replayed deliveries.
Node.js
ts
import { createHmac, timingSafeEqual } from 'node:crypto'
const expected = 'v1=' + createHmac('sha256', process.env.TROVV_WEBHOOK_SECRET!)
.update(timestamp + '.' + rawBody).digest('hex')
const valid = expected.length === signature.length &&
timingSafeEqual(Buffer.from(expected), Buffer.from(signature))Verification checklist
- Read the raw body before JSON parsing.
- Reject timestamps outside your replay window.
- Compute HMAC-SHA256 over timestamp + period + exact raw body.
- Compare signatures in constant time.
- De-duplicate using Trovv-Event-Id.
- Return 2xx quickly and process asynchronously.
Was this page helpful?