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
- Check the key is loaded at startup
- Initialise the client after loading env
- Use sk_ keys on the server, pk_ keys in the browser
Detailed fix by platform
JavaScript
- 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
- Env — Key present?
- Key type — sk_ vs pk_
- 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:
Similar errors
Most viewed in API
Other ways to find it
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026