Skip to main content
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

Copy your endpoint’s signing secret (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.
app/api/webhooks/tolt/route.ts

Handle the event

Narrow on event.type and event.data is typed for that resource.
Every event is { 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.
Deliveries can be retried, so the same event may arrive twice. Deduplicate on the svix-id header.

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.
The signature is HMAC-SHA256, and you can check it with any crypto library:
  1. Read svix-id, svix-timestamp and svix-signature. Reject if the timestamp is more than 5 minutes from now.
  2. Base64-decode the part of your secret after whsec_. That is the key.
  3. Sign the string {svix-id}.{svix-timestamp}.{raw body} with it, and base64-encode the digest.
  4. svix-signature is a space-separated list like v1,<base64>. Accept if any signature after the comma equals yours, compared in constant time.
Python