verifyWebhook() checks that a delivery really came from Tolt, then hands you the event, typed by event.type.
ToltPOST /api/webhooks/tolt verifyWebhook()
Returned when valid
eventToltWebhookEvent
type
data.id
data.amount1470
timestamp
Thrown when invalid
WebhookVerificationError400
svix-idmissing
svix-timestamp
svix-signatureno match
Install
whsec_...) from Dashboard → Settings → Webhooks into TOLT_WEBHOOK_SECRET.
Verify a delivery
Always pass the raw request body. A parsed and re-serialized body won’t match the signature.- Next.js
- Express
app/api/webhooks/tolt/route.ts
Handle the event
Narrow onevent.type and event.data is typed for that resource.
{ type, data, timestamp }. data has the same fields as the API resource, plus organization_id. The types are: partner, link, customer, transaction and commission, each with .created and .updated. See Event types.
Options
string
required
The raw request body, exactly as received.
Headers | Record<string, string | string[]>
required
The request headers: a Fetch
Headers object or a plain object such as Express’s req.headers.string
required
Your endpoint’s signing secret,
whsec_....number
default:"300"
How far the
svix-timestamp may be from now before the delivery is rejected as a replay.Errors
verifyWebhook() throws WebhookVerificationError and returns nothing when the delivery can’t be trusted. Respond 400.
Verify without the package
Verify without the package
The signature is HMAC-SHA256, and you can check it with any crypto library:
- Read
svix-id,svix-timestampandsvix-signature. Reject if the timestamp is more than 5 minutes from now. - Base64-decode the part of your secret after
whsec_. That is the key. - Sign the string
{svix-id}.{svix-timestamp}.{raw body}with it, and base64-encode the digest. svix-signatureis a space-separated list likev1,<base64>. Accept if any signature after the comma equals yours, compared in constant time.
Python

