On this page
- Why restricted keys, and why one per service
- The three permission levels
- Starting permission sets by integration
- Hosted Checkout or Payment Links backend
- Subscription billing (SaaS)
- Support or back-office refund tool
- Reporting, analytics and finance exports
- AI agents and coding assistants
- Permissions to keep at None almost everywhere
- How to find the minimum for an existing service
- Restrict where the key can be used, too
- Keep the permissions when you rotate
- A quick checklist
- FAQ
A Stripe restricted key should have Write only on the resources the service creates or changes, Read only on the resources it looks at, and None on everything else. In practice that means a checkout backend needs little more than Checkout Sessions: Write, a reporting job needs a handful of Read permissions and nothing else, and almost no service needs Payouts or Transfers at all. The rest of this guide gives a starting permission set for the integrations most teams run, and a method for trimming any key down to what it really uses.
If you're replacing a key because it leaked or is due for rotation, the procedure lives on our Stripe rotation page. This post is about the step most teams skip while they're there: deciding what the new key is allowed to do.
Why restricted keys, and why one per service
An sk_live_ secret key can call every endpoint in your account: create charges, issue refunds, change payout destinations. A restricted key (rk_live_ in live mode, rk_test_ in a sandbox) can only call what you allow, resource by resource. Stripe now recommends restricted keys over unrestricted secret keys, and says to "create a separate restricted key for each service, and give each key only the Stripe API permissions that each service needs" (Stripe: restricted API keys).
The second half of that sentence matters as much as the first. One restricted key shared by your web app, your billing worker and your analytics job ends up with the union of all their permissions, which is close to a secret key again. Separate keys give you three things:
- A smaller blast radius. If the analytics job's key leaks, the attacker can read reports. They can't refund anything.
- Readable logs. Each key has its own request log, so you can see exactly what one service does.
- Independent rotation. You can roll the email worker's key without touching checkout.
The three permission levels
Each resource on a restricted key is set to None, Read or Write, and the default is None. Stripe's rule is simple: "Write permissions imply read permissions" (Stripe). So you never need to set both.
The permissions reference lists which permission each endpoint needs. A few mappings aren't obvious and catch people out:
| What you want to do | Permission it needs |
|---|---|
| Create or read refunds | Charges (charge_read / charge_write); there is no separate refunds permission |
| Create or read Prices | Plans (plan_read / plan_write), the older name for prices |
| Open a customer billing portal session | Customer portal (customer_portal_write) |
| List or retrieve Events | Events (event_read) |
| Read balance and balance transactions | Balance (balance_read) |
| Apply a customer's cash balance to a PaymentIntent | Customers (customer_write), not PaymentIntents |
| Remove a discount from a subscription | Customers (customer_write) |
| List a customer's saved payment methods | Payment methods (payment_method_read) |
If you hit a missing permission, Stripe doesn't fail silently. It returns an invalid request error whose message explains which permission to add (Stripe). That makes it safe to start narrow: a gap shows up on the first request in your sandbox, not as a mystery in production.
Starting permission sets by integration
These are starting points for common integrations, built from the permissions reference. Your code may call endpoints these don't cover (an expanded object, a lookup you forgot about), so treat each set as a first draft and confirm it in a sandbox, as described in the next section.
Hosted Checkout or Payment Links backend
Your server creates Checkout Sessions and, after payment, reads the session to fulfil the order.
| Resource | Level | Why |
|---|---|---|
| Checkout Sessions | Write | Create and expire sessions; Write covers reading line items |
| Products, Plans (Prices) | Read | Only if your code looks up prices instead of hardcoding price IDs |
| Customers | Write | Only if you create or reuse customers yourself before checkout |
Your webhook handler doesn't need an API key to verify events: that uses the endpoint's whsec_ signing secret. Give it its own key only if it calls back into the API, for example to retrieve the session's line items.
Subscription billing (SaaS)
A typical SaaS backend creates customers, starts and changes subscriptions, and sends users to the billing portal.
| Resource | Level | Why |
|---|---|---|
| Customers | Write | Create customers, update billing details |
| Subscriptions | Write | Create, upgrade, cancel; also covers subscription items and schedules |
| Customer portal | Write | Create billing portal sessions |
| Checkout Sessions | Write | If new subscriptions start through Checkout |
| Plans (Prices), Products | Read | Show plans and prices in your app |
| Invoices | Read | Show invoice history to users |
Leave Charges at None unless the same service issues refunds. Most SaaS apps refund from the Dashboard, which needs no key at all.
Support or back-office refund tool
An internal tool that lets support staff look up a payment and refund it.
| Resource | Level | Why |
|---|---|---|
| Charges | Write | Create refunds |
| PaymentIntents | Read | Find the payment |
| Customers | Read | Search by customer |
This is a key worth an IP restriction (below): it can move money back out of your account, but only from your office or VPN.
Reporting, analytics and finance exports
A job that pulls data into a warehouse or a dashboard should never be able to change anything. Give it Read on exactly what it exports, for example:
| Resource | Level |
|---|---|
| Balance | Read |
| Charges | Read |
| Invoices | Read |
| Subscriptions | Read |
| Payouts | Read |
| Events | Read |
A read-only key still exposes customer data if it leaks, so it is not harmless. But it can't refund, pay out or create anything, which turns a leak from a financial incident into a data one.
AI agents and coding assistants
Stripe's guidance is direct: "RAKs are the recommended type of key for API keys you give to AI agents" (Stripe). An agent reading your support inbox or debugging a billing issue usually needs Read on Customers, Subscriptions, Invoices and PaymentIntents, and nothing else. Add writes one at a time, only when a task really needs them, and use a separate key per agent so its request log reads as a record of what the agent did.
The safest version is an agent that never holds the key at all. Our MCP server lets coding agents use and rotate keys through tools that never return the secret value. Whatever you use, don't paste an sk_live_ key into an agent's context.
Permissions to keep at None almost everywhere
Some resources turn a leaked key from a nuisance into a loss. Grant them only to a service whose whole job is that action:
| Resource | What a leaked key could do with Write |
|---|---|
| Payouts | Trigger payouts from your balance |
| Transfers | Move funds to connected accounts |
| Connected accounts | Change connected accounts, including their external bank accounts |
| Charges | Issue refunds |
| Webhook Endpoints | Add an endpoint and receive a copy of your events |
| Balance settings | Change how your balance is managed |
The webhook line is easy to overlook. A key with Webhook Endpoints: Write can register a new endpoint that receives your events, which include customer and payment data. Set it up from the Dashboard and keep it out of application keys.
Connect platforms have one more subtlety: the permissions reference marks some permissions as "(Direct)" and notes that they "can't authorize Connect call patterns" (permissions reference). Check the reference for each Connect endpoint you call rather than assuming a permission works on behalf of connected accounts.
How to find the minimum for an existing service
Starting sets are a guess. For a service already running on a secret key, measure instead:
- Build it in a sandbox first. Stripe's advice is to create a restricted key in a sandbox before creating a live-mode key (Stripe: restricted API keys). On the API keys page in the Dashboard, click Create restricted key, and either choose a preconfigured set of permissions or start from zero.
- Start broad if you must, then trim. Stripe explicitly allows giving a key broad permissions first, then removing excess ones after reviewing how it is used (Stripe).
- Read the key's request log. Open the key's overflow menu (⋯) and choose View request logs. Every
GETis a read, everyPOSTandDELETEa write. List the endpoints that appear, map each one to its permission in the reference, and that's your set. - Run your test suite and a real flow (checkout, upgrade, refund) against the sandbox key. Fix each invalid request error by adding the permission it names, through ⋯ → Edit key.
- Create the live key with the same permissions, or use ⋯ → Duplicate key on an existing live key as a template, and roll it out.
Take your time over step 3 for anything that runs rarely: a monthly invoice job or an annual renewal path won't show up in a day of logs. If you can't wait for a full cycle, read the code for every Stripe call instead.
Restrict where the key can be used, too
Permissions limit what a key can do; network restrictions limit who can use it. "If your service sends API requests from stable IP addresses, you can restrict your secret or restricted API keys to those addresses" (Stripe). Access policies have since replaced plain IP restrictions: a policy can allow specific IP addresses or CIDR ranges, or allow networks (ASN) and countries while blocking sources such as Tor exit nodes, anonymous VPNs and public proxies. Stripe recommends configuring access policies on all live mode keys, and you attach one through the key's ⋯ → Manage access policy (Stripe: API keys). A refund-capable key that only works from your servers is far less useful to whoever finds it in a log.
Serverless platforms with changing egress IPs make IP restrictions harder. There, keeping permissions tight matters even more.
Keep the permissions when you rotate
Least privilege only holds if rotation preserves it. When you rotate a key from its menu (⋯ → Rotate key), Stripe revokes it and generates a replacement, and a restricted key's replacement keeps the same name (Stripe: API keys). Open the new key's Edit key view afterwards to confirm the permission set is what you expect. If you replace a key by creating a new one instead, use Duplicate key so you start from the old permissions rather than from memory. The rotation page covers the overlap window and expiry options.
If you use Keysquid to distribute Stripe keys, note one requirement from our side: Keysquid checks each key you paste by reading your balance (GET /v1/balance), so the key needs at least Balance: Read. That's a read-only permission and safe to add. Stripe keys are created in the Dashboard rather than through an API, so Keysquid's role for Stripe is assisted: you create the restricted key, and Keysquid verifies it and writes it to every platform that uses it. See how keys and syncs work and the security model for what Keysquid can and can't see.
A quick checklist
- Every service has its own restricted key, named after the service.
- Each resource is None unless the service's request log or code shows it is needed.
- Read-only services have no Write permissions at all.
- Payouts, Transfers, Connected accounts and Webhook Endpoints are None on application keys.
- Keys that can move money are limited to your servers' IP addresses where possible.
- Agents get their own read-mostly keys, never the secret key.
- Rotation keeps the same permissions, and you review them once a year against the request logs.
Frequently asked questions
Does Write permission on a Stripe restricted key include Read?
Yes. Stripe's documentation says write permissions imply read permissions: a key that can write a resource can also read it. Set Read only for resources the service looks at but never changes.
What happens when a restricted key is missing a permission?
Stripe rejects the request with an invalid request error, and the error message says which permission to add. Nothing partial happens, so you find gaps on the first call rather than weeks later.
Can I change a restricted key's permissions after creating it?
Yes. On the API keys page, open the key's overflow menu and choose Edit key. You can also duplicate a key to start a new one with the same permissions.
Which permission does a key need to issue refunds?
Refunds are covered by the Charges resource in Stripe's permissions reference: reading refunds needs charge_read and creating them needs charge_write. There is no separate refunds permission.
Should I give an AI agent a Stripe secret key?
No. Stripe recommends restricted keys for any key you give to an AI agent. Start with read-only access to the few resources the agent needs and add writes one at a time.