--- title: "How to Rotate Stripe API Keys Without Downtime" canonical: "https://infisical.com/blog/stripe-api-key-rotation" published: "2026-11-17" tags: ["Technical"] source-index: https://infisical.com/llms.txt ---

# How to Rotate Stripe API Keys Without Downtime

Stripe API keys [sprawl](https://infisical.com/blog/what-is-secret-sprawl) just like any other secret. They live in environments of services, CI secrets, staging clusters, and `.env` files.

Rotating a Stripe key used to mean manual work: Issuing a new key, revoking the old one, and pasting the new key to the dozens of places it’s needed (and potentially missing one and causing downtime).

Infisical now automates Stripe key rotation. It’s the first secrets manager with built-in Stripe API key rotation: It automatically creates a new key and expires the old one without deploying a function or writing custom code.

## Why rotate Stripe API keys on a schedule?

Regularly rotating API keys is good security hygiene. It invalidates keys periodically to neutralize leaks and invalidate credentials that exist on devices that shouldn’t have them. Stripe's own [key best practices](https://docs.stripe.com/keys-best-practices) recommend periodically rotating the keys because a rotation forces you to know every key and where it’s used. Some compliance requirements also make implicit or explicit demands of credential rotation.

Until now, this was always manual work: you had to navigate to Stripe’s API key page and click *Rotate key*, choose when the old key should expire, and then update the new secret value where it’s needed.

After this, watch request logs in Stripe to ensure it’s working. To be cautious, Stripe advises rolling the new key gradually, starting with a few servers and expiring the old key only once it receives no more requests.

But this doesn’t scale and is unreliable.

### Why manual API key rotation doesn’t scale

The steps in the dashboard take less than a minute, but it’s impossible to know every place the Stripe API key is used: In server environment variables, CI secrets, Kubernetes, developer `.env` files… the list goes on. If you miss a copy, you risk downtime of your payments service or grumpy Slack messages from engineers whose work ground to a halt.

That work is annoying, so most organizations rotate secrets infrequently. And when they do, they often rely on reminders that they might miss.

## How to rotate Stripe API keys automatically with Infisical

Infisical's [Stripe API key rotation](https://infisical.com/docs/documentation/platform/secret-rotation/stripe-api-key) replaces the manual process. Infisical connects to your Stripe account through a Stripe App, creates a new key on your desired interval, stores it as a secret, and expires old keys. Your applications read that secret from Infisical by name, so its value changes without anyone copying it.

This rotation maintains two active credential sets with overlapping validity, ensuring zero downtime during rotation cycles.

### Connect your Stripe account

Infisical needs permission to create and expire keys on your account. In your Infisical project, go to **Integrations**, then **App Connections**, and add a [Stripe connection](https://infisical.com/docs/integrations/app-connections/stripe). Select **Connect to Stripe**, and install the Infisical Stripe app on your account.

### Create the rotation

From the secrets dashboard, select **Add Secret Rotation** and choose **Stripe API Key**. The settings are:

- **Environment** and **Stripe Connection**: where the rotated secret lives, and which connection creates the keys.
- **Rotation Interval**: the number of days between rotations.
- **Rotate At**: the time of day a rotation runs once the interval is up, so you can schedule it for low traffic.
- **Key Name**: what each generated key is called in the Stripe Dashboard. Infisical appends a timestamp so the old and new keys are easy to tell apart. Naming it after the service, such as `checkout-service`, tells anyone reading the Stripe Dashboard what the key is for.
- **Permissions**: the same choices as a restricted key in Stripe. Stripe has no "all access" option for restricted keys, so you grant each resource your service uses.
- **API Key**: the name of the Infisical secret that holds the current key, such as `STRIPE_API_KEY`.

Creating the rotation creates the first key in Stripe right away and stores it under the mapped name.

The same rotation can be created through the [Infisical API](https://infisical.com/docs/api-reference/endpoints/secret-rotations/stripe-api-key/create):

```bash
curl --request POST \
  --url https://us.infisical.com/api/v2/secret-rotations/stripe-api-key \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "checkout-service-stripe",
    "projectId": "<project-id>",
    "connectionId": "<stripe-connection-id>",
    "environment": "prod",
    "secretPath": "/",
    "isAutoRotationEnabled": true,
    "rotationInterval": 30,
    "rotateAtUtc": { "hours": 3, "minutes": 0 },
    "parameters": {
      "keyName": "checkout-service",
      "permissions": ["payment_intent_write", "customer_write", "product_read"]
    },
    "secretsMapping": {
      "apiKey": "STRIPE_API_KEY"
    }
  }'
```

## FAQ

### How often should you rotate Stripe API keys?

Stripe doesn't prescribe an interval. With dual-phase rotation, a key lives for up to two intervals, and every service needs to pick up the new value at least once per interval. A 30-day interval suits most services that deploy weekly or more often. Go shorter if your services restart daily, and longer if some process can't be restarted that often.

### Can Infisical rotate my existing `sk_` secret key?

No. Infisical creates and rotates restricted keys, and it never changes or expires a key it didn't create. To move off a secret key, set up the rotation, point your services at the rotated secret, and delete the `sk_` key in the Stripe Dashboard once its traffic stops.

To start rotating your Stripe API keys automatically, [sign up](https://app.infisical.com/signup) or [talk to an expert](https://infisical.com/talk-to-us) about your setup.

Human mode