Skip to content

Connect Stripe to a tool built with Claude or ChatGPT (2026)

Your tool built with Claude needs to read Stripe’s payments: failed charges to follow up, unpaid invoices, the month’s revenue. The Stripe credential touches your customers' money, and it must end up neither in the code nor in the conversation. On while, it stays in while, and your AI never sees it. Here is how.

By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 18, 2026.

View as Markdown

Connect the Stripe API to a tool built with Claude or ChatGPT: the Stripe restricted API key kept in while, out of the code and out of the AI’s reach, and the tool reading payments, invoices and customers

Stripe holds your payments, customers, subscriptions and invoices. A tool built with Claude or ChatGPT becomes valuable when it reads that data: the list of failed payments to follow up, unpaid invoices, the month’s revenue by plan. To do that, it needs a Stripe API credential, and that credential touches your customers’ money.

That is where things often go wrong: the secret key ends up pasted into the code, or into the conversation with the AI, where it can leak. On while, the Stripe credential stays in while. The tool calls Stripe without ever holding it, and your AI never sees it.

The short version. Create a restricted key in Stripe, read only if the tool writes nothing. Ask your AI to connect Stripe, then paste the key into while through the link it gives you. The tool reads your payments, every call is logged, and a refund waits for your approval if you ask.

Secret key or restricted key: which one to give

Stripe offers several kinds of keys, and only one fits a tool1,2.

Secret keyRestricted key
It starts withsk_live_ or sk_test_rk_live_ or rk_test_
What it opensThe whole account, with no restrictionOnly the resources you choose
PermissionsCannot be reducedNone, Read or Write, resource by resource
Stripe’s adviceNot advised for new usesRecommended for most uses

A restricted key limits the risk to what you allowed. If the tool only reads, it cannot write anything, even with the key in hand.

Connect Stripe to your tool, in three steps

The whole thing takes a few minutes, and you have no code to write.

  1. Create a restricted key in Stripe. On the Dashboard’s API keys page, click Create restricted key. For each resource, choose None, Read or Write, for example read access to payments, customers and invoices. Click Create key, and copy it: in live mode, Stripe shows it only once1,2.
  2. Ask your AI to connect Stripe. It declares the connection in while and gives you a link.
  3. Paste the restricted key into while. You open the link, paste the key and confirm. Neither your AI nor the tool’s code sees it.

Start with a test environment, with an rk_test_ key: payments are not actually processed there1. Switch to the live key once the tool is ready.

You, to your AI: Connect Stripe to this tool, read only, and show this week’s failed payments with the customer and the amount, so we can follow up.

The tool built with AI calls the Stripe API through while: the restricted key is added to each call inside while, out of the code, every read of payments is logged and a refund waits for a person's approval
The tool calls Stripe through while, which adds the credential to each call.

What while does on each call

The tool calls Stripe through while, without a credential. while adds the restricted key to each call, and logs it in the history. For the first seven days, reads go through and teach while what the tool calls. A write, like creating a customer or a refund, goes through once you approve its rule. After that, an unexpected call is refused, and your AI is told.

For payments, caution makes sense. You can ask for your approval before a sensitive call.

You, to your AI: Ask me before every refund the tool makes in Stripe.

Each refund then waits for your approval in while before reaching Stripe. The credentials of your software are detailed on our security page, and the same mechanism works for any API in connect an API with no credentials in the code.

Changing the credential

Stripe lets you expire and roll a key from the API keys page, and advises changing it when someone who had access leaves the company1. When it changes, paste the new one into while: the tool uses it from the next call, without being put back in place.

What while adds around it

  • Your colleagues use the tool with a while account for up to 3 people, or, on the Pro plan, with their email account, Google or Microsoft. See keep a tool for your colleagues.
  • Connected software: one on the Libre plan, and 25 on the Pro plan, Stripe included.
  • The tool’s data is backed up every day, and your tools are hosted in France by Nextmap.

To track incoming money, see the cash flow forecast, and for related connections, Qonto and Pennylane.

Try it with your tool

Give this message to your AI, then ask it to connect Stripe. The trial is free, with no sign-up, and your tool has its address in 3 minutes.

The message to give your AI
Read while.sh/agents and help me get started with while.

In the docs: Variables and secrets.

Sources

  1. Stripe, API keys, accessed November 18, 2026
  2. Stripe, Restricted API keys, accessed November 18, 2026

Questions

Which Stripe key should you give a tool built with AI?

A restricted key, which starts with rk_. Stripe recommends it for most uses: you choose None, Read or Write for each resource. The secret key, sk_, opens the whole account and is not advised for new uses1,2.

How do you create a restricted key in Stripe?

On the Dashboard’s API keys page, click Create restricted key, choose the permissions resource by resource, then Create key. Stripe shows it only once in live mode1,2.

Does my AI see the Stripe credential?

No. Your AI declares the connection to Stripe and gives you a link. You paste the restricted key into while there, and neither your AI nor the tool’s code sees it.

Can you test without touching real payments?

Yes. First create a restricted key in a test environment, which starts with rk_test_. Payments are not actually processed there1,2.

Can you block a refund made by the tool?

Yes. Give the key read access only if the tool writes nothing. If it must issue refunds, ask on while for your approval before each refund: it waits for your approval before reaching Stripe.

Give your AI the message, and it takes care of the rest

Give this to your AI

Read while.sh/agents and help me get started with while.

Copy the message

In 3 minutes, with no sign-up, the tool has its own address. To keep it, create your account.

For a company project, write to the while team: hello@while.sh