Checklist
Is the Stripe publishable key safe to expose?
Short answer. Yes. Stripe's API keys page says a publishable key (pk_live_ or pk_test_) can go in front-end code. It identifies the account and can create tokens or PaymentMethods. It cannot create charges or read account data. Secret keys (sk_), restricted keys (rk_), and webhook signing secrets (whsec_) stay on the server.
Updated 3 Dec 2026
This is a practical checklist, not a guarantee. It is not a penetration test, a compliance audit, or proof that an app is safe to launch.
This page answers the question with the checks, not with a yes that covers every string from Stripe. The publishable key is the public one. sk_, rk_, and whsec_ are not. If a secret or restricted key is already in a bundle, a repo, or a chat, use Leaked Stripe secret key?. The signature check is the Stripe webhook checklist. Stripe is the directory entry. How the product differs from a merchant-of-record is Stripe vs Paddle.
Stripe's pages below were read on 3 Dec 2026. Labels move. If a step here disagrees with the page it links, follow that page.
What a publishable key is
Stripe's API keys page puts publishable keys in the column "safe to expose." The same row says a pk_ key is for Stripe.js, Elements, and mobile SDKs. It can identify your account and create tokens or PaymentMethods from payment details. It cannot perform sensitive operations such as creating charges or reading account data. Stripe says you can include it in front-end code or in applications you distribute.
Sandbox keys start with pk_test_. Live keys start with pk_live_. Stripe says each mode has its own keys, and objects in one mode are not visible to the other. A test PaymentIntent is not a live payment. When you go live, Stripe says to copy the live publishable key into the client code that still has pk_test_. That swap is expected. The live publishable key is still the public key.
Stripe also says you cannot expire a publishable key. Publishable keys are shown in the Dashboard by default, because Stripe does not treat them as sensitive. The same page says only publishable keys are safe to expose outside the application's back end.
A pk_ value in a NEXT_PUBLIC_ or VITE_ variable matches that design. Those prefixes are in the JavaScript a visitor can open. The wider pass is API keys in the frontend.
What must stay on the server
Stripe's keys table marks every other key type as not safe to expose.
| Prefix | What Stripe says | In the browser? |
|---|---|---|
pk_live_ / pk_test_ | Identifies the account. Creates tokens or PaymentMethods. Cannot create charges or read account data. | Yes. |
rk_live_ / rk_test_ | Restricted key. You set Read, Write, or None per resource. Stripe recommends these instead of secret keys. | No. |
sk_live_ / sk_test_ | Unrestricted access to the Stripe APIs. Stripe does not recommend these for new work. | No. |
sk_org_ | Organization key. Acts across the accounts in the organization. | No. |
whsec_ | Webhook signing secret. One per endpoint. A different secret for test and live if the endpoint is used in both. | No. |
Stripe's restricted keys page says a restricted key is for server-side requests, and that you treat it with the same caution as a secret key. A leaked restricted key can do only what its permissions allow. That limit is not a reason to put it in the client. Stripe's authentication page says not to embed secret or restricted keys in source code or client-side applications. Use the host's secret store, or an environment variable the browser bundle does not inline.
Stripe's best practices page says secret keys must stay in the server environment. If someone else obtains one, they can make charges, read customer data, or disrupt the integration. The same page says people scan public repositories for Stripe keys, and that private repositories can still leak through a development environment.
A client secret is a third kind of value. It is not a publishable key, and it is not an API key you reuse.
Stripe's Payment Intents guide says the client secret lets the client complete the payment for the amount already set on that PaymentIntent. Stripe says not to log it, embed it in a URL, or expose it to anyone other than the customer, and to use TLS on any page that includes it. The SetupIntent object says the same for saving a payment method: the client secret completes setup from the frontend, and it should not be stored, logged, or exposed to anyone other than the customer. The Payment Element samples describe that value as one your back end passes, with details such as the amount. Create a new one per payment. Do not commit one, and do not print it in a log the browser or a shared error tool keeps.
Mistakes in an AI-built app
Builders paste whichever key makes the demo charge. These are the mixes Stripe's docs rule out.
sk_orrk_underNEXT_PUBLIC_orVITE_, or copied into a component so Stripe.js can "create the payment." The publishable key is the one Stripe.js uses. The secret key is what your server uses to create the Checkout Session or PaymentIntent.- A browser function that sends an amount, and a server route that charges that amount with the secret key. Stripe's PaymentIntent flow completes the amount specified when the server created the PaymentIntent. The Payment Element comment in Stripe's docs says the client secret comes from the back end with details such as the amount. Compute the price on the server from your catalog. Do not trust a price field the page posted.
- Fulfilling an order because the browser opened the success URL. Stripe's webhook page says that without verification, someone can send a fake event that fulfills an order or grants access. Verify the
Stripe-Signatureheader with the raw body and the endpoint'swhsec_secret. The steps are the Stripe webhook checklist. - One key for both modes. A
pk_test_key and ansk_live_key are not a pair. Objects created in the sandbox are not visible to live mode, and the webhook secret differs for test and live on the same endpoint URL.
How generated code keeps picking the wrong variable is How to keep API keys out of AI-generated code.
How to check your app
Search the built JavaScript, not only the source you think shipped. After the production build, search the output for sk_live_, sk_test_, rk_live_, rk_test_, sk_org_, and whsec_. A hit is a server credential in the client. pk_live_ or pk_test_ in that output is the publishable key Stripe says to embed.
Then search env names. A secret, restricted key, or webhook secret whose name starts with NEXT_PUBLIC_ or VITE_ is in the bundle even when the value is not hard-coded. The publishable key may use that prefix. The others may not.
Read the route that creates the payment. It should run on the server, with the secret or restricted key, and it should set the amount from your prices. The browser should receive a client secret or a Checkout URL for that object, then confirm with Stripe.js and the publishable key.
Open the webhook route. It should pass the raw body, the Stripe-Signature header, and whsec_ to Stripe's library. Stripe says the framework must not parse that body first, or verification fails. A handler that marks an order paid from the success-page query, and never checks the signature, is the gap.
Then run a free passive check on the URL you will share. It can see a key that shipped in a public script. It does not call Stripe, and it does not read your Dashboard. The worksheets for the rest of the pass are the checklist pack.
If a secret key was exposed
Roll it. Stripe's best-practices page says to rotate a restricted or secret key immediately if it was exposed, even when you are not sure anyone saw it. Stripe says that if they detect an exposed secret or restricted key they notify you, and in some cases they deactivate it. They also say detection does not catch every exposed key. Do not wait for the email.
The Dashboard steps, the request log, and the difference between a grace period and Now are in Leaked Stripe secret key?. Deleting the line from the repo does not roll the key. You cannot expire a publishable key, and you do not treat a pk_ value in the client as that incident.
FAQ
Is a pk_live_ key a secret because it says live?
No. Stripe's keys page says live mode is when card networks process real payments, and that the live publishable key is still safe to embed in client code. pk_live_ identifies the live account to Stripe.js. sk_live_ and rk_live_ are the live credentials that must stay on the server. Mixing a live publishable key with a test secret key does not make the publishable key secret. It pairs two modes that cannot see each other's objects.
Can I create the charge in the browser if I only use the publishable key?
No. Stripe says a publishable key cannot create charges or read account data. The server creates the Checkout Session or PaymentIntent with a secret or restricted key, including the amount. Stripe.js, using pk_ and that payment's client secret, confirms the payment the server already defined.
Does the success page prove the customer paid?
No. The browser can open a success URL without a paid invoice. Stripe says an unverified webhook can be a fake event that fulfills an order. Record the payment from a signed webhook, with the raw body and the endpoint's whsec_ secret. The checklist is Stripe webhook verification.
I found sk_live_ in the built JavaScript. Is deleting the env var enough?
No. Treat the key as copied. Rotate it in the Dashboard, put the replacement only in the server environment, and redeploy. Then search the new build again. The sequence is Leaked Stripe secret key?.
Sources
Checked 3 Dec 2026.
Informational only. This page describes checks and vendor documentation. It is not a security audit, a penetration test, or a certification, and it is not a guarantee.
Newsletter
A short weekly note on new tools and security checklists. No spam, unsubscribe anytime.