# Stripe CLI Commands

This documentation outlines the various commands available in the Stripe Command Line Interface (CLI), designed to streamline your Stripe integration and development workflow.

## Core API Interaction Commands

These commands allow you to directly interact with the Stripe API from your terminal.

### `stripe get`

Make GET HTTP requests to retrieve an individual API object or a set of objects. This command is useful for fetching data and can be piped to other tools like `jq` for further processing.

**Command:** `stripe get`

**Arguments:**
*   `[ID]`: The ID of the API object to retrieve.
*   `[URL path]`: The URL path of the API object or set of objects to fetch.

**Flags:**
*   `-c, --confirm`: Skip the warning prompt and automatically confirm the command.
*   `--dark-style`: Use a darker color scheme for the command output.
*   `-d, --data [data]`: Additional data to send with the API request. Supports nested values (e.g., `nested[param]=value`).
*   `-b, --ending-before [ending_before]`: Retrieve the previous page in a list, using a cursor based on an object's ID.
*   `-e, --expand [expand]`: Response attributes to expand inline (target nested values with `nested[param]=value`).
*   `-i, --idempotency [idempotency]`: Set an idempotency key for the request to prevent replaying within 24 hours.
*   `-l, --limit [limit]`: Number of objects to return (between 1 and 100). Defaults to 10.
*   `--live`: Make a live API request (by default, runs in test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `-a, --starting-after [starting_after]`: Retrieve the next page in a list, using a cursor based on an object's ID.
*   `--stripe-account [stripe_account]`: Specify the Stripe account to use for the request.
*   `-v, --stripe-version [stripe_version]`: Specify the Stripe API version to use for the request.

**Examples:**
*   **Get a specific charge by ID:**
    ```sh
    stripe get ch_1OKcnt2eZvKYlo2C99k9lfXl
    ```

### `stripe post`

Make POST HTTP requests to the Stripe API. This command supports API features like idempotency keys and expandable objects.

**Command:** `stripe post`

**Arguments:**
*   `[URL path]`: URL path of the API object to either create or update.

**Flags:**
*   `-c, --confirm`: Skip the warning prompt and automatically confirm the command.
*   `--dark-style`: Use a darker color scheme for the command output.
*   `-d, --data [data]`: Additional data to send with the API request. Supports setting nested values (e.g., `nested[param]=value`).
*   `-e, --expand [expand]`: Response attributes to expand inline (target nested values with `nested[param]=value`).
*   `-i, --idempotency [idempotency]`: Set an idempotency key for the request to prevent replaying within 24 hours.
*   `--live`: Make a live API request (by default, runs in test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account [stripe_account]`: Specify the Stripe account to use for the request.
*   `-v, --stripe-version [stripe_version]`: Specify the Stripe API version to use for the request.

**Examples:**
*   **Create a payment intent:**
    ```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.

**Command:** `stripe delete`

**Arguments:**
*   `[URL path]`: URL path of the API object to delete.

**Flags:**
*   `-c, --confirm`: Skip the warning prompt and automatically confirm the command.
*   `--dark-style`: Use a darker color scheme for the command output.
*   `-d, --data [data]`: Additional data to send with the API request. Supports setting nested values (e.g., `nested[param]=value`).
*   `-e, --expand [expand]`: Response attributes to expand inline (target nested values with `nested[param]=value`).
*   `-i, --idempotency [idempotency]`: Set an idempotency key for the request to prevent replaying within 24 hours.
*   `--live`: Make a live API request (by default, runs in test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account [stripe_account]`: Specify the Stripe account to use for the request.
*   `-v, --stripe-version [stripe_version]`: Specify the Stripe API version to use for the request.

**Examples:**
*   **Delete a customer:**
    ```sh
    stripe delete /v1/customers/cus_9s6XKzkNRiz8i3
    ```

## Webhook and Event Management

These commands help you manage and interact with Stripe webhooks and events.

### `stripe logs tail`

Establish a direct connection with Stripe to tail your test mode Stripe API request logs in real-time from your terminal. Multiple filters can be used together, and a log entry must match all filters to be shown.

**Note:** `logs tail` only supports displaying *test mode* request logs.

**Command:** `stripe logs tail`

**Flags:**
*   `--filter-account [filter_account]`: Filter request logs by the source and destination account (`connect_in`, `connect_out`, `self`).
*   `--filter-http-method [filter_http_method]`: Filter request logs by HTTP method (`GET`, `POST`, `DELETE`).
*   `--filter-ip-address [filter_ip_address]`: Filter request logs by IP address.
*   `--filter-request-path [filter_request_path]`: Filter request logs that directly match any Stripe path (e.g., `/v1/charges`).
*   `--filter-request-status [filter_request_status]`: Filter request logs by the response status (`SUCCEEDED`, `FAILED`).
*   `--filter-source [filter_source]`: Filter request logs by the source of each request (`API`, `DASHBOARD`).
*   `--filter-status-code [filter_status_code]`: Filter request logs by HTTP status code.
*   `--filter-status-code-type [filter_status_code_type]`: Filter request logs by the type of HTTP status code (`2XX`, `4XX`, `5XX`).
*   `--format [format]`: Specifies the output format for request logs (`JSON`).

**Examples:**
*   **Basic usage:**
    ```sh
    stripe logs tail
    ```

### `stripe listen`

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

**Note:** 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 of the `listen` command.

**Command:** `stripe listen`

**Flags:**
*   `-e, --events [events]`: A comma-separated list of snapshot events to listen for. Defaults to `[*]`.
*   `-f, --forward-to [forward_to]`: The URL that snapshot webhook events will be forwarded to. Returns a webhook signing secret.
*   `-H, --headers [headers]`: A comma-separated list of custom HTTP headers to forward.
*   `-c, --forward-connect-to [forward_connect_to]`: The URL that Connect webhook events will be forwarded to.
*   `--connect-headers [connect_headers]`: A comma-separated list of custom HTTP headers to forward to any connected accounts.
*   `--thin-events [thin_events]`: A comma-separated list of which thin events to listen for. Use `*` for all events.
*   `--forward-thin-to [forward_thin_to]`: The URL that thin webhook events will be forwarded to. Returns a webhook signing secret.
*   `--forward-thin-connect-to [forward_thin_connect_to]`: The URL that thin Connect webhook events will be forwarded to.

### `stripe trigger`

Trigger example webhook events for local testing. These events are based on real API objects and may trigger other webhook events as a side effect.

**Note:** Triggering events causes side effects, as all necessary API objects will be created in the process.

**Command:** `stripe trigger`

**Arguments:**
*   `[event]`: The webhook event to trigger. A list of supported events can be found by running `stripe help trigger`.

**Examples:**
*   **Trigger a `charge.succeeded` event:**
    ```sh
    stripe trigger charge.succeeded
    ```

### `stripe events resend`

Resend 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:**
*   `[ID]`: The ID of the event to resend.

**Flags:**
*   `--account [account]`: To resend an event sent to a Connect webhook endpoint, set this flag to the connected account ID.
*   `-c, --confirm`: Skip the warning prompt and automatically confirm the command.
*   `--dark-style`: Use a darker color scheme for the command output.
*   `-e, --expand [expand]`: Response attributes to expand inline.
*   `-i, --idempotency [idempotency]`: Set an idempotency key for the request.
*   `--live`: Make a live request (by default, runs in test mode).
*   `-s, --show-headers`: Show response HTTP headers.
*   `--stripe-account [stripe_account]`: Specify the Stripe account to use for this request.
*   `-v, --stripe-version [stripe_version]`: Specify the Stripe API version to use for this request.
*   `--webhook-endpoint [webhook_endpoint]`: Resend the event to the given webhook endpoint ID.

**Examples:**
*   **Basic usage:**
    ```sh
    stripe events resend evt_1PH9HU2eZvKYlo2CrSrLx8y1
    ```

## Utility Commands

These commands provide convenient shortcuts and utilities for interacting with Stripe.

### `stripe open`

Shortcut to open the Stripe documentation or Dashboard in your browser.

**Note:** Any Dashboard pages (including `/test/` in the URL) can be viewed in live mode with the `--live` flag.

**Command:** `stripe open`

**Arguments:**
*   `[shortcut]`: Shortcut used to quickly open a page on stripe.com. Examples include `api`, `dashboard`, `dashboard/webhooks`, `docs`.

**Flags:**
*   `--list`: List all supported shortcuts.
*   `--live`: Open the Dashboard for your live integration (by default, runs in test mode).

**Examples:**
*   **Open the Dashboard webhooks page:**
    ```sh
    stripe open dashboard/webhooks
    ```
*   **Open the Dashboard API keys page in live mode:**
    ```sh
    stripe open dashboard/apikeys --live
    ```
*   **List available shortcuts in live mode:**
    ```sh
    stripe open --live --list
    ```

### `stripe serve`

Start an HTTP server to serve static files. By default, the current working directory is used. This command is useful for serving files from Stripe Samples.

**Command:** `stripe serve`

**Arguments:**
*   `[path]`: Path of the directory to serve files from.

**Flags:**
*   `--port [port]`: Port the HTTP server should use.

**Examples:**
*   **Basic Usage:**
    ```sh
    stripe serve ./sales-tax-sample
    ```