# Stripe CLI Documentation

This document outlines the various commands and functionalities available within the Stripe Command Line Interface (CLI). The Stripe CLI provides a powerful set of tools for interacting with the Stripe API, managing your Stripe integration, and streamlining your development workflow.

## Core Commands

The Stripe CLI offers a range of commands to perform common operations.

### `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 from your terminal. You can filter these logs using various flags to narrow down the results.

**Command:** `stripe logs tail`

**Flags:**

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

**Examples:**

```sh
stripe logs tail
```

### `stripe open`

This command provides a shortcut to open Stripe documentation or the Stripe Dashboard in your browser.

**Command:** `stripe open`

**Arguments:**

A shortcut string to specify which page to open. Examples include `api`, `dashboard`, `dashboard/apikeys`, `docs`, etc.

**Flags:**

*   `--list`: Lists all supported shortcuts.
*   `--live`: Opens the Dashboard for your live integration (defaults to test mode).

**Examples:**

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

### `stripe listen`

This command allows you to receive webhook events from Stripe on your local machine via a direct connection to Stripe's API. You can filter events by type or forward them to an application running on a specific port.

**Command:** `stripe listen`

**Flags:**

*   `-e, --events`: A comma-separated list of snapshot event types to listen for.
*   `-f, --forward-to`: The URL to which snapshot webhook events will be forwarded.
*   `-H, --headers`: Custom HTTP headers to forward.
*   `-c, --forward-connect-to`: The URL for Connect webhook events.
*   `--connect-headers`: Custom HTTP headers for connected accounts.
*   `--thin-events`: A comma-separated list of thin event types to listen for.
*   `--forward-thin-to`: The URL for thin webhook events.
*   `--forward-thin-connect-to`: The URL for thin Connect webhook events.

**Note:** You do not need to configure webhook endpoints in your Dashboard to receive webhooks with the CLI. The webhook signing secret will remain consistent between restarts of the `listen` command.

### `stripe trigger`

This command allows you to trigger example webhook events for local testing. These events are based on real API objects and may trigger other related webhook events.

**Command:** `stripe trigger`

**Arguments:**

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

**Examples:**

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

### `stripe events resend`

This command resends an event to the CLI's local webhook endpoint. You can only resend events created within the last 30 days.

**Command:** `stripe events resend`

**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 and automatically confirm.
*   `--dark-style`: Use a darker color scheme.
*   `-e, --expand`: Response attributes to expand inline.
*   `-i, --idempotency`: Set an idempotency key for the request.
*   `--live`: Make a live request (defaults to test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account=`: Specify the Stripe account to use for the request.
*   `-v, --stripe-version=`: Specify the Stripe API version to use for the request.
*   `--webhook-endpoint=`: Resend the event to a specific webhook endpoint ID.

**Examples:**

```sh
stripe events resend evt_1PH9HU2eZvKYlo2CrSrLx8y1
```

### `stripe get`

This command makes GET HTTP requests to retrieve individual API objects or sets of objects. The output can be piped to other tools for further processing.

**Command:** `stripe get`

**Arguments:**

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

**Flags:**

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

**Examples:**

```sh
stripe get ch_1OKcnt2eZvKYlo2C99k9lfXl
```

### `stripe post`

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

**Command:** `stripe post`

**Arguments:**

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

**Flags:**

*   `-c, --confirm`: Skip the warning prompt and automatically confirm.
*   `--dark-style`: Use a darker color scheme.
*   `-d, --data`: Additional data to send with the API request.
*   `-e, --expand`: Response attributes to expand inline.
*   `-i, --idempotency`: Set an idempotency key for the request.
*   `--live`: Make a live request (defaults to test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account=`: Specify the Stripe account to use for the request.
*   `-v, --stripe-version=`: Specify the Stripe API version to use for the request.

**Examples:**

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

### `stripe delete`

This command makes DELETE HTTP requests to the Stripe API.

**Command:** `stripe delete`

**Arguments:**

The URL path of the API object to delete.

**Flags:**

*   `-c, --confirm`: Skip the warning prompt and automatically confirm.
*   `--dark-style`: Use a darker color scheme.
*   `-d, --data`: Additional data to send with the API request.
*   `-e, --expand`: Response attributes to expand inline.
*   `-i, --idempotency`: Set an idempotency key for the request.
*   `--live`: Make a live request (defaults to test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account=`: Specify the Stripe account to use for the request.
*   `-v, --stripe-version=`: Specify the Stripe API version to use for the request.

**Examples:**

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

### `stripe serve`

This command starts an HTTP server to serve static files, useful for working with Stripe Samples.

**Command:** `stripe serve`

**Arguments:**

The path of the directory to serve files from.

**Flags:**

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

**Examples:**

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

## Webhook Commands

The Stripe CLI provides dedicated commands for managing and interacting with webhooks.

### `stripe logs tail` (Webhook Logging)

As mentioned earlier, `stripe logs tail` can be used to monitor incoming webhook events in real-time.

### `stripe listen` (Receiving Webhooks)

This command is essential for receiving webhook events locally.

### `stripe trigger` (Triggering Webhooks)

Use this command to simulate webhook events for testing purposes.

### `stripe events resend` (Resending Webhooks)

This command allows you to resend specific webhook events.

## Other Commands

### `stripe open` (Opening Resources)

This command is a convenient way to open various Stripe resources in your browser.

## General Flags

Many Stripe CLI commands support the following general flags:

*   `-c, --confirm`: Skips confirmation prompts.
*   `--dark-style`: Enables a dark color scheme.
*   `-i, --idempotency`: Sets an idempotency key for requests.
*   `--live`: Switches to live mode for requests.
*   `-s, --show-headers`: Displays response HTTP headers.
*   `--stripe-account=`: Specifies the Stripe account for the request.
*   `-v, --stripe-version=`: Specifies the Stripe API version for the request.