# API key rotation: a schedule and a procedure that works

Canonical: [API key rotation: a schedule and a procedure that works](https://contextingo.com/blog/api-key-rotation-schedule)

Locale: en

Purpose: Rotate keys on a schedule and immediately after exposure. A two-key procedure, an inventory, and what to automate. Works for tool and agent keys too.

Content updated: 2026-10-10

Source revision: content.ts 2026-10-10

Maintenance owner: the Contextingo site owner

[Topic map](https://contextingo.com/llm/topics/blog.md) · [Complete scoped map](https://contextingo.com/sitemap.md)

A key that never changes is a key that is probably known to someone who left. Rotation limits how long a leaked key is useful.

## When to rotate

- **At once** when a key may have been exposed: pasted in a chat, committed, logged.
- **When someone with access leaves** the team.
- **On a schedule** that matches the risk, for example every few months for powerful keys.

## A procedure without downtime

1. Create the new key next to the old one.
2. Deploy the new key to every place that uses it.
3. Check from logs that the old key is no longer used.
4. Revoke the old key.
5. Record the date and the next rotation.

## Make it easier

- Keep an inventory: what the key is for, who owns it, where it is stored.
- Give each service its own key, so revoking one does not break the rest.
- Scope keys narrowly and set low limits on development keys.
- Store keys in a secret manager and read them at run time.

## Personal keys for agents

In Contextingo each person connects Claude Code or Codex with their own personal key, which can be revoked on its own. Related: [keeping secrets out of the agent’s context](/blog/keep-secrets-out-of-coding-agent-context).

## Questions

### How often is often enough?

There is no universal interval. Match it to what the key can do, and always rotate after exposure.

### Is deleting the commit enough after a leak?

No. Assume the key was copied, and rotate it.
