GoCardlessDeveloper Docs
Create a sandbox account

Testing Webhooks (CLI)#

View as Markdown

Webhooks let you receive real-time notifications from GoCardless when things happen in your merchant's account.

You can use the gocardless CLI to test your webhook integration locally. Each event from GoCardless contains an Event object with a link to the modified resource. The CLI can trigger these events and either print them to the console or forward them to your local webhook handler.

Listen for events#

gocardless listen
Started listening for new webhooks. Any new webhooks will be printed to your console.

Trigger an event#

In a separate terminal tab, use the trigger command to fire a mock webhook:

gocardless trigger mandate_activated
This will trigger a mandate_activated event and create necessary resources in the process ⏳
Event triggered successfully, see dashboard for events 🚀

You'll see the event payload in your listen tab:

{
  "action": "active",
  "created_at": "2022-02-24T12:49:32.066Z",
  "details": {
    "cause": "mandate_activated",
    "description": "The time window after submission has ended without errors, so this mandate is now active.",
    "origin": "gocardless"
  },
  "id": "EV00QXTDGM5895",
  "links": {
    "mandate": "MD000K62KEVTEQ"
  },
  "resource_type": "mandates"
}

Forward events to your webhook handler#

Use the --forward flag to pipe events to a running webhook server:

gocardless listen --forward http://localhost:8001/webhook

Events will be forwarded to your webhook URL. Make sure your handler performs all the recommended checks when processing incoming webhooks.

What's next?#