# Stripe CLI Documentation

This section details the various commands available within the Stripe Command Line Interface (CLI), designed to streamline your Stripe integration and development workflow.

## Core Commands

The Stripe CLI offers a suite of commands to interact with your Stripe account, manage webhooks, and facilitate local development.

### `stripe logs tail`

This command establishes a direct connection with Stripe, allowing you to tail your test mode Stripe API request logs in real-time directly from your terminal. You can apply multiple filters to narrow down the logs displayed.

**Key Features:**

*   **Real-time Logging:** Monitor API requests as they happen.
*   **Test Mode Only:** `logs tail` exclusively displays test mode request logs.
*   **Filtering:** Apply various filters to pinpoint specific requests.

**Filters Available:**

*   `--filter-account`: Filter by source and destination account (`connect_in`, `connect_out`, `self`).
*   `--filter-http-method`: Filter by HTTP method (`GET`, `POST`, `DELETE`).
*   `--filter-ip-address`: Filter by IP address.
*   `--filter-request-path`: Filter by specific Stripe API path (e.g., `/v1/charges`).
*   `--filter-request-status`: Filter by request outcome (`SUCCEEDED`, `FAILED`).
*   `--filter-source`: Filter by the origin of the request (`API`, `DASHBOARD`).
*   `--filter-status-code`: Filter by HTTP status code.
*   `--filter-status-code-type`: Filter by HTTP status code type (`2XX`, `4XX`, `5XX`).
*   `--format`: Specify output format (`JSON`).

**Example:**

```sh
stripe logs tail
```

### `stripe open`

This command provides a shortcut to open various Stripe documentation pages or your Stripe Dashboard in your web browser.

**Key Features:**

*   **Quick Navigation:** Access documentation and Dashboard sections rapidly.
*   **Live Mode Option:** Use the `--live` flag to open the Dashboard for your live integration.

**Arguments:**

A shortcut representing the page to open (e.g., `api`, `dashboard`, `dashboard/webhooks`).

**Flags:**

*   `--list`: Lists all supported shortcuts.
*   `--live`: Opens the Dashboard in live mode.

**Examples:**

```sh
stripe open dashboard/webhooks
stripe open dashboard/apikeys --live
stripe open --live --list
```

### `stripe listen`

The `listen` command allows you to receive Stripe webhook events directly on your local machine through a connection to Stripe's API. You can filter events by type or forward them to an application running on a specific port.

**Key Features:**

*   **Local Webhook Reception:** Receive events without configuring Dashboard endpoints.
*   **Event Filtering:** Specify which events to listen for.
*   **Forwarding:** Forward events to a local application.
*   **Signing Secret:** Provides a webhook signing secret that remains consistent across restarts.

**Flags:**

*   `-e, --events`: Comma-separated list of snapshot event types to listen for (default: `[*]`).
*   `-f, --forward-to`: URL to forward snapshot webhook events to.
*   `-H, --headers`: Comma-separated list of custom HTTP headers to forward.
*   `-c, --forward-connect-to`: URL to forward Connect webhook events to.
*   `--connect-headers`: Comma-separated list of custom HTTP headers for connected accounts.
*   `--thin-events`: Comma-separated list of thin event types to listen for.
*   `--forward-thin-to`: URL to forward thin webhook events to.
*   `--forward-thin-connect-to`: URL to forward thin Connect webhook events to.

**Example:**

```sh
stripe listen -f http://localhost:4242
```

### `stripe trigger`

Use the `trigger` command to simulate example webhook events for local testing. These events are based on real API objects and can trigger other related webhook events.

**Key Features:**

*   **Local Testing:** Simulate webhook events without actual occurrences.
*   **Real Object Simulation:** Events are based on actual Stripe API objects.
*   **Side Effects:** Triggering events creates necessary API objects.

**Arguments:**

The webhook event to trigger (e.g., `account.application.deauthorized`, `charge.succeeded`).

**Example:**

```sh
stripe trigger charge.succeeded
```

### `stripe events resend`

This command allows you to resend a specific event to your CLI's local webhook endpoint. You can only resend events created within the last 30 days.

**Key Features:**

*   **Event Replay:** Resend historical events for debugging.
*   **Specific Endpoint Targeting:** Use `--webhook-endpoint` to target a particular endpoint.

**Arguments:**

The ID of the event to resend.

**Flags:**

*   `--account=`: Specify the connected account ID for Connect webhook endpoints.
*   `-c, --confirm`: Skip the warning prompt.
*   `--dark-style`: Use a darker color scheme.
*   `-e, --expand`: Expand response attributes.
*   `-i, --idempotency`: Set an idempotency key.
*   `--live`: Make a live request.
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account=`: Specify the Stripe account.
*   `-v, --stripe-version=`: Specify the Stripe API version.
*   `--webhook-endpoint=`: Resend the event to the specified webhook endpoint ID.

**Example:**

```sh
stripe events resend evt_1PH9HU2eZvKYlo2CrSrLx8y1 --webhook-endpoint=we_123456
```

### `stripe get`

Make GET HTTP requests to retrieve individual API objects or sets of objects. The output can be piped to other tools like `jq` for further processing.

**Key Features:**

*   **API Data Retrieval:** Fetch data directly from the Stripe API.
*   **Piping Support:** Integrate with other command-line tools.

**Arguments:**

*   The ID of the API object to retrieve.
*   The URL path of the API object or set of objects.

**Flags:**

*   `-c, --confirm`: Skip the warning prompt.
*   `--dark-style`: Use a darker color scheme.
*   `-d, --data`: Additional data for the request.
*   `-b, --ending-before`: Retrieve the previous page in a list.
*   `-e, --expand`: Expand response attributes.
*   `-i, --idempotency`: Set an idempotency key.
*   `-l, --limit`: Number of objects to return (1-100).
*   `--live`: Make a live request.
*   `-s, --show-headers`: Show response HTTP headers.
*   `-a, --starting-after`: Retrieve the next page in a list.
*   `--stripe-account=`: Specify the Stripe account.
*   `-v, --stripe-version=`: Specify the Stripe API version.

**Example:**

```sh
stripe get ch_1OKcnt2eZvKYlo2C99k9lfXl
```

### `stripe post`

Make POST HTTP requests to the Stripe API, supporting features like idempotency keys and expandable objects.

**Key Features:**

*   **API Data Creation/Update:** Create or update resources via POST requests.
*   **Advanced API Features:** Supports idempotency keys and expandable objects.

**Arguments:**

The URL path of the API object to create or update.

**Flags:**

*   `-c, --confirm`: Skip the warning prompt.
*   `--dark-style`: Use a darker color scheme.
*   `-d, --data`: Additional data for the request.
*   `-e, --expand`: Expand response attributes.
*   `-i, --idempotency`: Set an idempotency key.
*   `--live`: Make a live request.
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account=`: Specify the Stripe account.
*   `-v, --stripe-version=`: Specify the Stripe API version.

**Example:**

```sh
stripe post /v1/payment_intents -d amount=2000 -d currency=usd -d "payment_method_types[]=card"
```

### `stripe delete`

Make DELETE HTTP requests to the Stripe API to remove API objects.

**Key Features:**

*   **Resource Deletion:** Remove resources from your Stripe account.

**Arguments:**

The URL path of the API object to delete.

**Flags:**

*   `-c, --confirm`: Skip the warning prompt.
*   `--dark-style`: Use a darker color scheme.
*   `-d, --data`: Additional data for the request.
*   `-e, --expand`: Expand response attributes.
*   `-i, --idempotency`: Set an idempotency key.
*   `--live`: Make a live request.
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account=`: Specify the Stripe account.
*   `-v, --stripe-version=`: Specify the Stripe API version.

**Example:**

```sh
stripe delete /v1/customers/cus_9s6XKzkNRiz8i3
```

### `stripe serve`

Start an HTTP server to serve static files, which is particularly useful for serving files from Stripe Samples.

**Key Features:**

*   **Static File Serving:** Easily serve local files.
*   **Stripe Samples Integration:** Works well with Stripe Samples projects.

**Arguments:**

The path of the directory to serve files from.

**Flags:**

*   `--port`: The port the HTTP server should use.

**Example:**

```sh
stripe serve ./sales-tax-sample --port 4242
```