Stripe CLI
Official CLI for Stripe. Test webhooks locally, manage resources, and trigger events without the dashboard.
- Official repo: https://github.com/stripe/stripe-cli
- Docs: https://docs.stripe.com/stripe-cli
Authentication
stripe login # Opens browser for auth
stripe login --api-key sk_test_xxx # Use API key directly
Common Commands
Webhook Testing
stripe listen # Forward all events to default endpoint
stripe listen --forward-to localhost:3000/webhook # Forward to local server
stripe listen --events payment_intent.succeeded # Filter specific events
stripe trigger payment_intent.succeeded # Trigger a test event
stripe trigger customer.subscription.created # Test subscription flow
Resources
stripe customers list --limit 5
stripe customers create --name "Test User" --email test@example.com
stripe payment_intents create --amount 2000 --currency usd
stripe products list
stripe prices list --product prod_xxx
stripe subscriptions list --customer cus_xxx
Logs and Events
stripe logs tail # Stream API logs in real-time
stripe events list --limit 10
stripe events resend evt_xxx
Fixtures
stripe fixtures path/to/fixture.json # Run a fixture file for test data
Agent Best Practices
- Always use test mode keys (sk_test_*) for agent operations
- Use
--jsonor pipe output throughjqfor structured data stripe listenruns as a long-lived process - run it in background- Use
stripe triggerto test webhook handlers without real transactions - The
stripe logs tailcommand is invaluable for debugging API issues - Use
stripe resourcesto discover available resource types
Example Workflows
Set up local webhook testing
stripe listen --forward-to localhost:3000/api/webhooks \
--events checkout.session.completed,payment_intent.succeeded
Create a test customer with subscription
CUSTOMER=$(stripe customers create --name "Test" -q --json | jq -r '.id')
stripe subscriptions create --customer "$CUSTOMER" --price price_xxx