← All errors · StripeStripe payments & webhook errors

Invalid API Key provided

Exact error

Invalid API Key provided: sk_test_****

What it means

Stripe rejected the secret key sent with the request (authentication_error).

Likely causes

How to fix it

  1. Copy the secret key again from Dashboard → Developers → API keys, with no quotes or trailing spaces.

  2. Keep secret keys server-side only:

    # .env.local
    STRIPE_SECRET_KEY=sk_test_...
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
  3. Update the variable on your host (e.g. Vercel) and redeploy.

  4. If you are going live, swap all three values together: pk_live_ in the browser, sk_live_ or rk_live_ on the server, and each webhook endpoint's new whsec_ secret.

Still stuck after trying this? Get it fixed for $49, or you don't pay.

Prevent this next time

FAQ

What does "Invalid API Key provided" mean?

Stripe rejected the secret key sent with the request (authentication_error).

What usually causes it?

Typo, extra whitespace or quotes around the key in your env file. Key was rotated, expired or deleted in the Dashboard (after a rotation the old key only keeps working until the expiry you chose). Using a publishable key (pk_) where a secret key (sk_ or rk_) is required.

How do I fix it?

1. Copy the secret key again from Dashboard → Developers → API keys, with no quotes or trailing spaces. 2. Keep secret keys server-side only: 3. Update the variable on your host (e.g. Vercel) and redeploy. 4. If you are going live, swap all three values together: pk_live_ in the browser, sk_live_ or rk_live_ on the server, and each webhook endpoint's new whsec_ secret.

Last checked against official docs on . Sources: Stripe docs: API keys.

Related errors

More Stripe errors and fixes →

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy