# Stripe API keys: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/stripe
Last checked: 2026-10-25

Stripe API keys are created and managed on the Dashboard **API keys** page. Stripe recommends restricted keys (`rk_`) over unrestricted secret keys (`sk_`) for server code, and each mode (sandbox or live) has its own set of keys.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Publishable key | `pk_live_` | No | Client-side use with Stripe.js, Elements and mobile SDKs; cannot perform sensitive operations | Cannot be expired |
| Restricted key (RAK) | `rk_live_` | Yes | Only the permissions you grant when creating it | Does not expire unless you expire or rotate it, or schedule a rotation |
| Secret key | `sk_live_` | Yes | Unrestricted access to all Stripe APIs | Does not expire unless you expire or rotate it, or schedule a rotation |
| Organization key | `sk_org_` | Yes | Organization-level access across multiple Stripe accounts | — |

## How to create a Stripe key

1. Sign in to the Stripe Dashboard and switch to the sandbox or live mode you need.
2. Open the [API keys](https://dashboard.stripe.com/apikeys) page.
3. Click **Create secret key** (or create a restricted key from the Restricted keys list).
4. Enter the verification code Stripe sends by email or text, name the key and click **Create**.
5. Copy the key and store it in a secrets vault. In live mode you cannot reveal a key you created yourself again.

## Limiting what the key can do

Use restricted API keys (`rk_`) and grant only the resources the integration needs. You can also attach an access policy (IP address ranges, or ASN, country and threat-source rules) to a key under **Manage access policy**.

## How to rotate a Stripe key

1. On the [API keys](https://dashboard.stripe.com/apikeys) page, open the overflow menu (⋯) for the key.
2. Select **Rotate key** and choose an **Expiration** for the old key (now, or a later time).
3. Click **Rotate API key**, then copy and store the new key.
4. Deploy the new key, check the old key's request logs, then let the old key expire.

## How to revoke a Stripe key

1. On the [API keys](https://dashboard.stripe.com/apikeys) page, open the overflow menu (⋯) for the key.
2. Select **Expire key** and confirm. Code using that key stops working immediately.

## If the key leaked

1. Rotate the key from the API keys page and choose **Now** as the expiration so the exposed key stops working.
2. Check the key's request logs (overflow menu, **View request logs**) for activity you do not recognise.
3. Update your secrets vault and redeploy with the new key.
4. Attach an access policy to the replacement key so requests from unknown sources are blocked.

## Gotchas

- Webhook signing secrets are not API keys. Find them under each endpoint in the Dashboard Webhooks section.
- In live mode a secret or restricted key you created yourself is shown once and cannot be revealed later.
- From November 30, 2026, Stripe MCP stops accepting full-access secret keys and restricted keys without the Agent tag; use OAuth or an agent API key.
- A key unused for payouts or transfers for over 180 days can have limited access until you click **Restore access**.

## Using this key with AI agents (BotPassword)

- `run_with`: Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
- `http_request`: Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
- `rotate`: Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.
- `store_secret`: Saves a value the agent already holds as a new vault item.

## FAQ

### Where do I find my Stripe API key?

In the Dashboard on the [API keys](https://dashboard.stripe.com/apikeys) page, with the sandbox or live mode toggled to the one you need.

### What is the difference between sk_ and rk_ Stripe keys?

`sk_` keys have unrestricted permissions on all Stripe APIs; `rk_` restricted keys only have the permissions you choose. Stripe recommends restricted keys.

### Can I view my Stripe live secret key again?

Only keys Stripe created for you can be revealed in live mode. If you created the key yourself and lost it, rotate or delete it and create another.

### How do I rotate a Stripe API key without downtime?

Use **Rotate key** in the Dashboard and pick a later expiration; both keys work for up to 7 days.

### Can an AI agent use my Stripe key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a `.env` file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with `run_with`, `http_request`, `store_secret`, so the agent gets the result and never the value.

## Sources

- https://docs.stripe.com/keys
- https://docs.stripe.com/mcp
- https://docs.stripe.com/cli
