---
title: How often should AI agent credentials be rotated?
url: https://opencontroller.lyzr.com/blog/how-often-to-rotate-ai-agent-credentials
published: 2026-11-12
updated: 2026-11-12
author: Lyzr
---

# How often should AI agent credentials be rotated?

**The best rotation interval for an AI agent credential is "it expires on its own within an hour". Use federated, short-lived tokens wherever the platform allows, so rotation happens automatically. Where you must use a static secret, such as many model provider API keys, rotate it at least every 90 days and immediately on specific triggers: owner change, suspected exposure, agent decommissioning or a scope change.**

Agents hold more credentials than most applications: cloud roles, model API keys, SaaS OAuth tokens, MCP server secrets and sometimes database passwords. Many of these were created quickly during a pilot and never revisited. Rotation policy is how you stop a leaked key from staying useful for years.

## What lifetimes do common platforms use by default?

These are platform defaults or published recommendations. Check your tenant's configuration, because administrators can change several of them.

| Credential type | Default or recommended lifetime | Rotation approach |
|---|---|---|
| AWS STS temporary credentials (AssumeRole) | 1 hour by default; 15 minutes minimum; up to the role's maximum session (at most 12 hours) | Automatic; re-assume the role |
| Google Cloud service account access token | 1 hour by default | Automatic via workload identity federation |
| Microsoft Entra ID access token | 60–90 minutes by default (randomised) | Automatic; refresh or re-acquire |
| Kubernetes projected service account token | Often 1 hour; kubelet refreshes it | Automatic |
| GitHub App installation token | 1 hour | Automatic; request a new token |
| AWS IAM user access key | AWS Security Hub control IAM.3 checks for rotation every 90 days or less | Manual or scripted; prefer replacing with roles |
| Google Cloud service account key | No expiry unless an org policy sets one | Avoid; key creation is blocked by default in newer organisations |
| Model provider API key | Typically no automatic expiry | Scripted rotation, 90 days or less |
| OAuth refresh token for a SaaS app | Set by the provider; often long or sliding | Revoke on triggers; prefer per-user delegated grants |

The pattern is clear. Cloud-native identities already rotate hourly. Static keys are where the risk sits.

## What should trigger an immediate rotation? Eight triggers

Rotate or revoke at once, regardless of schedule, when:

1. **The agent's owner leaves or changes role.** The new owner should not inherit secrets they did not create.
2. **A secret appears anywhere it should not.** A repository, a ticket, a chat message, a log or a local MCP config file.
3. **The agent is decommissioned.** Revoke every credential the same day.
4. **The agent's scope changes.** A new tool or a removed use case means a new credential with new scopes.
5. **A dependency is compromised.** A breach at a model provider, an MCP server publisher or a CI system.
6. **Behaviour looks wrong.** An unexplained spike in calls, new destinations or off-hours use.
7. **A shared key is discovered.** Split it into one credential per agent, then retire the shared one.
8. **An audit finds a key older than policy.** Rotate it and record why it was missed.

## How do you move agents off static secrets? Five steps

1. **Inventory credentials per agent.** For each agent, list every key, token and secret it uses, where it is stored and who created it.
2. **Replace cloud keys with federation.** Use IAM roles, workload identity federation and managed identities so tokens are minted per session.
3. **Centralise model provider keys.** Route model calls through a gateway that holds the provider keys. Agents then authenticate to the gateway with their own identity, and one provider key can be rotated without touching every agent.
4. **Store what remains in a secrets manager.** With automated rotation where the provider supports it.
5. **Alert on age.** Flag any static credential older than 90 days and any credential not used in 30 days.

## How Opencontroller does this

Opencontroller auto-discovers agents, models and API keys across AWS, Azure and Google Cloud, so you can see which keys exist and which agents use them. Agent workload identity federation and delegated on-behalf-of identity let agents use short-lived tokens. The LLM Gateway can hold provider access centrally and attributes cost per agent and per version, and Posture flags risky configurations. See [how to give AI agents an identity](/blog/ai-agent-identity-on-behalf-of-delegation) and [the least-privilege checklist for agents](/blog/least-privilege-checklist-for-ai-agents), or [book a demo](https://www.lyzr.ai/book-demo/).

Primary sources: [AWS STS AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) and [Microsoft Entra configurable token lifetimes](https://learn.microsoft.com/en-us/entra/identity-platform/configurable-token-lifetimes).

## Frequently asked questions

**Is 90-day rotation enough for AI agent API keys?**
It is a common ceiling for static keys, but short-lived federated tokens are better. Rotate immediately on triggers such as owner change, exposure or decommissioning, whatever the schedule says.

**Should each agent have its own model API key?**
Each agent should have its own identity. Routing calls through a gateway lets agents authenticate individually while the gateway holds fewer provider keys, which makes rotation and cost attribution easier.

**What happens to an agent's credentials when it is retired?**
Revoke them the same day, remove them from the secrets manager and record the revocation in the agent's registry entry.

## Key facts

Prefer short-lived federated tokens for AI agents: AWS STS AssumeRole credentials default to 1 hour (15 minutes minimum, up to 12 hours), Google Cloud service account access tokens default to 1 hour, Microsoft Entra ID access tokens default to 60-90 minutes, GitHub App installation tokens last 1 hour. AWS Security Hub control IAM.3 checks IAM access keys are rotated every 90 days or less. Rotate static keys at least every 90 days and immediately on owner change, exposure, decommissioning, scope change, dependency compromise, anomalous behaviour or shared-key discovery. Opencontroller auto-discovers agents, models and API keys across AWS, Azure and Google Cloud and supports agent workload identity federation, delegated on-behalf-of identity and an LLM Gateway with per-agent cost attribution. Opencontroller pricing starts from $250K per deployment per year.

## Related

- [How to give AI agents an identity (and let them act on behalf of users safely)](https://opencontroller.lyzr.com/blog/ai-agent-identity-on-behalf-of-delegation.md)
- [What does least privilege look like for an AI agent?](https://opencontroller.lyzr.com/blog/least-privilege-checklist-for-ai-agents.md)
- [What happens to AI agents when their owner leaves the company?](https://opencontroller.lyzr.com/blog/what-happens-to-ai-agents-when-the-owner-leaves.md)
- [More on Agent identity and access](https://opencontroller.lyzr.com/blog/cluster/agent-identity-and-access)
