No API key provided 🔌 API

Stripe: You did not provide an API key. You need to provide your API key in the Authorization header

The request reached the API without an API key — the environment variable wasn’t loaded or the SDK wasn’t initialised with it.

Seen on: REST API

Meaning

Stripe (and many APIs) return 401 with this message when Authorization is missing. Common: undefined env vars in production, initialising the SDK before dotenv, or using the publishable key on the server.

Common causes

  • Secret key environment variable missing
  • SDK initialised with undefined
  • Authorization header stripped by a proxy
  • Using the publishable key where a secret key is needed

⚡ Quick fix

  1. Check the key is loaded at startup
  2. Initialise the client after loading env
  3. Use sk_ keys on the server, pk_ keys in the browser

Detailed fix by platform

JavaScript

  1. javascript
    import "dotenv/config";
    if (!process.env.STRIPE_SECRET_KEY) throw new Error("STRIPE_SECRET_KEY missing");
    const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

How to diagnose

  1. Env — Key present?
  2. Key type — sk_ vs pk_
  3. Header — Authorization sent?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.