## listen

Receive webhook events from Stripe on your local machine via a direct connection to Stripe's API. The `listen` command can receive events based on your account's default API version or the latest version, filter by type of event, or forward events to an application running on a given port.

To forward events with `--forward-to` or `--forward-connect-to`, you must also select the events to forward with `--events`, `--all-snapshot`, or `--all-thin`. Otherwise, the command exits with an error.

> You don't need to configure any webhook endpoints in your Dashboard to receive webhooks with the CLI.
> 
> The webhook signing secret provided will not change between restarts to the `listen` command.

**Command:** `stripe listen`

### Flags

- `-e, --events <events types>`
  A comma-separated list of the events to listen for. Accepts both [snapshot event types](https://docs.stripe.com/api/events/types.md), such as `charge.captured`, and [thin event types](https://docs.stripe.com/api/v2/core/events/event-types.md), such as `v1.billing.meter.no_meter_found`. To listen for all events of one format, use `--all-snapshot` or `--all-thin` instead. The `*` wildcard isn't supported.

- `--all-snapshot`
  Listen for all [snapshot events](https://docs.stripe.com/events/how-events-work.md#event-formats).

- `--all-thin`
  Listen for all [thin events](https://docs.stripe.com/events/how-events-work.md#event-formats).

- `--events-from <value>`
  Listen for snapshot and thin events from only the specified accounts (default: `all`).
    - `@self`
      Events from your account only.
    - `@accounts`
      Events from your connected accounts only.
    - `all`
      Events from your account and your connected accounts.

- `-f, --forward-to <url>`
  The URL to forward events to. Requires `--events`, `--all-snapshot`, or `--all-thin`. A single URL can't receive both snapshot and thin events. Returns a [webhook signing secret](https://docs.stripe.com/webhooks/signatures.md) that you can add to your application's configuration.

- `-H, --headers <values>`
  A comma-separated list of custom HTTP headers to forward.

Ex: `"Key1:Value1, Key2:Value2"`

- `-c, --forward-connect-to <url>`
  The URL to forward events from connected accounts to. Requires `--events`, `--all-snapshot`, or `--all-thin` (default: the `--forward-to` URL).

- `--connect-headers <values>`
  A comma-separated list of custom HTTP headers to forward to any connected accounts. This is useful when testing a [Connect](https://docs.stripe.com/connect.md) platform.

Ex: `"Key1:Value1, Key2:Value2"`

- `-l, --latest`
  Receive events used in the latest API version. By default, webhook events received will depend on your account's default API version.

- `--live`
  Make a live request. Requests run in a sandbox by default.

- `-a, --load-from-webhooks-api`
  Listen for all webhook events based on your existing webhook endpoints configured in the Dashboard and API.

- `-j, --print-json`
  Print JSON objects to stdout.

- `--print-secret`
  Only print the webhook signing secret and exit.

- `--skip-verify`
  Skip certificate verification when forwarding to HTTPS endpoints.

- `--thin-events <events types>`
  A comma-separated list of thin events to listen for. Use `--events` or `--all-thin` instead.

- `--forward-thin-to <url>`
  The URL to forward thin events to. Use `--forward-to` with `--all-thin` or `--events` instead.

- `--forward-thin-connect-to <url>`
  The URL to forward thin events from connected accounts to. Use `--forward-to` with `--events-from @accounts` and either `--all-thin` or `--events` instead.

### Examples

**Basic usage**

```sh
stripe listen
```

```
> Ready! Your webhook signing secret is whsec_abcdefg1234567
2022-01-28 09:47:46   --> customer.created [evt_abc123]
2022-01-28 09:48:22   --> charge.succeeded [evt_def456]
2022-01-28 09:48:58   --> charge.succeeded [evt_ghi789]
```

**Forward webhook events to an application**

```sh
stripe listen --all-snapshot --forward-to http://localhost:4242
```

**Forward connected account events to an application**

```sh
stripe listen --all-snapshot --forward-connect-to http://localhost:4242
```

**Filter webhook events by type**

```sh
stripe listen --events=payment_intent.succeeded
```
