July 27, 2020
This tutorial will show you how to develop and test Webhooks locally, all from your local development machine.
You want to use Webhooks to receive important info. After writing your code you could could deploy it to a remote server and do your testing there, but that takes time and for every change you would need to redeploy your code.
By developing and testing locally you’ll have access to all of your development and debugging tools. You’ll be able to quickly make changes right from your IDE and fix issues without redeploying code remotely.
This will save you time. You’ll finish your integration faster and be able to move on to other things.
For Mac or Linux, go to Expose.sh and copy/paste the installation code shown into a terminal.
For Windows go to Expose.sh, download the binary and put it somewhere in your PATH.
Get a public URL for your local machine
Start your API server. Then run
expose <port> where port is the port your API server is running on, like 80 or 8080.
Expose.sh will generate a random public expose.sh URL that forwards to your local machine. You can use this URL with your webhook provider.
Here is a full example where I have a server running locally on port 80:
expose 80 https://s3rh.expose.sh is forwarding to localhost:80 http://s3rh.expose.sh is forwarding to localhost:80
You now have a public URL for your local machine. This URL should work even if you have a firewall or other network boundaries in the way, because it sets up a tunnel between expose.sh and your machine.
Configure your endpoint with your Webhook provider
My webhook endpoint is
https://s3rh.expose.sh url I’ve been given, I will configure
https://s3rh.expose.sh/api/v1/webhook-receive with my webhook provider as my endpoint.
The steps to do this will vary from provider to provider. Find where you can configure your webhook endpoint, then put in your new expose.sh url + the route to your webhook endpoint. Most providers will have a settings page where you can do this. For others, a simple API request can set up your endpoint.
Trigger your Webhook provider to hit endpoint using your new expose.sh URL
Now, do something that will trigger a Webhook. When your Webhook provider hits your new expose.sh endpoint, the request will be forwarded to your local machine. You can then debug and make changes as needed.
Using a custom subdomain like myapi.expose.sh would save you from needing to reconfigure a different URL each time with your Webhook provider.
Here’s how to get a public URL with a custom subdomain
expose 80 as myapi.expose.sh https://myapi.expose.sh is forwarding to localhost:80 http://myapi.expose.sh is forwarding to localhost:80
Expose.sh is free to use for randomly generated subdomains. If you want to use custom subdomains you can do this for as little as $4.99/month depending on how many subdomains you want to use. Sign up here
As you can see, using expose.sh to test a Webhook integration is much faster than doing it using a remote server.