Guide

Svix webhooks: verify svix-signature headers and test locally

Svix webhooks are what you receive from the many services that use Svix to send theirs, including Clerk, Resend and Polar. They all share one signature scheme: three svix- headers and a whsec_ secret. Here is how that scheme works, how to verify it and how to test any Svix-powered sender against localhost.

All docs

Get a public URL for Svix webhooks#

Svix can't deliver to localhost. An OtterKit webhook endpoint gives you a public HTTPS URL that answers Svix around the clock and keeps every request, so nothing is lost while your laptop is closed or your handler is half written:

Terminal
npx otterkit login
npx otterkit webhook --daemon --subdomain svix-dev
#   https://svix-dev.otterkit.app

The name is reserved to your account, so the URL stays the same every time you start it. An endpoint costs $0.01 per hour while it is live and never more than $3 in any 30 days, and new accounts get 10 free credits. To look at a payload before you sign up, the try page gives you a live URL in the browser with no account.

Register the URL in Svix#

  1. Open the webhooks section of the service you are integrating. Svix-powered senders usually embed the same portal, with an Add Endpoint button.
  2. Paste the endpoint URL and choose the event types.
  3. Copy the endpoint's signing secret, which starts with whsec_.

Use https://svix-dev.otterkit.app as the URL. Add a path if your handler expects one, such as https://svix-dev.otterkit.app/webhooks/svix: the endpoint accepts any path and records it.

How the Svix signature works#

The signed content is svix-id, svix-timestamp and the raw body, joined with dots. The key is the part of the secret after whsec_, base64-decoded. The result is an HMAC-SHA256, base64-encoded, sent in svix-signature as v1,<signature>. The header can hold several signatures separated by spaces while a secret is being rotated; accept the request if any of them matches.

Reject timestamps more than five minutes from your clock. Some senders rename the headers to webhook-id, webhook-timestamp and webhook-signature, which is the Standard Webhooks spelling of the same scheme.

OtterKit can run the same check on every request as it arrives. Start the endpoint again with the secret, and each capture is marked valid, invalid or missing:

Terminal
npx otterkit stop svix-dev
npx otterkit webhook --daemon --subdomain svix-dev --verify svix:whsec_…

A failed check comes with its reason, such as signature_mismatch, so a wrong secret and a changed body look different. See signature verification for all 16 presets and the generic HMAC mode.

Send a test event#

In the portal, open the endpoint's Testing tab and send an example event. Every message, attempt and response is listed on the endpoint's page.

Then watch it land, or wait for it in a script:

Terminal
# Follow requests as they arrive, with headers and bodies
npx otterkit inspect svix-dev --follow

# Or block until the next POST, then print it as JSON
npx otterkit await svix-dev --method POST --count 1 --timeout 120s --json

Replay Svix events into your local handler#

Once an event is captured you can send it to your handler as often as you like, with the original headers and body, without asking Svix to fire it again:

Terminal
# Send the latest captured event to a server on port 3000
npx otterkit replay svix-dev --target 127.0.0.1:3000

# Or a specific one (1 is the oldest, -1 the latest)
npx otterkit replay svix-dev --index 3 --target 127.0.0.1:3000

Replays cost nothing and are added to the capture log with your handler's response next to them. If you would rather have events delivered live while you work, expose the handler with a tunnel instead and register the tunnel URL.

Retries, timeouts and duplicates#

  • Svix retries a failed message several times with growing gaps, over hours, and can disable an endpoint that fails for days. Resend a message or recover a time range from the portal.
  • Use svix-id to recognise a retry of a message you have already handled.

To see how your code copes when a delivery fails, the HTTP status codes guide has URLs that return any status on demand.

Questions about Svix webhooks#

Which services send Svix webhooks?#

Clerk, Resend and Polar among others. If the request has svix- headers and the secret starts with whsec_, this page applies.

Is a Svix secret the same as a Stripe webhook secret?#

No. Both start with whsec_, but the headers and the signed content differ. Use the check that matches the sender.

Do I need the svix library to verify?#

No, the scheme is a plain HMAC and easy to implement. The library saves you the edge cases, such as multiple signatures and the timestamp check.

Other providers#