How to Rotate a Leaked API Key: The First Ten Minutes
For a leaked key there is one right move: revoke it at once and issue a new one. Finding who did it, reading the bill and understanding the cause come later. You do not investigate while the meter is running. ⏱️
This article gives the order of the first ten minutes, the next hour and what to prepare before any incident. This article covers the defender’s side only; it does not describe how to carry out an attack.
How is a leak recognised?
BU BÖLÜMÜN ÖZETİ
- A spend alert
- A notice from outside
- An exposure you find yourself
Most businesses do not notice a leak themselves; a signal arrives. Three kinds are common.

A spend alert
The most frequent signal is an unexpected spend alert. If an email that does not arrive on a normal day arrives at night, the first assumption should be a leak. In the console, look at which key and which model the usage came from. A model you do not recognise or an unusual hour is a strong sign. 📧
A notice from outside
Services that scan code repositories, and some providers, tell the owner when they find a key in the open. A security researcher may also write. Do not delete such messages as spam; check the key first. A false alarm costs a minute, and a missed alarm costs a bill. Verify through the console, not through links in the message.
An exposure you find yourself
Sometimes you find the leak: a key in the page source, a file pushed to a repository by mistake, a code pasted into a chat. Even with no trace of use, the key counts as leaked. A key seen in the open is treated as a key that has been used. There is no reason to wait. 🔍
What is done in the first ten minutes?
BU BÖLÜMÜN ÖZETİ
- One: revoke the key
- Two: issue a new one and place it
- Three: check the cap and the alert
The order matters. Each step closes the gap left by the one before.
One: revoke the key
Open the keys page in the provider console and revoke the suspect key. OpenAI’s page says the same: if you believe your key has been leaked, rotate it immediately. Requests made with a revoked key are refused from that moment. If you are not sure which key leaked, revoke all the suspects. A box that is down for a few minutes is an acceptable price. 🛑
Two: issue a new one and place it
Create a new key and put it only in the right place: the server’s environment variable or the vault. Do not put the new one where the old one wrongly sat. Test with one question that the box works again. Sharing the new key by the old route repeats the leak. As OpenAI notes, applications in production need their key values updated.
Three: check the cap and the alert
In the same session, look at the limits page of the console. Is a spending limit set, is the alert on? If not, switch them on now. If the leak repeats or another key is also exposed, the cap is the last line. The moment of an incident is the most persuasive time to fit a missing lock. How to choose the number is in what is a spending cap. 🚧
What is done in the next hour?
BU BÖLÜMÜN ÖZETİ
- Measuring the damage
- Finding where it leaked from
- Looking at the other keys
Once the meter has stopped, three questions are answered: how much, from where, and where else?

Measuring the damage
In the console, look at the usage history of the leaked key: when did it start, which models were called, how much in total? Take screenshots and export; you will need them when writing to the provider. OpenAI recommends reviewing whether usage aligns with your team’s work. The record is the basis both for disputing the bill and for drawing the lesson. 📊
Finding where it leaked from
Where did the key sit? The page source, a repository, a plugin setting, a document, a former employee’s laptop. Rotating without finding the source repeats the same leak with a new key. A finding Truffle Security published in February 2026 gives an example: Google API keys opened years earlier for services such as maps, and sitting in website code, gained access to the AI service once that service was enabled in the same project. A leak does not always come from a new mistake.
Looking at the other keys
If one key sat in the wrong place, others may have too. Are there other secrets in the same repository, the same plugin or the same document? If so, they are rotated as well. One leak is a call to review the whole arrangement. Open your key list and confirm where each line lives; the arrangement itself is in how to store an AI API key. 🗂️
How do you talk to the provider?
BU BÖLÜMÜN ÖZETİ
- When to write
- What to write
- What not to rely on
If a bill has arisen, you need to write to the provider. The outcome is not guaranteed; preparation improves the odds.
When to write
At once. After revoking the key, report the situation through the support channel the same day. Delay may mean both a larger loss and a weaker request. Write from the address that owns the account; an account opened in a freelancer’s name causes trouble at exactly this point. ✉️
What to write
Keep it short and factual: when you noticed the leak, when you revoked the key, in which interval and on which models the unusual usage occurred, and what your normal monthly usage is. Attach the screenshots. A timeline works; guesses and blame do not.
What not to rely on
Do not rely on the provider cancelling the bill. Decisions are made case by case and it is not defined as a right. What you can rely on are the things you set up before the incident: the cap, the alert, separate keys. Goodwill is not a plan. This article is not legal advice; for large amounts, consult a lawyer. Incident handling as a whole is in the AI audit guide. ⚖️
What is prepared before an incident?
BU BÖLÜMÜN ÖZETİ
- A one-page plan
- The two-person rule
- Lock list: a leaked key
The ten-minute sequence takes ten minutes only if it was written beforehand.

A one-page plan
Write on one page: the console address, how to reach the keys page, who is authorised to revoke, where the new key goes and who is told. Keep the plan, without the keys themselves, where the team can reach it. Nobody searches for a document at midnight; its place must be known in advance. 📄
The two-person rule
At least two people should be able to open the console and revoke a key. If the only one is on holiday or unreachable, the meter runs. The second person need not be technical; having tried the steps once is enough. Once a year, run a drill with a harmless test key.
Lock list: a leaked key
This article’s lock list has five lines, in order. One: revoke the suspect key. Two: issue a new one and place it only on the server or in the vault. Three: check the cap and the alert. Four: record the usage history and find the source of the leak. Five: write to the provider the same day. How to try the bot itself before launch is explained in how to test a chatbot before launch. Forecast: providers will widen the scanning that automatically suspends keys found in the open. Update log. 30 November 2026: first publication. Forecasts on this page are re-read when they fall due; one that proves wrong is corrected here, not deleted.
How does Adapte Digital review incident readiness?
BU BÖLÜMÜN ÖZETİ
- A single delivery package
- What is reviewed
- Where to start
In the Attack File one question is asked: if a key leaked tonight, who would do what, and in how many minutes?
A single delivery package
Adapte Digital does not charge a monthly management fee. Work starts with a single delivery package whose scope is written down in advance: 36,000 TRY + VAT. If the work grows, the new need is defined as a separate add-on package, priced by what will be delivered rather than by the hours spent. 📦
What is reviewed
The rotation plan, the people with console access and the alert recipients are checked; where no plan exists, a one-page draft is left behind.
Where to start
The written scope of each package, with current pricing and capacity, is on our campaign pages. 🧭
Quick Summary
- A leaked key is revoked first; investigation comes afterwards.
- The new key goes only on the server or in the vault.
- The usage history is recorded and the source of the leak is found.
- The provider is written to the same day, with a timeline; the outcome is not guaranteed.
- A one-page plan and two authorised people make ten minutes possible.
Short Glossary
- Key rotation
- Key rotation is the act of invalidating an old key and issuing a new one in its place.
- Revocation
- Revocation is the act of making a key unable to authorise any further request.
- Timeline
- A timeline is a record that shows in order what happened and when during an incident.
Frequently Asked Questions
Next Step
Write this question on paper: if a key leaked tonight, who opens the console and who revokes the key? If you cannot write two names, your plan is incomplete.
Sources: OpenAI Help Center — Best practices for API key safety · Truffle Security — Google Fixes the Gemini API Key Privilege Escalation Issue · Sysdig — 2024 Global Threat Year-in-Review
Updated: November 2026
Sık Sorulan Sorular
Yes. A key seen in the open counts as leaked. No trace of use does not mean it will not be used.
The box stops until the new key is in place. A few minutes of outage is far cheaper than a running meter.
It is not guaranteed. Applying at once with evidence improves the odds; the real protection is a cap set in advance.
