How to give AI agents short-lived credentials instead of API keys

Reviewed

In short: Stop handing agents long-lived API keys. Give each agent a workload identity, then exchange it for a short-lived token scoped to one tool and one task. Where a target only accepts keys, keep the key in a broker the agent cannot read. Rotate every key that remains on a schedule, and record each issuance.

6 min read

NewCore describes just-in-time, task-scoped credentials so agents never hold standing secrets. This does not establish support for every token-binding standard.

Why are API keys a poor fit for agents?

An API key is a bearer secret. Whoever holds it can use it, from anywhere, until someone revokes it. Agents make that worse. They run unattended, they read untrusted text and they often copy credentials into logs or prompts.

A key also carries no context. The target service sees the key, not the agent, the person behind it or the task. That makes logs hard to read and revocation blunt.

The desk's first criterion asks whether agents receive short-lived, scoped credentials instead of holding long-lived secrets. It carries 20% of each total.

What replaces the key?

Three patterns cover most cases. Teams usually combine them.

  • Token exchange: the agent presents its own identity and receives a short-lived token for one target. RFC 8693 standardises this in OAuth.
  • Just-in-time issuance: a broker issues a credential when a task starts and removes it when the task ends.
  • Secretless access: a proxy injects the credential into the outbound call, so the agent never sees it.

How does token exchange work for an agent?

The agent starts with an identity it did not have to store, such as a cloud workload identity or a SPIFFE SVID. It sends that identity to an authorization server and asks for a token for a named target.

The server checks policy and returns a token with a short lifetime and a narrow scope. If the agent acts for a person, the token can carry both identities. That supports on-behalf-of delegation, where the target sees who the agent works for.

Binding the token to a key makes theft less useful. DPoP, RFC 9449, binds a token to a key the client holds. Mutual TLS binding, RFC 8705, ties it to a client certificate.

What about systems that only accept static keys?

Many SaaS APIs still accept only static keys. You cannot remove those keys yet, but you can remove them from the agent.

Store the key in a broker or gateway. The agent calls through it, and the broker adds the key to the outbound request after a policy check. The agent never holds the key, so it cannot leak it. Rotation becomes a broker task, not a hunt through agent configurations.

How do you migrate step by step?

  1. From the inventory, list every credential agents hold. Note type, target, scope, age and where it is stored.
  2. Rank them by blast radius: write access to money, identity or production first.
  3. Give each agent runtime a workload identity from its cloud or from SPIFFE.
  4. For targets that accept OAuth, set up token exchange with lifetimes in minutes, not days.
  5. Scope each token to one target and the operations the agent's purpose needs.
  6. For targets that only accept keys, move the key into a broker that injects it per call.
  7. Bind tokens to a key with DPoP or mutual TLS where the target supports it.
  8. Rotate remaining keys on a fixed schedule and after any owner change.
  9. Log each issuance with agent, person, target, scope and lifetime.
  10. Delete the old keys and confirm nothing breaks over one full business cycle.

How short should a credential live?

Short enough that a stolen copy is of little use, long enough that the issuer is not overloaded. Minutes suit most tool calls. A task that runs for hours can renew with its workload identity rather than holding one long token.

Lifetimes are a trade-off with availability. Every renewal depends on the issuer, so plan for issuer outages before you shorten lifetimes everywhere.

Which credentials should you tackle first?

Not every key carries the same risk. A read-only key for a public status page matters less than a key that can create users or move money. Rank by what an attacker could do with each credential.

  • Keys that can change identity: create users, grant roles or issue tokens.
  • Keys that can move money or change prices.
  • Keys with write access to production infrastructure.
  • Keys that can read regulated data in bulk.
  • Everything else, in order of the systems they reach.

Start the migration with one high-risk credential and one agent. Prove the pattern works end to end, including renewal and revocation. Then reuse the same pattern for the next credential, rather than designing each one from scratch.

Record what you removed. A short log of retired keys, with dates and owners, becomes useful evidence at the next audit and access review.

Credential checklist

  • Every agent credential listed with type, target, scope and age.
  • Each agent runtime has a workload identity it did not have to store.
  • Token exchange in place for OAuth targets, with lifetimes in minutes.
  • Static keys moved into a broker the agent cannot read.
  • Token binding with DPoP or mutual TLS where supported.
  • Rotation schedule set for every remaining key.
  • Issuance log retained with the call records.

What to ask your vendor

  • Does the agent ever hold a long-lived secret? If so, which ones and why?
  • Which standards does credential issuance use: token exchange, SPIFFE, DPoP, mutual TLS?
  • What are default token lifetimes, and can they be set per target?
  • For key-only targets, does the agent ever see the key?
  • How are remaining keys rotated, and who is told?
  • What happens to running agents if the issuer is unavailable?

For agents that act for employees, the buyer-need ranking weights credentials and per-call checks at 25% each.

Best for agents that act on behalf of employees

Questions buyers ask

Why replace API keys for AI agents?

A key works for whoever holds it until revoked, and agents read untrusted text that can make them leak it. Short-lived, scoped tokens limit what a stolen copy can do and for how long.

What is secretless access for agents?

A broker or proxy adds the credential to the outbound call after a policy check. The agent never holds the secret, so it cannot leak it, and rotation happens in one place.

Which standard covers token exchange?

RFC 8693, OAuth 2.0 Token Exchange. An agent presents one token, such as its workload identity, and receives a new token scoped to a specific target.

Related pages

Sources