---
title: Acting for a person
summary: How an agent gets a token that says "this person, acted for by this agent", and how agents pass a smaller token to other agents.
section: agents
order: 3
---
# Acting for a person

How an agent gets a token that says "this person, acted for by this agent", and how agents pass a smaller token to other agents.

An agent exchanges the person's token for a new one using token exchange (RFC 8693). The new token keeps the person as `sub` and adds the agent as `act`. It can only be narrower than the token it came from.

There are two ways to be allowed to do this. Either the person approves the agent on a consent page, for limits they can see and withdraw ([ask the person first](#ask-the-person-first-consent)), or you run the client yourself and its own setup is the permission ([set up the agent's client](#set-up-the-agent-s-client)). A client that is delegated to by a person is bound by that delegation for that person, so a revoke or a pause by the person stops its exchanges.

## Ask the person first (consent)

The person decides, and can see and stop it. Send them to `/authorize` with the scope `tessera:delegate`; the other scopes and the `resource` of that request are what is delegated. The client must be one that may use token exchange (see below), and the request needs at least one scope besides `openid` and a `resource`.

```text
$ISSUER/authorize?client_id=notes&response_type=code&redirect_uri=...&state=...
  &code_challenge=...&code_challenge_method=S256
  &scope=openid%20orders:read%20tessera:delegate&resource=https://mcp.example.com
```

The person is signed in first, then sees "Allow notes to act as you?" with who is asking, what is delegated, for how long (24 hours by default, 30 days at most, and they can only choose shorter), how many times, and which actions will ask them to confirm again. They can allow, allow for one hour or refuse. Ask for tighter limits with an RFC 9396 `authorization_details` entry (`scopes`, `locations`, `duration_seconds`, `max_uses`, `acr`):

```json
[{"type":"agent_delegation","scopes":["orders:read"],"locations":["https://mcp.example.com"],"duration_seconds":7200,"max_uses":50,"acr":"2"}]
```

Say which roles you need with an optional `roles` array of `<app>:<role>` keys in the same entry. The same page lets the person set what the agent may do: the roles you declare are ticked and each can be unticked, a role they do not hold is shown disabled, and "Everything I can do" is a separate choice they must make themselves. Choosing it, or adding a role to an agent that already exists, asks them to confirm it is them first unless they signed in with a passkey or a second step in the last five minutes. Declaring a role grants nothing, and the page shows only roles the realm defines, in the realm's own words. With nothing declared, nothing is ticked.

```json
[{"type":"agent_delegation","scopes":["orders:read"],"locations":["https://mcp.example.com"],"roles":["orders:viewer"]}]
```

After the person allows, the page says what the agent may do and shows a Continue link to your `redirect_uri` (no timer and no automatic redirect, so a script follows the link). The marker scope never appears in a token. The token response carries `authorization_details` with the `delegation_id` and `agent_id`. Then exchange as described below: the person's access token is the `subject_token` and must have been issued to the client that exchanges, and the actor is the agent's own access token, or the `agent_id` sent by a confidential client that authenticated. An `agent_id` from a public client is refused. The result has the scopes, resources and lifetime narrowed to the delegation, ends with the delegation, and carries `act.delegation_id`. Its `roles` and `permissions` are the person's current roles that the agent's [ceiling](#limit-the-roles-an-agent-carries) allows: none for a new agent until a role is chosen. Only an agent created before ceilings existed still carries all of the person's roles, until the sunset.

### Limit the roles an agent carries

A new agent carries **no roles** until its owner sets a ceiling. Set `allowed_roles` on the agent: a list of `<app>:<role>` keys (a realm-wide role by its bare key), or choose `ceiling_mode` `person` for everything the person can do (never more than the person's current roles).

- The token's `roles`, `permissions` and role-granted scopes are the person's **current** roles that the ceiling allows. A role the person lost is dropped even if it is listed, and a listed role the person never held is never added. An empty list, which is what a new agent has, gives the agent no role at all.
- No request removes a ceiling: `allowed_roles: null` is a `400` for an agent that has one. An agent created before ceilings existed shows `legacy: true` ("no limit set") and keeps its old behavior until the sunset, then its exchanges are refused with the code `legacy_agent_ceiling_required`. This is a breaking change for API callers that created agents and relied on them carrying all of the person's roles: pass a ceiling.
- Every key must be a role that exists in the realm; an unknown key is a `400`. A key for a role the person does not hold today is fine, it just never applies.
- It applies from the next exchange. A token already issued keeps its roles until it expires.

An administrator sets it with the admin API (`tessera:agents:write`) or the CLI; the person sets it on their own agents under Security › Agents in their account, and sees the roles on the consent page.

```sh
# A delegated agent created with a subset of its owner's roles
tessera agents create --realm acme --kind delegated --external-id notes-1 \
  --owner-user-id 6c0f... --allowed-scope read --allowed-role billing:invoice-reader

# Change it later (a list, or "ceiling_mode": "person")
curl -sS -X PATCH "$ADMIN/users/$USER_ID/agents/$AGENT_ID" -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H 'Content-Type: application/json' -d '{"allowed_roles": ["billing:invoice-reader"]}'
```

The person narrows an agent whenever they like. Widening it again needs a recent sign-in, and a person cannot widen an agent an administrator limited. The `token_exchange.issued` audit event records the issued `roles` and the `allowed_roles` behind them.

A refused exchange carries a machine `code`. Branch on it, never on the description:

| `code` | Meaning | What to do |
| --- | --- | --- |
| `consent_required` | The delegation expired, was revoked or is used up | Send the person to the `authorize_url` in the answer with `tessera:delegate` again |
| `delegation_paused` | The person paused it | Tell them; do not ask again until they resume it |
| `interaction_required` | The sign-in is too old or too weak for this action | Send the person to the `step_up_url` (add `redirect_uri`, `state` and a PKCE challenge), redeem the code, exchange again |

An administrator can require a recent or stronger sign-in for chosen scopes with the realm's delegation policy (`GET`/`PUT $ADMIN/delegation-policy`: `step_up_scopes`, `step_up_acr`, `step_up_max_age_seconds`, `max_duration_seconds`). A resource server in Go can ask for the same with `tessera.RequireStepUp`, which answers the RFC 9470 `insufficient_user_authentication` challenge, and `Claims.DelegationID()` ties an action to the person's consent.

In their account, under Agents, the person sees each delegation with its expiry, uses and last use. They can pause, resume (this needs a recent sign-in) or revoke it. Delegations an administrator created show as "granted by administrator". The audit events are `agent.delegation.granted`, `.paused`, `.resumed`, `.revoked`, `.expired` and `token_exchange.step_up_required`, and a webhook on `agent.*` receives them. A revoke or pause takes effect at the next exchange and at introspection; an API that checks tokens offline sees it when the token expires, so keep these tokens short.

If you ask with `tessera:delegate` from a client that may not use token exchange, the redirect carries `error=invalid_scope` and the error code `delegation_not_enabled`, with the fix in the description.

### Public clients, DCR and CIMD

A public client that registers itself (Dynamic Client Registration or a Client ID Metadata Document) cannot ask a person to delegate. Registration creates such a client with token exchange off, refuses the token exchange grant in the registration, and `tessera:delegate` is an administrative scope that cannot be registered as one of its scopes. Its request for `tessera:delegate` is answered with `invalid_scope` (`delegation_not_enabled`). Delegation is for clients that an administrator created and enabled for token exchange. If your MCP client or agent registers itself, it signs people in and calls your API with its own token, but it cannot act as the person through a delegation.

## Set up the agent's client

Each agent gets its own confidential client, allowed to use token exchange. Token exchange is off for every client until you turn it on (`token_exchange_policy` is `disabled` by default). Set it with the CLI:

```sh
tessera clients ensure agent-a --realm acme --kind confidential \
  --grant client_credentials --grant urn:ietf:params:oauth:grant-type:token-exchange \
  --scope docs.read --scope docs.write \
  --resource https://docs.example --resource https://billing.example \
  --token-exchange-policy enabled --env-file agent-a.env
```

`--token-exchange-policy` takes `disabled`, `enabled` or `allowlist`; for `allowlist`, add `--token-exchange-audience` once per audience. Or call the admin API:

```sh
curl -sS -X PATCH "$ADMIN/clients/agent-a" \
  -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "allowed_grants": ["client_credentials", "urn:ietf:params:oauth:grant-type:token-exchange"],
    "allowed_scopes": ["docs.read", "docs.write"],
    "allowed_resources": ["https://docs.example", "https://billing.example"],
    "token_exchange_policy": "enabled"
  }'
```

- `enabled` lets the client exchange for any audience it may use. `allowlist` also requires every issued audience to be in `token_exchange_allowed_audiences`.
- `allowed_scopes` and `allowed_resources` are a ceiling for this client. A request outside them is refused.
- Create the client first as in [identities](/docs/agents/identities.md#service-account-client-credentials).

## One hop

You need two tokens: the person's access token (`subject_token`, from a normal sign-in, issued for the API you want to call: the app that signs the person in sends that API's URL as `resource` and lists it in its `allowed_resources`, because a plain OIDC app's own token is only for the app itself) and the agent's own access token (`actor_token`, from `client_credentials`). The agent authenticates the request as its own client.

```sh
curl -sS "$ISSUER/token" -u "agent-a:$A_SECRET" \
  -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
  --data-urlencode "subject_token=$USER_TOKEN" \
  -d subject_token_type=urn:ietf:params:oauth:token-type:access_token \
  --data-urlencode "actor_token=$A_TOKEN" \
  -d actor_token_type=urn:ietf:params:oauth:token-type:access_token \
  --data-urlencode "scope=docs.read" \
  -d resource=https://docs.example
```

```json
{
  "access_token": "eyJhbGciOi...",
  "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
  "token_type": "Bearer",
  "expires_in": 600,
  "scope": "docs.read"
}
```

The new token's claims:

```json
{
  "sub": "6f1d2c1e-3b0a-4a64-9c53-0b1a8d0e5f11",
  "aud": "https://docs.example",
  "scope": "docs.read",
  "client_id": "agent-a",
  "act": { "sub": "agent-a", "sub_type": "service_account" }
}
```

- `sub` stays the person. `client_id` is the exchanging client. There is no refresh token.
- `actor_token_type` may be left out. For an actor that is a JWT from a trusted issuer, send `urn:ietf:params:oauth:token-type:jwt` (see [workload identity](/docs/agents/workload-identity.md)).
- The actor token must belong to the client that authenticates the request. A person's token is never an actor, and neither is a token that already has an `act` claim.
- Without an `actor_token` the request is refused: Tessera does delegation only, never impersonation.

`act.sub_type` says what kind of actor it is:

| `sub_type` | `act.sub` is |
| --- | --- |
| `service_account` | The client id |
| `workload` | The workload's `sub`, `workload:<issuer-id>:<subject>` |
| `agent` | A delegated agent id, or an `agent:<issuer-id>:<subject>` principal |

## Chains of agents

Agent A passes its token to agent B, which exchanges it again. The `act` claim nests, latest actor outermost:

```json
{
  "sub": "6f1d2c1e-3b0a-4a64-9c53-0b1a8d0e5f11",
  "act": {
    "sub": "agent-c",
    "sub_type": "service_account",
    "act": {
      "sub": "agent-b",
      "sub_type": "service_account",
      "act": { "sub": "agent-a", "sub_type": "service_account" }
    }
  }
}
```

Each hop is a fresh exchange: the next agent sends the token it received as `subject_token` and its own token as `actor_token`.

### Narrowing rules

On a hop made with a real actor credential, the incoming token is the ceiling:

| You ask for | What happens |
| --- | --- |
| A scope not in the incoming token, or not allowed to this client | `invalid_scope`, nothing is trimmed |
| A resource not in the incoming `aud`, or not allowed to this client | `invalid_target` |
| A `tessera:` scope, or Tessera's own APIs as resource | Refused |
| Nothing (no `scope`, no `resource`) | The hop keeps what it received, limited to what the client allows |
| A longer life | The lifetime is at most what the incoming token has left |

`roles` and `permissions` are the person's current roles that the [ceiling](#limit-the-roles-an-agent-carries) of the agent behind the delegation allows, and that the incoming token also lists, with their permissions. A new agent has none.

### Naming the next agent with may_act

Repeat the `may_act` form parameter (up to 10 values, 256 characters each) with the `act.sub` of each agent allowed to take the next hop. The issued token carries them:

```json
{ "may_act": [{ "sub": "agent-b" }] }
```

If agent C then tries to exchange that token, the answer is `invalid_grant` and the audit log records `may_act_mismatch`. A token without `may_act` allows any actor that passes the other rules. The issued token does not inherit `may_act`; each token names its own next step. A `may_act` claim that cannot be read refuses every hop.

### Limits

- The realm maximum is 5 hops by default. Change it with `token_exchange_max_chain_depth` (1 to 10) on the realm.
- Lower it for chains through one agent: `tessera delegation limit service_account agent-b --max-depth 2`. The types are `agent`, `service_account` and `workload`. `tessera delegation limits` lists them, `unlimit` removes one.
- An actor that already appears in the chain is refused (`actor_in_chain`), which also stops loops.

## Services acting for services

By default the subject must be a person. To let an agent act for a service with no person involved, turn on `service_delegation` for the agent's own client, the one that makes the exchange and authenticates the request:

```sh
tessera delegation limit service_account agent-a --service-delegation --realm acme
```

That client may then use another service's `client_credentials` token, or a workload or agent token, as `subject_token`, with its own token as `actor_token`. The result has `sub` = the service that owns the subject token and `act` = the agent. Setting the flag on the service that owns the subject token does nothing: without it on the exchanging client the exchange is refused with `invalid_grant` ("subject token cannot be exchanged") and audited as `service_delegation_disabled`. The command also needs the `clients:write` scope.

> **Planned.** A chain that starts from a service token takes one hop today. The token a service-rooted exchange returns is refused as the `subject_token` of a second exchange (`invalid_grant`, "subject token subject is invalid"), even when the second client has `service_delegation`. Chains that start from a person's token are not affected.

## Errors

Errors follow RFC 6749: `{"error": "...", "error_description": "..."}` with status `400` (see [error codes](/docs/reference/error-codes.md)).

| `error` | Meaning |
| --- | --- |
| `unauthorized_client` | The client lacks the token exchange grant, or its policy is `disabled` |
| `invalid_request` | `actor_token` or the subject fields are missing, or `may_act` has more than 10 values |
| `unsupported_token_type` | A token type other than an access token (or, for the actor, a JWT) |
| `invalid_grant` | A bad, expired or foreign token; actor already in the chain; `may_act` mismatch; chain too deep; subject token is DPoP-bound and the request was signed with another key |
| `invalid_scope` / `invalid_target` | The request is wider than the incoming token or the client allows |

A killed agent or client gets `403 access_denied` with an `error_code` instead (see [the kill switch](/docs/agents/revocation-and-kill-switch.md#what-a-killed-agent-sees)), and a rate limit gives `429` (see [quotas](/docs/agents/quotas-and-usage.md)).

## Sender-constrained hops (DPoP)

If the incoming token is bound to a DPoP key, the exchange must carry a DPoP proof signed with that key, or it is refused. The issued token is bound to the key of the request that obtained it. Use DPoP for every client that exchanges: a bearer token can be passed on by whoever holds it. See [protect an MCP server](/docs/agents/protect-an-mcp-server.md#dpop).

## Read the chain in your API

Validate the token as usual (see [helper libraries](/docs/connect/helpers.md#validate-an-access-token-in-your-api)), then read `act`. It is a nested claim: the outer `act` is the latest actor, and it may hold its own `act` for the one before.

```ts
type Actor = { sub: string; sub_type?: string; act?: Actor };

function actors(claims: { act?: Actor }): { sub: string; subType?: string }[] {
  const chain = [];
  for (let actor = claims.act; actor; actor = actor.act) chain.push({ sub: actor.sub, subType: actor.sub_type }); // latest first
  return chain;
}
```

The same loop in Go: decode `act` into a struct with a pointer to itself (`Act *Actor`) and follow it until it is nil.

Introspection (`POST $ISSUER/introspect`) returns `act`, `may_act` and `delegation_depth` (the number of nested `act` objects). A token that is not delegated has none of them. The caller must be a confidential client that is the token's own client or is registered with the token's audience in its `allowed_resources`; a public client gets `401 invalid_client`, and any other caller gets `{"active": false}`.

The audit log records every hop. `token_exchange.issued` carries `chain`, `depth`, `actor_credential` (`access_token`, `jwt` or `agent_id`), `subject_kind` and `narrowing` (what the hop removed). Refusals are `token_exchange.policy_rejected` with a `reason` (`may_act_mismatch`, `actor_in_chain`, `service_delegation_disabled`, `asserted_identity_subject`, `legacy_actor_disabled`) and `token_exchange.chain_depth_exceeded` (with the limit and who set it).

## The agent id form is deprecated

Older integrations send a delegated agent's id (a UUID) as `actor_token`. An id is a name, not a credential, so this form is being retired. It still works by default, keeps its old behavior (the scope and audiences you ask for are intersected with the agent's allowlists and the client's, and extras are dropped without an error), and every use is audited as `token_exchange.legacy_actor_used`.

To move off it, give each agent a client that sends its own token, watch the audit log until `token_exchange.legacy_actor_used` stops, then end the form:

```sh
tessera delegation legacy-actor --disable
tessera delegation legacy-actor --sunset 2026-12-01T00:00:00Z
```

After that, a request with an agent id is refused with `invalid_grant` ("agent id actor tokens are no longer accepted; send the agent's access token").
