# Stripe CLI: Webhooks

This guide introduces how to use the Stripe CLI to receive and inspect webhook events.

## What are Webhooks?

Webhooks are automated messages sent from Stripe to your specified URL when specific events occur in your Stripe account. They are a crucial part of integrating Stripe into your application, allowing you to react to events like successful payments, disputes, or subscription updates in real-time.

## Using the Stripe CLI for Webhooks

The Stripe CLI provides a convenient way to forward webhook events from your Stripe account to your local development environment. This eliminates the need to manually send test events or deploy your application to a public URL just to test webhook functionality.

### Key Commands

The primary command for working with webhooks in the Stripe CLI is `stripe listen`.

#### `stripe listen`

This command starts a local server that listens for webhook events from Stripe and forwards them to your application.

**Usage:**

```bash
stripe listen --forward-to <your-local-url>
```

**Example:**

If your local application is running on `http://localhost:3000` and expects webhook events at the `/webhook` endpoint, you would run:

```bash
stripe listen --forward-to localhost:3000/webhook
```

The CLI will output a webhook signing secret that you'll need to verify incoming webhook events.

#### `stripe trigger`

While `stripe listen` receives events, `stripe trigger` allows you to manually send specific events to your Stripe account, which will then be forwarded by `stripe listen`. This is useful for testing specific scenarios.

**Usage:**

```bash
stripe trigger <event-name>
```

**Example:**

To trigger a `payment_intent.succeeded` event:

```bash
stripe trigger payment_intent.succeeded
```

You can also pass arguments to `stripe trigger` to customize the event payload. Refer to the Stripe CLI documentation for a full list of supported events and their parameters.

### Verifying Webhook Signatures

When you use `stripe listen`, it provides a webhook signing secret. It's essential to verify the signature of incoming webhook events in your application to ensure they are legitimate and haven't been tampered with. The Stripe CLI offers libraries and examples in various languages to help you with this verification process.

## Further Information

*   **Stripe Webhooks Documentation:** For a comprehensive understanding of webhooks, including best practices and security considerations, refer to the official Stripe Webhooks documentation.
*   **Stripe CLI GitHub Repository:** Explore the Stripe CLI source code and contribute on GitHub.