# Testing Webhooks (CLI)

Source: https://docs.gocardless.com/docs/developer-resources/gc-cli/testing-webhooks-cli

# Testing Webhooks (CLI)

[Webhooks](/docs/getting-started/stay-up-to-date-with-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](/docs/api-reference/events/payments) 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

```bash
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:

```bash
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:

```json
,
  "id": "EV00QXTDGM5895",
  "links": ,
  "resource_type": "mandates"
}
```

> **Info:**
> The `trigger` command also creates any resources needed by the event. To target a specific
>   existing resource, use the resource flag (e.g. `--mandate MD000K62KEVTEQ`). Run `gocardless help
>   trigger` to see all available flags.

## Forward events to your webhook handler

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

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

Events will be forwarded to your webhook URL. Make sure your handler performs all the [recommended checks](/docs/getting-started/stay-up-to-date-with-webhooks#build-a-webhook-handler) when processing incoming webhooks.

## What's next?

  
#### [Webhooks Guide](/docs/getting-started/stay-up-to-date-with-webhooks)

Learn how to build a robust webhook handler.

  
#### [CLI Reference](/docs/developer-resources/gc-cli/cli-reference)

Full reference for all `gocardless` commands including `trigger` and `listen`.