Testing Webhooks Locally with the Svix CLI

A common issue when developing a webhook endpoint is that you have to deploy it to a public URL in order to receive events to test it. Having to deploy every change in order to test it is not a developer experience I'd wish on my worst enemy so how can we get webhooks sent to our local development environment?

With the Svix CLI, you can set up a public URL that will tunnel webhooks to localhost. To get started, you’ll need to install the CLI (see our Github repo for installation instructions).

Once you have the CLI installed, run the listen command:

$ svix listen http://localhost:8000/webhook/

You can choose the local URL where you want to forward the webhook. You should get an output like this:

Webhook relay is now listening at
https://api.relay.svix.com/api/v1/receive/q1FB7XNKZTO4s0Tzh5BDTZ7_oktf1NBo/

All requests on this endpoint will be forwarded to your local url:
http://localhost:8080/webhook/

Your actual URL will have a different identifier at the end. Now you just need to set the provided URL as your endpoint URL in whatever service you're trying to receive webhooks from and you'll be able to receive them on localhost.

You can even use Svix Play to view and inspect the messages you're receiving by navigating to https://play.svix.com/view/{your endpoint identifier}.