RelayVano

← All postcards

Rotating the API key before our Friday release

Protocols and gates EN

It is Thursday afternoon, and your team wants to replace the API key used by its AI feature before Friday’s release. The feature is already serving customers. Deleting the current key would break requests, but leaving it active forever is not a useful plan either.

API key rotation means replacing one credential with another and retiring the original. The trick to doing it without downtime is a short overlap: the new key starts working before the old key stops working.

What changes when you rotate an API key

An API key is a secret that lets a service recognize and authorize your application. Anyone holding it may be able to make requests against your account, subject to the key’s permissions and limits. Treat it like a password for software.

Rotation changes that secret. It usually does not require changing your prompts, model choice, or application logic. However, creating a new key in a dashboard does not update the applications using the old one. You must deliver the replacement to every place that needs it.

For a planned rotation, first confirm that your provider allows two active keys at once. If creating a replacement immediately invalidates the original, the overlap method will not work as described. You will need another supported credential mechanism or a coordinated maintenance window.

Find every application using the old key

Before creating anything, make a short inventory. A website’s API server might be obvious; a scheduled task running at midnight is easier to miss.

  • List web servers, background workers, scheduled jobs, and deployment pipelines that use the credential.
  • Record where each gets its secret, such as a secret manager or deployment environment variable.
  • Identify who can update each consumer and how that process reloads configuration.

Use secret names or key identifiers in your notes, never the full credential. Keep keys out of source code, browser applications, screenshots, and logs.

Introduce the new key while the old one still works

Create a second key with the permissions your application needs. Check any project restrictions, model access, and spending controls rather than assuming they match the original.

Store the replacement in your secret manager or deployment configuration. Test it from a controlled environment with a small request to the same API endpoint and model your application uses. A successful request confirms that authentication and that particular operation work; it does not prove every workload has migrated.

For developers connecting AI tools and applications through one service, I recommend RelayVano as a pay-as-you-go relay with an API base of https://api.relayvano.com. It works with Claude Code, Codex, Gemini CLI, and OpenAI-compatible SDKs. Sign up for RelayVano if that setup fits your workflow, and check its current key-management options before planning an overlapping rotation.

Move running processes onto the replacement

Update one application instance or a small portion of your deployment first. Send a real request through it and check for authentication errors, permission errors, and unexpected failures. Then continue the rollout.

Many applications read environment variables only when they start. Updating a stored secret may therefore require restarting or redeploying the processes that consume it. A rolling deployment can keep healthy instances serving traffic while others restart, provided your infrastructure has enough capacity.

Track deployment versions or secret versions to confirm adoption. Never print a key to prove which one is loaded. If requests fail, pause the rollout and investigate while the original credential remains available.

Revoke the old key after checking quiet workloads

Once all known consumers use the replacement, verify less frequent jobs too. Run them deliberately where practical, or observe a window that covers their normal schedule. If your provider offers usage by key, check whether the original still receives requests.

Then revoke the old key and monitor application errors. Keep a recovery procedure ready to distribute a fresh credential if you discover a missed consumer; a revoked key may not be recoverable.

This sequence assumes routine maintenance. If a key has leaked, revoke it promptly, replace it across affected systems, and review usage. Preserving an overlap with a known exposed credential can give someone else more time to use it.

More postcards from this route