What does Stripe 'Invalid API Key provided' mean?
The request sent a key Stripe doesn't recognize for that account or mode, often test vs live mixed up, a typo, or an empty env var. An expired key that was rolled or expired in the Dashboard returns api_key_expired. Copy the current key from the Dashboard's API keys page into a server-side env var. Only pk_ keys belong in the browser.
Last updated 2026-11-25 · Reviewed by ProofForge
The exact error
{"error":{"message":"Invalid API Key provided: sk_live_****abcd","type":"invalid_request_error"}}
error code: api_key_expired ("The API key provided has expired.")Why it happens
- Using an
sk_test_key against live objects (or the reverse). - The key was rolled and the old one has expired.
- Production env var not set, so the SDK gets
undefined. - A publishable
pk_key used where a secret key is required.
How to fix it
- Get the key for the right mode from the Dashboard's API keys page.
- Set
STRIPE_SECRET_KEYon the server only and restart or redeploy. - Prefer restricted keys (
rk_) with only the permissions your integration needs.
// server
import Stripe from 'stripe'
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)
// browser: only pk_live_ / pk_test_Check it's fixed
Make one test API call from the server, and confirm no sk_live_ or rk_live_ string appears in your built frontend JS.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
FAQ
Is the publishable key safe to expose?
Yes, pk_ keys are designed for the browser. Secret (sk_) and restricted (rk_) keys are not.
I rolled my key. Why did the old one keep working?
When rolling, Stripe lets you set an expiry of up to 7 days so you can migrate. After that it returns an expired-key error.
What if the secret key was public?
Roll it immediately and review request logs. See /leaked-keys/stripe.