← 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

How to 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):

    import Stripe from 'stripe';
    export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
  3. Add the variable on Vercel for every environment that needs it and redeploy.

Prevent this next time

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