How to rotate an API key your AI agents use
Create a new key at the provider, save it in the dashboard as the next version, let agents read it, then revoke the old key at the provider.
Rotation in Guardry is manual. Create a new key at the provider, save it in the dashboard as the new value of the entry, which becomes the next version, and then revoke the old key at the provider. Agents receive the new version the next time they read the entry. Guardry does not rotate anything at the provider for you.
Before you start
You need to be an owner or administrator of the organization, because those roles manage secrets. You also need access to the provider, where keys are created and revoked.
If you are rotating because a key leaked, the order is different: revoke first. See An AI agent leaked an API key.
1. Create the new key at the provider
Create the new key at the provider. If the provider lets you hold two keys at once, leave the old one working for now, so nothing breaks between saving the new value and restarting what uses it.
2. Save it in the dashboard as the new version
Open the entry in the dashboard and save the new value. It becomes the next version of the same entry. The name does not change, so no command, script or agent instruction has to change.
An agent cannot do this step. Agents can never edit, rotate or delete an existing entry.
3. Let the agents pick it up
An agent gets the new version on its next read. The CLI does not cache secret values, so the next run fetches the entry again.
# Each new run gets the entry's current version
guardry --profile coding-agent secrets run --secret API_KEY --secret DATABASE_URL -- python agent.pyA program that is already running is different. guardry secrets run puts the value into the program's environment when the program starts, so a long-running process keeps the old key until you restart it. Restart those processes now.
4. Revoke the old key at the provider
When everything that used the old key has been restarted, revoke the old key at the provider. Saving a new version in Guardry does not do this. Until the provider revokes it, the old key works for anyone who holds a copy.
5. Confirm in the audit log
The audit log records the entry name and the version for each read, along with who read it and when. Check that your agents are now reading the new version.
What this does not do
- There is no automatic rotation at the provider. Guardry does not create, change or revoke keys there.
- There are no dynamic or short-lived provider credentials generated on demand, other than TOTP codes.
- Saving a new version does not reach into running programs. A value an agent already received stays with it until the process ends or the provider revokes the key.
Questions
Does Guardry rotate API keys automatically?
No. Rotation is manual. An owner or administrator saves a new value in the dashboard, which becomes the next version, and the old credential must still be revoked at its provider.
Do I need to change anything on my agents after rotating a key?
No change to commands or names. The entry keeps its name and agents get the new version on their next read. Restart any long-running process that was started with the old value.
Can an AI agent rotate a key by itself?
No. An agent can never edit, rotate or delete an existing entry, including one it created. A person saves the new value in the dashboard.
Is saving the new value in Guardry enough?
No. Saving the new value changes what agents receive from now on. The old key stays valid until you revoke it at the provider, so the rotation is finished only after that step.