Connect Stripe, Brevo or any API to your app with no credential in the code (2026)
An API key in the code always ends up leaking: in a repository, a log, a conversation with your AI. With while, your app calls Stripe or Brevo without ever holding the key, and every call is recorded.
By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 19, 2026.
The short version. Your AI connects Stripe, Brevo or any API to your app over MCP. The key stays in while: neither your code nor your AI ever sees it. What matters, like deleting a database, waits for a person’s approval.
Prerequisites
- An app, already on while or ready to deploy.
- The key for the API you want to connect, from Stripe or Brevo for example.
- An AI that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.
Step 1: Give your AI this message
Open your AI in your app’s folder and paste this message into it:
Connect to while with my account (while.sh/agents), then put my app on while.
Your AI adds while’s MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn’t open, type /mcp, choose while, then Authenticate. On that page, choose “A new app”, then click Authorize.
Step 2: Paste the key into while
Your AI declares the connection to Stripe and gives you a link. You open it, paste the Stripe key and approve. Your AI never sees it1.
What your AI does
It adds the connection to the service, in while.yaml:
services:
- name: web
port: 3000
connections: [stripe]
Your app receives while’s address for Stripe in STRIPE_URL, and calls it without a key:
const r = await fetch(`${process.env.STRIPE_URL}/v1/balance`);
const solde = await r.json();
The key is added to every call, and every call is recorded. For the first 7 days, reads go through, and while learns from them what your app calls. A write, like a payment or an outgoing email, goes through as soon as you approve its rule. After that, an unexpected call is refused, and your AI is notified.

Allow a new call
You, to your AI: Allow creating customers in Stripe.
Your AI proposes the rule, and you approve it in while. Your app then creates its customers, and anything you haven’t allowed is still refused.
Ask for your approval before a sensitive call
You, to your AI: Ask me before every refund.
Your AI sets a rule on refunds: each one waits for your approval in while before it goes out to Stripe.
Change the key
You, to your AI: We need to change the Brevo key.
You paste the new key into while, and your app uses it from the very next call, with no new deployment.
See your app’s calls
You, to your AI: Why did sending emails fail yesterday?
Your AI reads the latest call and the refused calls on the Brevo connection in while, and fixes the problem.
Connect Google with no key to keep
You, to your AI: Connect Google Sheets to our app.
Your AI declares the connection to Google. Depending on what you choose, a service account’s key stays in while, or there is no key at all: short-lived tokens, signed for your app, that Google exchanges.
Go back to the previous version
You, to your AI: Go back to the previous version.
In the 30 minutes after a production release, the previous version comes back in a second. After that, it takes a few seconds. Once the previous version is back, your AI reads what broke in while’s logs, fixes it and deploys again.
In the docs: Outbound traffic, API connections and Versions and rollback.
Next steps
Sources
- Stripe, keeping your API keys safe, accessed November 2, 2026