Webhooks on your localhost with the Hookdeck CLI
Learn how to receive webhooks on your localhost with the Hookdeck CLI
Introduction
This guide demonstrates how to receive a webhook from services such as Resend, Twilio, Shopify, and Stripe on your localhost development environment using the Hookdeck CLI. You’ll learn how to set up your environment, run the Hookdeck CLI, receive webhooks, and replay webhooks from the Hookdeck Console to test your code during development.
Setup
Step 1: Install the Hookdeck CLI
Via NPM:
On Mac:
On Windows:
Step 2: Create and run a localhost web server
Install Flask to use as the web server:
Create a server.py
file in the project root:
Run the server:
Step 3: Create a localtunnel with the Hookdeck CLI
In a new terminal window, run the following command to create a localtunnel:
The output will look similar to the following:
Trigger a webhook
Step 4: Trigger a test webhook with a cURL command
Run the following cURL command to act as an inbound webhook, replacing the {URL}
with the Event URL from the Hookdeck CLI output:
The cURL command output will be similar to the following:
You will see the terminal running the Hookdeck CLI log the inbound webhook:
You will also see the Python server log the inbound webhook:
Step 5: Trigger a test webhook from the Hookdeck Console
Open the Console URL from your terminal in your browser.
Choose a Sample Webhook Provider from the list of Example Webhooks. For example, Stripe.
Select a Sample Webhook Type from the list on the right. For example, invoice.created.
Click Send.
The Hookdeck Console will show the test webhook has been triggered. You can also inspect the webhook payload and the localhost web server response.
You will see the terminal running the Hookdeck CLI log the inbound webhook:
You will also see the Python server log the inbound webhook:
Step 6: Replay the webhook
From the Hookdeck Console, click the Resend to destination button to replay the webhook.
Step 7: Trigger and receive a webhook from an API platform
Copy the Event URL from the Hookdeck CLI output. The same URL can also be found in the Hookdeck Console.
Go to the API provider platform, such as Resend, Twilio, Shopify, or Stripe, and register the Hookdeck URL as the webhook URL with the provider.
Trigger a webhook from your chosen API provider, and you will see a log entry appear in the Hookdeck console.
Additionally, you will see the webhook logged in the Hookdeck CLI:
And by the Python server running in your local development environment:
Conclusion
You have successfully received a webhook on your localhost development environment using the Hookdeck CLI! You also inspected the webhook payload and server response and replayed a webhook using the Hookdeck console.
This guide provided a basic example to get you started. You can now expand on this by creating a Hookdeck account, trying features such as transformations, and filtering, benefitting from functionality like configurable retries, and generally using Hookdeck as your reliable inbound webhook infrastructure.