API keys explained and how to keep them private
An API key is a code that identifies your requests to an AI or app service. Here's why it acts like a password and where it should never be pasted.
An API key is a secret code that tells a service who's calling it. Treat it the way you'd treat a bank password.
What the key is
An API, as the API page explains, is a connection between computers or between computer programs.1 The key is how the service on the other end knows which account is using that connection.
OpenAI's help centre defines it plainly. An API key is a unique code that identifies your requests to the API.2 [fig:key-path]
Why it works like a password
You don't type it in each time, so it's easy to forget it's there. But it unlocks real things. OpenAI warns that a compromised API key allows a person to gain access to your account quota, without your consent.2 In the same help page it says that can lead to data loss, unexpected charges and interrupted access to your own account.2
So if someone else has your key, they can use your account and you may be billed for it. That's the reason it's compared to a password.
OpenAI also says your key is intended to be used by you, and that it doesn't support the sharing of API keys.2 If a helper needs access, the maker's own team or member settings are the proper route, not a copied key.
Where a key should never be pasted
The site's rule is simple. Keep keys out of anywhere other people, or other software, can read them. Specifically:
- Prompts and chat boxes. Never paste a key, a password, a customer record or a card number into an AI tool. Keep secrets and customer data out of prompts unless your own business policy says otherwise.
- Emails, group chats and shared documents. These get forwarded and searched.
- Screenshots and screen recordings. A key in the corner of a help request is still a key.
- Web pages and mobile apps you publish. OpenAI says never to deploy your key in client-side environments like browsers or mobile apps. Doing so lets malicious users take that key and make requests on your behalf, which may lead to unexpected charges.2
- Code repositories. OpenAI notes that committing an API key to source code is a common vector for credential compromise, and that public repositories are a common way to share a key with the internet without meaning to.2
The last two matter most if you hire a developer. Ask where the key is stored.
Where it can go instead
Automation tools usually have a place to save a key once, so you're not pasting it into each step. n8n's OpenAI page, for one, points to a separate OpenAI credentials page for guidance on setting up authentication.3 Follow the maker's documentation for your tool.
Some tools also offer their own built-in access so you don't need a key from the AI company. n8n says that on n8n Cloud you can use the OpenAI node with Gateway credits instead of your own OpenAI API key.3 Check the current terms on the maker's page before relying on that, since features and plans change.
If you think a key has leaked
Don't wait. OpenAI says that if you believe your key has been leaked, rotate your key immediately from the API Keys page.2 Rotating means swapping the old key for a new one.
For a planned swap before a key expires, OpenAI describes this order. Create a replacement, update your applications to use it, and revoke the old key once you've verified that the replacement works.2
OpenAI also recommends creating keys with an expiration date and a regular rotation process, and setting monthly spend limits to help limit unexpected costs from a leaked key.2 This information was checked on 1 December 2026 against the maker's page, which says it was updated last month. Other AI services may differ, so read their own help pages.
A webhook URL is a different kind of private detail. The page on signing secrets covers it.
Further reading and sources
- API, Wikipedia
- Best practices for API key safety, OpenAI Help Center
- OpenAI node, n8n Docs