| [ Web Proxy ] |
| Viewing: https://docs.stripe.com/keys | [Back] [Original] |
Stripe authenticates API requests using your accounts API keys. If a request doesnt 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 rotate API keys. You can access your API keys on the API keys tab.
pk_test_ (publishable), rk_test_ (restricted), and sk_test_ (secret). They let you test without affecting live data.pk_live_, rk_live_, and sk_live_. See Switch to live mode for instructions.When you sign up for a Stripe account, we create three types of API keys for you:
| Type | Safe to expose | Description |
|---|---|---|
Restricted API key (RAK)rk_... | No | API key with permissions you control. Limit the damage to your business that a bad actor could cause if they obtained your key. Create as many RAKs as you want and assign them to different parts of your application. This guide explains how to configure and use RAKs. |
| Publishable API key | Yes | API key that you can put in front-end code or applications you distribute. |
Secret API keysk_... | No | API key that has unrestricted permissions on all Stripe APIs. Because you cant limit their permissions, we dont recommend using secret keys for new use cases, and for existing integrations, we recommend migrating secret key usage to RAKs. |
Organization API keysk_org_... | No | API key that works at the organization level. Same as account-level restricted or secret keys, but operates at the organization level to manage multiple Stripe accounts at once. This guide explains how to configure and use organization API keys. |
We also support managed API keys issued by certain hosting platforms. Managed keys are secret API keys that a hosting platform delivers directly to your hosted applications. You dont need to handle managed keys directly; your hosting provider issues and rotates them for you.
Webhook signing secrets arent API keystheyre per-webhook secrets that your webhook receiver uses to authenticate that webhooks actually came from Stripe. You can find the signing secret for each webhook endpoint in the Webhooks section of the Dashboard.
If you created your Stripe account before May 2026, you might not have any restricted API keys. We recommend creating RAKs and migrating from secret keys.
Youre responsible for managing your API keys safely. Read our guide to best practices for protecting API keys.
All Stripe API requests occur in either a sandbox or live mode. You can use a sandbox to test your integration and access test data, and live mode to access actual account data. Each mode has its own set of API keys, and objects in one mode arent accessible to the other. For example, a sandbox product object cant be part of a live mode payment.
| Type | When to use | Objects | How to use | Considerations |
|---|---|---|---|---|
| Sandboxes | Use a sandbox, and its associated test API keys, as you build your integration. In a sandbox, card networks and payment providers dont 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 cant accept real payment methods or work with real accounts. | Identity doesnt perform any verification checks. Also, Connect account objects dont return sensitive fields. |
| Live mode | Use live mode, and its associated live API keys, when youre 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. |
Only publishable keys are safe to expose outside your applications backend. Youre responsible for protecting other Stripe API keys, including restricted API keys. Here are some ways you can protect your keys:
For a comprehensive guide, see best practices for managing secret API keys. We also maintain a library of skills to help AI agents follow these best practices.
Use the Dashboard to create, reveal, modify, delete, and rotate your API keys.
Use restricted API keys (RAKs) for most use cases. You can use a RAK to assign the exact permissions your integration needs, which can help reduce the damage a bad actor could cause to your business if they obtained your key.
Create an unrestricted secret API key only when your integration requires access to all Stripe APIs and resources without restriction. If a bad actor obtains your secret key, they can harm your business. We recommend using RAKs instead.
When you create a secret key in live mode, we display it once before you save it. Copy the key before saving it because you cant reveal it later.
In live mode, you can reveal only API keys that we create for you, such as a default secret key or a key generated by a scheduled rotation. In sandbox mode, you can always see all of your API keys, including restricted and secret keys.
Store sensitive keys in a place where you wont lose them, such as a secrets vault provided by your platform. Dont put keys in your applications code.
Publishable API keys arent sensitive, so we show them by default and you dont need to do anything to reveal them.
We cant recover keys that youve forgotten or lost access to. If you lose a key, rotate or delete it and create another.
You can reveal only live-mode RAKs that we created for you. If you create a RAK yourself, you cant reveal it after youve seen it once.
You can reveal only live-mode secret keys that we created for you. If you create a secret key yourself, you cant reveal it after youve seen it once.
Access policies have replaced IP address restrictions. Use policies, not restrictions.
If you expire a secret API key or a restricted API key, you must create a new one and update any code that uses the expired key. Any code that uses the expired key can no longer make API calls.
You cant expire a publishable key.
Rotating an API key revokes it and generates a replacement key thats ready to use immediately. You can also schedule an API key to rotate after a certain time. The replacement key is named as follows:
Publishable key.Secret key.You can rename a secret or restricted API key by editing the key.
Rotate an API key in scenarios such as:
To avoid downtime during key rotation:
An API key might have its access limited if it hasnt been used to create transfers, payouts, or update payout destinations for over 180 days. You cant use a limited access key to create payouts and transfers or to create payout destinations. You can restore access to use the key normally or to perform a blocked action.
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 Stripe Dashboard.
When youre ready to accept real payments, use live mode API keys instead of sandbox (test) keys. On the API keys page, toggle from sandbox mode to live mode. The page now shows your live mode API keys.
Switching API keys is only one step. Review the full go-live checklist to make sure your integration is production ready.
Copy your live mode publishable key (starts with pk_live_) and replace the pk_test_ key in your client-side code. Its safe to embed this key in your code or apps.
Server-side API keys are sensitive, so review our best practices for managing secret API keys. We recommend generating restricted API keys for your server-side code to limit the damage to your business if your keys are ever exposed or compromised.
rk_live_ or sk_live_). Store the key value securely in your server environment.If you use webhooks, update each webhook endpoints URL and copy the new signing secret from the Webhooks section of the Dashboard.
You can restrict access to a key by attaching an access policy to it. If someone attempts a request using a key they cant access, Stripe blocks the request and notifies you.
Stripe recommends configuring access policies on all live mode keys. That notifies you of any unauthorized access, so you can rotate the keys accordingly.
You can manage access by assigning different policies to different keys. For example, you can distinguish between staging and production environments by assigning different policies to their respective keys.
Stripe supports the following types of access policies:
An advanced access policy can use any combination of the following rules:
Selecting multiple rules combines them using AND logic. For example, if you allow ASN 16509 (Amazon), allow the United States, and block Tor exit nodes, then the policy only allows requests from AWS IPs in the US that are not known to be Tor exit nodes. It blocks all other requests.
To create an access policy, go to the Access policies page in your Dashboard and follow these steps:
192.0.2.0/24 covers the range 192.0.2.0192.0.2.255.If the creation succeeded, the new policy appears in the list.
To apply an access policy to an API key, go to the API keys page in your Dashboard and follow these steps:
To remove an access policy from a key, go to the API keys page in your Dashboard and follow these steps:
To make changes to an access policy, go to the Access policies page in your Dashboard and follow these steps:
When you update an access policy, the changes apply immediately to all API keys its assigned to.
To delete an access policy, go to the Access policies page in your Dashboard and follow these steps:
Deleting an access policy immediately removes it from all API keys it was applied to. Those keys allow requests from any source until you apply another policy to them.
| Web Proxy Viewer | New URL | Original Page |