← All errors · StripeStripe payments & webhook errors
You did not provide an API key
Exact error
You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth.
What it means
A request reached Stripe with no secret key at all, usually because the environment variable was undefined.
Likely causes
- STRIPE_SECRET_KEY not set in this environment (local vs Vercel production/preview).
- Stripe client initialized in browser code where server env vars are not available.
How to fix it
Log whether the variable exists (never log the value): `console.log(!!process.env.STRIPE_SECRET_KEY)`.
Initialize Stripe only in server code (route handlers, server actions):
import Stripe from 'stripe'; export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);Add the variable on Vercel for every environment that needs it and redeploy.
Prevent this next time
- Test webhooks locally with `stripe listen` and the Stripe test cards before going live.
- Check webhook delivery attempts in the Stripe Dashboard after each deploy, and keep test and live keys clearly separated per environment.
FAQ
What does "You did not provide an API key" mean?
A request reached Stripe with no secret key at all, usually because the environment variable was undefined.
What usually causes it?
STRIPE_SECRET_KEY not set in this environment (local vs Vercel production/preview). Stripe client initialized in browser code where server env vars are not available.
How do I fix it?
1. Log whether the variable exists (never log the value): `console.log(!!process.env.STRIPE_SECRET_KEY)`. 2. Initialize Stripe only in server code (route handlers, server actions): 3. Add the variable on Vercel for every environment that needs it and redeploy.
Related errors
Get new fixes weekly
No spam. Unsubscribe anytime. Privacy