Develop a webhook endpoint locally
Developing a webhook receiving endpoint and webhook verification can be tedious. To speed up the process of testing the changes to your code, you can use cloudflare tools to route webhooks to your local app.


Payments API webhooks are sent to your cloudflare domain, then are routed to your locally running app.
This is a step by step guide to set up a tunnel to your local machine to receive webhooks in sandbox.
We recommend you do this in the sandbox environment only
Ensure you're on sandbox
The sandbox environment gives access to the mock providers that TrueLayer develops only. All the values in the webhooks generated in the sandbox environment are safe to share. Avoid using these methods for production testing.


The 'Live' switch at the top-right of TrueLayer console should be toggled off.
1. Download the cloudflared tool
Follow the guide here.
2. Create a tunnel
You can generate a public domain name and start a tunnel from that domain into your local machine.
You can pass your locally running app's address to the command and make sure cloudflared
CLI command routes request to the generated public domain hits your local app.
cloudflared tunnel --url localhost:8080
After you run this command, the output will contain a section describing the public domain name cloudflared
generated, which will look like following:


Copy the domain name to be configured as the webhook endpoint on TrueLayer developer console.
3. Configure your webhook endpoint for the sandbox
Click Settings under the Payments API
section.


On the Settings page, change your Webhook URI to the domain generated with the cloudflared
command.


Set the webhook URI to the value generated through the cloudflared
command.
In this example, any webhooks generated in the sandbox environment will now be routed through https://circular-amounts-galaxy-tubes.trycloudflare.com
, to the address localhost:8080
on your machine. The Cloudflare URL changes each time you run the command on step 2.
Updated about 1 month ago