-
Notifications
You must be signed in to change notification settings - Fork 385
Resource commands
You can easily make API requests using the CLI:
$ stripe charges retrieve ch_123
$ stripe charges create --amount=100 --currency=usd --source=tok_visa
$ stripe charges update ch_123 -d "metadata[key]=value"
For a full list of available resources, type stripe resources
or the wiki page.
The CLI has three commands that let you interact with the Stripe API in test mode. You can easily make GET
, POST
, and DELETE
commands with the Stripe CLI.
For example, you can retrieve a specific charge:
$ stripe get /charges/ch_123
You can also pass data in using the -d
flag:
$ stripe post /charges -d amount=100 -d source=tok_visa -d currency=usd
These commands support many of the features on the Stripe API (e.g. selecting a version, pagination, and expansion) through command-line flags, so you won't need to provide specific headers. For a full list of supported flags, see the wiki page.
You can pipe the output of these commands to other tools. For example, you could use jq to extract information from JSON the API returns, and then use that information to trigger other API requests.
Here’s a simple example that lists past_due
subscriptions, extracts the IDs, and cancels those subscriptions:
$ stripe get /subscriptions -d status=past_due | jq ".data[].id" | xargs -I % -p stripe delete /subscriptions/%
The Stripe CLI has commands available to interact with all Stripe API resources. For example, with charges you could write:
$ stripe charges create amount=100 currency=usd source=tok_visa
All commands support making live requests with the --livemode
flag.
To see what actions you can make, use the help
command on any resource:
$ stripe charges --help
The full list of available top-level commands is:
3d_secure
account_links
accounts
apple_pay_domains
application_fees
balance
balance_transactions
bank_accounts
bitcoin_receivers
bitcoin_transactions
capabilities
cards
charges
checkout
country_specs
coupons
credit_notes
customer_balance_transactions
customers
disputes
ephemeral_keys
events
exchange_rates
external_accounts
fee_refunds
file_links
files
invoiceitems
invoices
issuer_fraud_records
issuing
line_items
login_links
order_returns
orders
payment_intents
payment_methods
payment_sources
payouts
persons
plans
products
radar
recipients
refunds
reporting
reviews
scheduled_query_runs
setup_intents
skus
sources
subscription_items
subscription_schedules
subscriptions
tax_ids
tax_rates
terminal
tokens
topups
transfer_reversals
transfers
usage_records
webhook_endpoints
The get
, post
, and delete
commands expose simple interface to make raw requests against the Stripe API. They allow you to get, update, and delete existing data without having to use curl.
The commands provide a few usage shortcuts:
- if you provide an id, the CLI will know how to load that directly
- paths provided do not require `/v1/ to be prepended to every request
For example:
$ stripe get ch_1EOA8IByst5pquEteSXgXjj0
{
"id": "ch_1EOA8IByst5pquEteSXgXjj0",
"object": "charge",
"amount": 1099,
"amount_refunded": 0,
...
}
The commands also map all of our top-level API features such as expand
and paging
:
Command | Flag | Description | Example |
---|---|---|---|
get, post, delete |
-d , --data
|
Data to pass for the API request | --data id=cust_123abc |
get, post, delete |
-e , --expand
|
Response attributes to expand inline. Available on all API requests, see the documentation for specific objects that support expansion | --expand customer,charges |
get, post, delete |
-i , --idempotency
|
Sets the idempotency key for your request, preventing replaying the same requests within a 24 hour period. | --idempotency foobar123456 |
get, post, delete |
-v , --api-version
|
Set the Stripe API version to use for your request | --api-version 2019-03-14 |
get, post, delete | --stripe-account |
Set a header identifying the connected account for which the request is being made | --stripe-account m_1234acbd |
get, post, delete |
-s , --show-headers
|
Show headers on responses to GET, POST, and DELETE requests | --show-headers |
delete |
-c , --confirm
|
Automatically confirm the command being entered. WARNING: This will result in NOT being prompted for confirmation for certain commands | --confirm |
get |
-l , --limit
|
A limit on the number of objects to be returned, between 1 and 100 (default is 10) | --limit 50 |
get |
-a , --starting-after
|
Retrieve the next page in the list. This is a cursor for pagination and should be an object ID | --starting-after cust_1234abc |
get |
-b , --ending-before
|
Retrieve the previous page in the list. This is a cursor for pagination and should be an object ID | --ending-before cust_1234abc |