Webhook Testing Guide

Testing webhooks is hard. You need to set up a public HTTPS endpoint, capture the incoming requests, and somehow forward them to your local development environment - that's a lot of work just to test a webhook!

In this guide, I'll show you how to test webhooks using UseWebhook - a free tool to capture and inspect webhooks from your browser, and replay them on localhost anytime.

1. Grab your webhook URL

First, grab your unique webhook URL. This is the endpoint where you'll be capturing any incoming webhooks.

Webhook Testing Tool

2. Send a test request

Once you've set up your webhook endpoint, you can send a test request to trigger the webhook. You can use tools like Postman or cURL to send the request.

Here's an example using cURL:

curl -X POST  $YOUR_WEBHOOK_URL \
  -H "Content-Type: application/json" \
  -d '{"event": "test"}'

Replace $YOUR_WEBHOOK_URL with your unique UseWebhook URL.

3. Inspect the response

After sending the test request, you can inspect the response to see if the webhook was received successfully. You should be able to see the request headers, body, and other relevant information.

Example webhook requests

UseWebhook highlights any differences between the current request and the previous request, making it easy to spot changes in the webhook headers or payload.

4. Forward to localhost

Next, let's forward incoming requests to your local machine. That way you can test how your application responds to webhooks without needing to re-deploy your server each time.

We'll use the UseWebhook CLI to automatically forward the requests.

You can install it by running the following command:

curl -sSL https://usewebhook.com/install.sh | bash

Now you can use the usewebhook command to forward requests to your local server. First, make sure your server is running locally. Then run the following command:

usewebhook $YOUR_WEBHOOK_URL \
  --forward-to http://localhost:3000/hello

You can now test your webhook locally. Each time a request is sent to your UseWebhook URL, it will be automatically forwarded to your local server.

5. Replay from webhook history

UseWebhook stores a history of requests to your webhook, so you can replay them at any time. This is useful for reproducing issues or testing changes to your application.

You can replay a request by going to your UseWebhook dashboard, selecting the request you want to replay, and copying the request ID.

Grab request ID

Then, use the usewebhook command to replay the request:

usewebhook $YOUR_WEBHOOK_URL \
  --request-id $REQUEST_ID \
  --forward-to http://localhost:3000/hello

For convenience, you can also grab the entire command from the UseWebhook dashboard. Select the request you want to replay, and click on the "Copy as" dropdown to pick the command you want to run.

Copy request as cURL

Conclusion

That's it - you can now provide your unique webhook URL to any third-party service (i.e. Stripe, Paddle, Slack). UseWebhook will capture any incoming webhook, so you can inspect them your browser or CLI, and optionally forward them to a development server.

Ready to try it out? Grab your webhook URL.