Stripe CLI
Manage your Stripe resources in test mode directly from the command line.
The Stripe CLI is a developer tool to help you build, test, and manage your integration with Stripe directly from the command line. With the Stripe CLI, it’s easy to perform many common tasks like calling Stripe APIs, testing your webhooks integration, and creating an application.
Start with a guide
Install the Stripe CLI on macOS, Windows, and Linux and get started with a YouTube video from Developer Advocacy.
Enable autocompletion so that the Stripe CLI automatically completes your commands.
Learn about Stripe CLI keys, where they’re stored locally, and where to find their permissions.
Take advantage of the latest features of the Stripe CLI.
Use these reference guides to explore the CLI and Stripe APIs.
Log into Stripe to authenticate requests
Log in and authenticate your Stripe user account to generate a set of restricted keys. To learn more, see Stripe CLI keys and permissions.
stripe login
Press the Enter key on your keyboard to complete the authentication process in your browser.
Your pairing code is: enjoy-enough-outwit-win This pairing code verifies your authentication with Stripe. Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?t=THQdJfL3x12udFkNorJL8OF1iFlN8Az1 (^C to quit)
Specify an API version while running requests
When you call Stripe APIs in the CLI, it uses your default API version in all requests, which you can identify in Workbench. To try out different API versions in the CLI, use the following flags:
Flag | Description | Example |
---|---|---|
–stripe-version 2024-11-20. | Use the --stripe-version flag in any CLI request to specify an API version. | stripe products create --name=“My Product” --stripe-version 2024-11-20. |
--latest | Use the --latest flag in any CLI request to specify the latest API version. | stripe products create --name="My Product" --latest |
You can also view a list of API versions.
Stream request logs
Use the stripe logs tail
command to stream API request logs. Keep this window open. If you have an error in your API calls, this terminal returns the API error message and a reason for the error.
stripe logs tail
Forward events to your local webhook endpoint
Use the --forward-to
flag to send all Stripe events in test mode to your local webhook endpoint. To disable HTTPS certificate verification, use the --skip-verify
flag.
stripe listen --forward-to localhost:4242/webhooks
Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit)
To forward specific events in a comma separated list, use the --events
flag.
stripe listen --events payment_intent.created,customer.created,payment_intent.succeeded,charge.succeeded,checkout.session.completed,charge.failed \ --forward-to localhost:4242/webhook
If you’ve already registered your endpoint in Stripe, you can use the --load-from-webhooks-api
and --forward-to
flags.
stripe listen --load-from-webhooks-api --forward-to localhost:4242
This command forwards events sent to your Stripe-registered public webhook endpoint to your local webhook endpoint. It loads your registered endpoint, parses the path and its registered events, then appends the path to your local webhook endpoint in the --forward-to
path. If you’re checking webhook signatures, use the {{WEBHOOK_
from the initial output of the listen
command.
List all available events
Use the –help flag to list all possible events that can occur for an event category. For example, to list all possible events for the prebuilt checkout page for Stripe Checkout:
stripe trigger checkout --help
Create a one-off product and price
- Make a single API request to Create a product.
stripe products create \ --name="My First Product" \ --description="Created with the Stripe CLI"
- Look for the product identifier (in
id
) in the response object. Save it for the next step.
If everything worked, the command-line displays the following response.
{ "id":
, "object": "product","prod_LTenIrmp8Q67sa"
- Call Create a price to attach a price of 30 USD. Swap the placeholder in
product
with your product identifier (for example,prod_
).LTenIrmp8Q67sa
stripe prices create \ --unit-amount=3000 \ --currency=usd \ --product=
{{PRODUCT_ID}}
If everything worked, the command-line displays the following response.
{ "id":
, "object": "price","price_1KzlAMJJDeE9fu01WMJJr79o"
Trigger a webhook event while testing
Trigger the checkout.
event to create the API objects that result from a checkout session successfully completing.
stripe trigger checkout.session.completed
Your stripe listen
terminal displays the following output:
Setting up fixture for: checkout_session Running fixture for: checkout_session Setting up fixture for: payment_page Running fixture for: payment_page Setting up fixture for: payment_method Running fixture for: payment_method Setting up fixture for: payment_page_confirm Running fixture for: payment_page_confirm Trigger succeeded!
To learn more about triggers, read our guide.