API keys (2024)

Use API keys to authenticate API requests.

Stripe authenticates your API requests using your account’s API keys. If a request doesn’t include a valid key, Stripe returns an invalid request error. If a request includes a deleted or expired key, Stripe returns an authentication error.

Use the Developers Dashboard to create, reveal, delete, and roll API keys. To access your v1 API keys, select the API Keys tab in your Dashboard.

Test mode versus live mode API keys (1)

All Stripe API requests occur in either test mode or live mode. Use test mode to access test data, and live mode to access actual account data. Each mode has its own set of API keys. Objects in one mode aren’t accessible to the other. For instance, a test-mode product object can’t be part of a live-mode payment.

Live mode key access

You can only reveal a live mode secret or restricted API key one time. If you lose it, you can’t retrieve it from the Dashboard. In that case, roll it or delete it and create a new one.

Type When to useObjectsHow to useConsiderations
test modeUse test mode, and its associated test API keys, as you build your integration. In test mode, card networks and payment providers don’t process payments.API calls return simulated objects. For example, you can retrieve and use test account, payment, customer, charge, refund, transfer, balance, and subscription objects.Use test credit cards and accounts. You can’t accept real payment methods or work with real accounts.Identity doesn’t perform any verification checks. Also, Connect account objects don’t return sensitive fields.
live modeUse live mode, and its associated live API keys, when you’re ready to launch your integration and accept real money. In live mode, card networks and payment providers do process payments.API calls return real objects. For example, you can retrieve and use real account, payment, customer, charge, refund, transfer, balance, and subscription objects.Accept real credit cards and work with customer accounts. You can accept actual payment authorizations, charges, and captures for credit cards and accounts.Disputes have a more nuanced flow and a simpler testing process. Also, some payment methods have a more nuanced flow and require more steps.

Secret and publishable keys API keys (2)

All accounts have a total of four API keys by default—two for test mode and two for live mode:

  • Test mode secret key: Use this key to authenticate requests on your server when in test mode. By default, you can use this key to perform any API request without restriction.
  • Test mode publishable key: Use this key for testing purposes in your web or mobile app’s client-side code.
  • Live mode secret key: Use this key to authenticate requests on your server when in live mode. By default, you can use this key to perform any API request without restriction.
  • Live mode publishable key: Use this key, when you’re ready to launch your app, in your web or mobile app’s client-side code.

Testing and development

Use only your test API keys for testing and development. This ensures that you don’t accidentally modify your live customers or charges.

You can find your secret and publishable keys in API keys. When you’re logged in, Stripe’s documentation automatically populates code examples with your test mode API keys (only you can see these values). If you’re not logged in, our code examples include randomly generated API keys. You can replace them with your own test keys or log in to see the code examples populated with your test API keys. If you can’t view your API keys, ask the owner of your Stripe account to add you to their team, with the proper permissions.

The following table shows randomly generated examples of secret and publishable test API keys:

Restricted API keys

The Dashboard can also generate restricted API keys, enabling customizable and limited access to the API. However, Stripe doesn’t offer any restricted keys by default.

Type Value When to use
Secretsk_test_26PHem9AhJZvU623DfE1x4sdOn 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. Don’t expose this key on a website or embed it in a mobile application.
Publishablepk_test_qblFNYngBkEdjEZ16jxxoWSMOn the client side: Can be publicly accessible in your web or mobile app’s client-side code (such as checkout.js) to securely collect payment information, such as with Stripe Elements. By default, Stripe Checkout securely collects payment information.
RestrictedA string that starts with rk_test_In microservices: Must be secret and stored securely in your microservice code to call Stripe APIs. Don’t expose this key on a website or embed it in a mobile application.

Keep your keys safe API keys (3)

Anyone can use your live mode secret API key to make any API call on behalf of your account, such as creating a charge or performing a refund. Keep your keys safe by following the secret API keys best practices.

Customize API access with restricted API keys API keys (4)

To provide limited access to the API, create restricted API keys. You can configure a restricted API key to allow read or write access to specific API resources. When using microservices that interact with the API on your behalf, define restricted keys that allow only the minimum access those microservices require. For example, if you use a dispute monitoring service, create a restricted key that only provides read access to dispute-related resources. That key allows the service to get the data it needs, but doesn’t allow it to make any changes or access any other data.

Restricted keys can’t interact with many parts of Stripe’s API because they’re only intended to reduce risk when using or building microservices. Don’t use restricted keys as an alternative to your account’s secret or publishable API keys during development of your Stripe integration.

Permission errors

If you use a restricted API key in a call it doesn’t have access to, Stripe raises a permission error.

Limit the IP addresses that can send API requests API keys (5)

You can increase the security of a secret or restricted key by limiting the IP addresses that can use it to send API requests. Additionally, you can restrict a key to one or more IP addresses or to a range of IP addresses.

Reveal a secret API key for test mode API keys (6)

In test mode, you can reveal a secret API key as many times as you want.

To reveal a secret key in test mode:

  1. In the Developers Dashboard, select the API keys tab.
  2. In the Standard keys list, in the Secret key row, click Reveal test key.
  3. Copy the key value by clicking it.
  4. Save the key value.
  5. Click Hide test key.

Reveal a secret or restricted API key for live mode API keys (7)

For security, in live mode Stripe only shows you a secret or restricted API key one time. Store the key in a safe place where you won’t lose it. To help yourself remember where you stored it, you can leave a note on the key in the Dashboard. If you lose the key, you can roll it or delete it and create another.

You can't reveal a live mode secret key that you created

After you create a secret or restricted API key in live mode, we display the value before you save it. You must copy the value before saving it because you can’t reveal it later. You can only reveal a default secret key or a key generated by a scheduled roll.

To reveal a secret or restricted key in live mode and attach a note:

Note

The API keys link here opens in live mode.

  1. In the Developers Dashboard, select the API keys tab.
  2. In the Standard keys list or Restricted keys list, in the row for the key you want to reveal, click Reveal live key.
  3. Copy the key value by clicking it.
  4. Save the key value.
  5. Click Hide test key.
  6. Click the overflow menu () next to the key, then select Edit key….
  7. In the Note field, enter the location where you saved the key, then click Save.
  8. If you created the key before Stripe introduced this feature, click Hide live key.

Note

Keys that you created before Stripe introduced this feature aren’t automatically hidden when they’re revealed. You must manually hide them.

Roll an API key API keys (8)

Rolling a key revokes it and generates a replacement key. You can roll a key immediately or schedule a key to roll after a certain time. Roll a key in scenarios such as the following examples:

  • If you’re in live mode and you lose a secret key or restricted key, you can’t recover it from the Dashboard and must replace it.
  • If a secret or restricted key is compromised, you need to revoke it to block any potentially malicious API requests that might use it.
  • Your policy requires rotating keys at certain intervals.

To roll an API key:

  1. Open the API keys page.
  2. In the row for the key you want to roll, click the overflow menu (), then select Roll key….
  3. Choose an expiration date from the Expiration dropdown.
  4. Click Roll API key.
  5. The dialog displays the new key value. Copy it by clicking it.
  6. Save the key value. You can’t retrieve it later.
  7. In the Add a note field, enter the location where you saved the key and click Done or Save.

If you chose Now for the Expiration, we delete the old key. If you selected a different time, you can see the time remaining until the key expires below its name.

Regardless of the old key’s expiration time, the new key is ready to use immediately.

When you roll a publishable key, the replacement key’s name is always Publishable key. When you roll a secret key, the replacement key’s name is always Secret key. When you roll a restricted key, the replacement key’s name is the same as the rolled key. You can rename a secret or restricted key by clicking its overflow menu and selecting Edit key….

Delete a secret or restricted API key API keys (9)

If you delete a key, any code that uses that key can no longer make API calls. Create a new key and update the code to use it.

Note

You can’t delete a publishable key.

To delete a key:

  1. In the Developers Dashboard, select the API keys tab.
  2. Locate the key you want to delete in either the Standard keys or Restricted keys list. Click the overflow menu icon () in the row of that key, then select Delete key….
  3. In the Delete API key dialog, if you’re sure that you want to delete the key, click Delete key. Otherwise, click Cancel.

Create a secret API key API keys (10)

To create a secret API key:

  1. Open the API keys page.
  2. Click Create secret key.
  3. Stripe sends a verification code to your email address or in a text message. (As with any email or text message, it might not arrive immediately.) Enter the code in the dialog. If the dialog doesn’t continue automatically, click Continue.
  4. Enter a name in the Key name field.
  5. Click Create.
  6. The dialog displays the new key value. Copy it by clicking it.
  7. Save the key value. You can’t retrieve it later.
  8. In the Add a note field, enter the location where you saved the key and click Done.

Create a restricted API key API keys (11)

A restricted API key only allows the level of access that you specify.

To create a restricted API key:

  1. Open the API keys page.
  2. You can create a restricted key from scratch or start by cloning an existing restricted key.
    • To create a restricted key from scratch, click Create restricted key. In this case, the default value for all permissions is None.
    • To clone an existing key, in the row for the key you want to clone, click the overflow menu (), then select Duplicate key…. In this case, the default value for each permission is its value in the cloned key.
  3. In the Key name field, enter a name. If you cloned an existing key, the default name is the cloned key’s name.
  4. For each resource you want the new key to access, select the permission for this key to allow. If you use Connect, you can also select the permission for this key to allow when accessing connected accounts. Available permissions are None, Read, or Write.
  5. Click Create key.
  6. Stripe sends a verification code to your email address or in a text message. (As with any email or text message, it might not arrive immediately.) Enter the code in the dialog. If the dialog doesn’t continue automatically, click Continue.
  7. The dialog displays the new key value. Copy it by clicking it.
  8. Save the key value. You can’t retrieve it later.
  9. In the Add a note field, enter the location where you saved the key and click Done.

Limit secret or restricted keys to a list or range of IP addresses API keys (12)

To limit API requests using a key to one or more specific IP addresses or to a range of IP addresses:

Valid IP address ranges

You can specify any valid CIDR range. For example, a valid range could be 100.10.38.0 - 100.10.38.255, specified as 100.10.38.0/24. All addresses in the range must start with 100.10.38.

  1. Open the API keys page.
  2. In the Standard keys list or Restricted keys list, in the row for the key you want to reveal, click the overflow menu (), then select Manage IP restrictions….
  3. Click Limit use to a set of IP addresses.
  4. Enter an IP address or range of IP addresses:
    • For an individual IP address, enter it in the IP address field.
    • For a range of IP addresses, enter the range in Classless Inter-Domain Routing (CIDR) notation. In the IP Address field, enter the first address in the range. In the CIDR field, enter the network prefix size.
    • You can also select the Bulk manage tab and enter individual IP addresses and ranges, separated by spaces. Changes you make in one tab appear in the other tab.
  5. To add another address or range, click + Add.
  6. Click Save.

Change a secret or restricted API key’s name or note API keys (13)

To change the name or note text of a secret or restricted key:

  1. Open the API keys page.
  2. In the row for the key you want to change, click the overflow menu (), then select Edit key….
  3. If you want to change the name, in Key name, enter the new name.
  4. If you want to change the note text, in Note, enter the new note text.
  5. Click Save.

View the API request logs API keys (14)

To open the API request logs, click the overflow menu () for any key, then select View request logs. Opening the logs redirects you to the main Stripe Dashboard.

API keys (2024)

FAQs

What is in an API key? ›

An application programming interface (API) key is a code used to identify and authenticate an application or user. API keys are available through platforms, such as a white-labeled internal marketplace. They also act as a unique identifier and provide a secret token for authentication purposes.

Where can I find my API keys? ›

To find an API key, you usually need to visit the website or platform that offers the API you want to use. The process can vary depending on the specific API provider, but you typically need to sign up for an account, create a project or application, and then generate an API key within that project.

What is the difference between API and API key? ›

Software applications exchange sensitive data with external services through an API. API keys serve as a project authorization mechanism to regulate usage by permitted projects. To use an API, the project must present the correct API credentials to access the abstracted software functions.

Are API keys still used? ›

Yes, by tracking API keys, you can gain insights into how your application is being used, such as understanding which users make the most requests or which keys are associated with high-traffic applications.

What is an API and examples? ›

API integrations are software components that automatically update data between clients and servers. Some examples of API integrations are when automatic data sync to the cloud from your phone image gallery, or the time and date automatically sync on your laptop when you travel to another time zone.

Can you use an API without a key? ›

Luckily, there's APIs with zero authentication requirements. An API without a key is perfect for beginners and web developers looking to access sample data sets for their apps without restrictions.

Are API keys free? ›

API Keys is free of charge. If you use Cloud Endpoints to manage your API, you might incur charges at high traffic volumes.

What is the advantage of API key? ›

API key can identify application traffic so that if there is suspicious activity or error, it can be identified early on. This function helps developers set API usage limits and ensures that only permitted traffic can access the API.

What can someone do with my API key? ›

If a key falls into the wrong hands, it can easily be exploited. Since API keys rarely expire, a hacker can use the key indefinitely unless the key's owner regenerates or deactivates the key.

Can someone else use my API key? ›

To keep your account secure we recommend that you don't share your API Key with anyone. Instead of sharing your key, you can invite teammates to be part of your organization account through the Members page. When they join, they'll get access to their own API Key, which will keep your account even safer.

What can I use instead of API key? ›

There are two main ways to secure REST APIs: API keys and OAuth tokens. API keys are good for read-only data, but not as good for authorization. OAuth tokens are better for authorization, but can be more complex to implement. The best way to secure a REST API depends on the specific needs of the application.

What are the key components of an API? ›

API Request

It contains several key components, including the endpoint (the URL of the API), the method (GET, POST, PUT, DELETE), parameters (data sent with the request), request headers (metadata about the request), and the request body (data sent to the server).

What is an API key in ChatGPT? ›

A ChatGPT API key is a unique identifier that allows you to access and utilize the ChatGPT API. This API serves as an interface between ChatGPT and external applications. By integrating the ChatGPT API, you can seamlessly incorporate ChatGPT's capabilities into your own applications.

What is the secret key of API key? ›

Secret API keys are unique identifiers used by applications to authenticate and authorize access to an API. They serve as a form of authentication, allowing the API to verify the identity of the requesting application.

Are API keys passwords? ›

API keys can't authenticate the individual user making the request, only the project or application sending the request. API keys are like passwords — only effective if the owner stores them securely. If a key falls into the wrong hands, it can easily be exploited.

Top Articles
Consejos para optimizar tu bandeja de entrada de Gmail
TextView: asignación de etiquetas
7 C's of Communication | The Effective Communication Checklist
Cranes For Sale in United States| IronPlanet
Walgreens Pharmqcy
13 Easy Ways to Get Level 99 in Every Skill on RuneScape (F2P)
Is Sportsurge Safe and Legal in 2024? Any Alternatives?
Craigslist Dog Sitter
J Prince Steps Over Takeoff
Robot or human?
Magicseaweed Capitola
Hair Love Salon Bradley Beach
Interactive Maps: States where guns are sold online most
Bcbs Prefix List Phone Numbers
Letter F Logos - 178+ Best Letter F Logo Ideas. Free Letter F Logo Maker. | 99designs
WEB.DE Apps zum mailen auf dem SmartPhone, für Ihren Browser und Computer.
How Much You Should Be Tipping For Beauty Services - American Beauty Institute
Tamilyogi Proxy
Wausau Marketplace
Satisfactory: How to Make Efficient Factories (Tips, Tricks, & Strategies)
Ahrefs Koopje
Curver wasmanden kopen? | Lage prijs
Hannaford To-Go: Grocery Curbside Pickup
yuba-sutter apartments / housing for rent - craigslist
Horn Rank
Albert Einstein Sdn 2023
Victory for Belron® company Carglass® Germany and ATU as European Court of Justice defends a fair and level playing field in the automotive aftermarket
12657 Uline Way Kenosha Wi
Bfsfcu Truecar
Kaliii - Area Codes Lyrics
Best Restaurants Ventnor
Account Now Login In
Strange World Showtimes Near Regal Edwards West Covina
Chattanooga Booking Report
All Things Algebra Unit 3 Homework 2 Answer Key
Hellgirl000
„Wir sind gut positioniert“
Wo ein Pfand ist, ist auch Einweg
Letter of Credit: What It Is, Examples, and How One Is Used
Rocky Bfb Asset
Royals Yankees Score
Quiktrip Maple And West
Ehc Workspace Login
Menu Forest Lake – The Grillium Restaurant
Movie Hax
Benjamin Franklin - Printer, Junto, Experiments on Electricity
Bellelement.com Review: Real Store or A Scam? Read This
Electric Toothbrush Feature Crossword
Puss In Boots: The Last Wish Showtimes Near Valdosta Cinemas
Haunted Mansion Showtimes Near The Grand 14 - Ambassador
Latest Posts
Article information

Author: Francesca Jacobs Ret

Last Updated:

Views: 5886

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Francesca Jacobs Ret

Birthday: 1996-12-09

Address: Apt. 141 1406 Mitch Summit, New Teganshire, UT 82655-0699

Phone: +2296092334654

Job: Technology Architect

Hobby: Snowboarding, Scouting, Foreign language learning, Dowsing, Baton twirling, Sculpting, Cabaret

Introduction: My name is Francesca Jacobs Ret, I am a innocent, super, beautiful, charming, lucky, gentle, clever person who loves writing and wants to share my knowledge and understanding with you.