Get started with Stripe APIs
Every call to a Stripe API must include an API secret key. After you create a Stripe account, we generate two pairs of API keys for your Stripe user Account—a publishable client-side key and a secret server-side key—for both test mode and live mode. Use the steps on this page to start sending requests in test mode.
To start moving real money with your live mode keys, you need to activate your account.
Initial setup
- Click the Sign in button (in the upper right) to login to the Stripe docs site, and start using your test mode API keys for authenticated requests.
1. Send your first API request
Start experimenting with Stripe APIs using the Stripe Shell to run Stripe CLI commands directly from the Stripe docs site. It operates exclusively in test mode, so you don’t have to worry about creating any real transactions that move money.
- Run the following command to call Create a customer by clicking the play () button.
stripe customers create --email=jane.smith@email.com --name="Jane Smith" --description="My First Stripe Customer"
If everything worked, the command-line displays the following response.
{ "id":
, "object":"cus_LfctGLAICpokzr","customer"
- Optionally, run the same command by passing your API secret key for test mode.
stripe customers create --email=jane.smith@email.com --name="Jane Smith" --description="My First Stripe Customer" --api-key sk_test_4eC39HqLyjWDarjtT1zdp7dc
If everything worked, the command-line displays the following response.
{ "id":
, "object":"cus_LfdZgLFhah76qf","customer"
2. View logs and events in the Dashboard
When you call Stripe APIs, Stripe creates and stores API and Event objects for your Stripe user Account in test or live mode based on the API key you specify. Because the last request used your API secret key for test mode, Stripe stored the objects for your account in test mode. Use these steps to view logs and events from the commands you just ran:
- To view the API request log:
- Open the Logs page.
- Click 200 OK POST /v1 customers.
- To view the Event log:
- Open the Events page.
- Click jane.smith@email.com is a new customer.
3. Store your API keys
Store your API publishable key in your client-side code, and your API secret key as an environment variable to keep it safe. You might consider using a password manager or secrets management service to securely store your API secret key.
Type | Value | When to use |
---|---|---|
Publishable | pk_test_TYooMQauvdEDq54NiTphI7jx | On the client-side. Can be publicly-accessible in your web or mobile app’s client-side code (such as checkout.js) to tokenize payment information such as with Stripe Elements. By default, Stripe Checkout tokenizes payment information. |
Secret | sk_test_4eC39HqLyjWDarjtT1zdp7dc | On the server-side. Must be secret and stored securely in your web or mobile app’s server-side code (such as in an environment variable or credential management system) to call Stripe APIs. |
This wraps up the get started guide. See the links below to continue exploring with the Stripe Shell or use our quickstarts to setup your local development environment in only a few steps.