Stripe secret_key_required: a publishable key called a secret API
Stripe returns secret_key_required? The request used a pk_ key. Stripe says that call needs a secret key, and the secret key stays on the server.
Reviewed October 15, 2026
What it means in plain English
The browser, or a server route, called a Stripe API that is not allowed to use a publishable key. Stripe's error list defines secret_key_required as: the API key provided is a publishable key, but a secret key is required. Stripe says to take the current keys from the Dashboard and update the integration.
A publishable key (pk_) is the one that belongs in the browser. Creating a Checkout Session, a PaymentIntent, a refund, or a Billing Portal session needs the secret key.
Likely causes
- The client calls
api.stripe.comwithpk_live_orpk_test_in theAuthorizationheader. - The server route loaded
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYorVITE_STRIPE_PUBLISHABLE_KEYand passed it to the Stripe SDK. - The secret key was never set on the host, so the code fell back to the publishable key.
How to fix it, step by step
- Move the Stripe call to a server route. Stripe's key guide says only publishable keys are safe to expose, and that other keys should not go in application code that ships to the browser.
- Read the secret from an environment variable that is not prefixed with
NEXT_PUBLIC_orVITE_. Usesk_test_in test mode andsk_live_in live mode, matching the price and the publishable key. - Leave the publishable key in the browser for Stripe.js. Do not send it as the API key for a secret endpoint.
- Redeploy the server after changing the variable.
How to check it worked
- The Stripe error
secret_key_requiredis gone. - The browser still only has a
pk_key, and the server log shows the secret call succeeding.
A key that is present, but from the other Stripe mode, is a different error. See No such price: test mode vs live mode.
Sources
Related fixes
More Stripe fixes
Keep going on your own.
The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.