Where to find, rotate and revoke your Stripe API key
A practical guide to Stripe API keys: which key type to use, where each one lives, how to rotate without downtime, and what to do if one is exposed.
Checked against these docs on 2026-11-19
Where to find your Stripe API keys
Open the API keys page in the Stripe Dashboard. It is where you create, reveal, expire and rotate keys for the account or sandbox you are viewing. Sandbox (test) and live mode each have their own keys. Webhook signing secrets are not API keys; you find them under Webhooks, on each endpoint.
In live mode you see a new secret key only once, when you create it. After that you can reveal only keys that Stripe created for you, such as a default key or one from a scheduled rotation. If you lose a key, rotate or delete it and create another. In a sandbox you can always see all keys.
Key types: secret, restricted and publishable
Use one restricted key per service (for example billing, reporting and the webhook handler), each with only the permissions that service needs. That limits the damage if one service is compromised.
- Publishable (
pk_test_,pk_live_). Safe to put in front-end code and mobile apps. It can create tokens and PaymentMethods, but can’t create charges or read account data. - Restricted (
rk_test_,rk_live_). You choose each resource’s permission: None, Read or Write. Stripe recommends restricted keys for most use cases and for keys you give to AI agents. - Secret (
sk_test_,sk_live_). Unrestricted access to all Stripe APIs. Stripe doesn’t recommend secret keys for new use cases and recommends migrating existing ones to restricted keys. - Organization (
sk_org_). Works at the organization level to manage several Stripe accounts.
How to rotate a Stripe key without downtime
Rotating revokes the key and creates a replacement. When you rotate in the Dashboard you pick an expiry for the old key from the Expiry dropdown. Both keys work until then, for up to 7 days. If you choose Now, the old key is deleted at once.
- On the API keys page, open the key’s overflow menu and choose Rotate key.
- Pick an expiry for the old key (for example a few days), then click Rotate API key.
- Copy the new key and store it in your secrets vault. In live mode you can’t retrieve it later.
- Roll the new key out gradually, starting with a small subset of servers, and watch your logs for errors.
- Before the old key expires, open View request logs for it and let it lapse only after its request volume has been at zero for a few hours or days.
If you need more than 7 days, create a new key by hand, migrate to it, and expire the old one when you’re done.
How to revoke (expire) a Stripe key
On the API keys page, open the key’s overflow menu and choose Expire key. Code that still uses it can no longer make API calls and gets an authentication error. You can’t expire a publishable key. Request logs stay available through View request logs.
What happens if a Stripe key leaks
Stripe says its security team monitors repositories, package registries, websites and forums for exposed keys. If it finds one it alerts you, and in some cases it deactivates the key proactively. Stripe doesn’t guarantee it will detect every exposed key.
Stripe API keys are also on GitHub’s secret scanning list: partner patterns for secret, restricted and test keys, with push protection on most of them.
Stripe’s steps after an exposure: rotate the key right away, update your backend, confirm the integration works from the new key’s request logs, then delete the compromised key. Then look for payouts, connected accounts or bank accounts you don’t recognise, refund fraudulent charges quickly, and rotate any other keys that may have been exposed.
Recommended rotation practice
- Stripe recommends rotating keys periodically, so you know where every key is used and can replace one at short notice, and writing down a plan for an exposed key. It doesn’t set a fixed interval.
- Rotate whenever someone with access to a key leaves your organization or changes roles.
- Keep secret and restricted keys in a secrets vault or environment variables, never in source code or an app.
- Attach an access policy to live keys (allowed IPs, or ASN, country and threat-source rules) so Stripe blocks and notifies you about use from unexpected places.
- Stripe will never ask you for your secret key.
Sources
Everything above comes from these pages. Providers change their dashboards, so check them for the latest. KeyAtlas is not affiliated with Stripe.