← All errors · Stripe

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.

Related errors

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy