Delegations
A delegation is one principal’s permission for another to act for it: within listed permissions, in one workspace unless it only fetches connected accounts, until it expires. The principal that gives the permission is the delegator, and the one that receives it is the delegate. The delegate acts with its own credentials: it exchanges its session or API key for short-lived delegated tokens that act as the delegator.
Any principal that is not a guest delegates to any other principal that is not a guest, whatever kind either declares, such as a human to an agent, or an agent to another agent. A guest signs in first, and a principal can’t delegate to itself.
What it allows
- Concrete permissions, 1 to 100, each as
<resourceType>:<action>with no wildcard, such asreport:edit. - Role permissions. When the delegation takes effect, the delegator must hold each permission other than
identity.connection:usethrough a project role or its role in the delegation’s workspace. Otherwise IdentityHound answersforbiddenwithdetails.reasonset todelegation_scope. Resource roles don’t count. A delegator acting with a restricted API key delegates only within the key’s restrictions. - One workspace. A delegation names its
workspaceIdand covers only that workspace’s resources. Only one whose sole permission isidentity.connection:usemay leave it out; any other without it answersinvalid_request. In access checks, a delegation for an archived workspace grants nothing. - Connected accounts. With
identity.connection:useamong its permissions, the delegation must name the provider app keys inconnections, such astwitch. The delegate can then ask for the delegator’s provider tokens for those connected accounts. - One hop. A delegated token can’t create, request, approve, deny, or revoke a delegation, or be exchanged for another delegated token, so a delegate can’t pass its authority on.
An access check through a delegation still needs the delegator’s own role and any required entitlement. Outside the delegation’s permissions, a check answers delegation_scope.
How it starts
- The delegator delegates, with its own session or API key, or your server delegates for it, naming
delegatorId. It isactiveat once. - The delegate asks, with its own session or API key, naming
delegatorId. It isrequesteduntil the delegator approves or denies it with its own session or API key, or your server does once the delegator agrees in your app. A delegate may send 20 requests every 15 minutes.
Every delegation states its term: expiresIn is required when a delegation is created or requested, and the delegation lasts that long from then. It is at most the config’s delegations.maxTtl, 30 days in a new project, and a longer one is refused with invalid_request. Approving a request doesn’t move its end: a request not approved in that time expires, and approving it then answers conflict.
A delegation’s reason is at most 1,000 characters.
Delegated tokens
The delegate exchanges its own session or API key, and an active delegation, for a delegated token. The token acts as the delegator, with the delegate and the delegation applied to every check:
- It lasts for the requested
expiresInor, if omitted, the config’sdelegations.tokenTtl, 15 minutes in a new project. That setting also caps the requested term, and the token never lasts past the delegation’s end. - It stops at once when the delegation ends, when the session or API key it came from stops, when either principal is suspended or deleted, or when the delegator revokes its other sessions.
- Of the delegator’s own account, it reaches only
GET /meand sign-out. Signing out ends this delegated token. To revoke the delegation itself, the delegate uses its own session or API key.
A delegated token is a kind of session, with no idle limit.
How it ends
A delegation is requested, active, denied, revoked, or expired. Its delegator, its delegate, your server, or a principal with identity.delegation:revoke in its workspace revokes it. Suspending or deleting either principal revokes every requested and active delegation it is a party to. Each ending stops the delegation’s tokens in the same moment.
On record
The change feed records which delegate acted for which delegator, and Access checks explains how your server names or chooses the delegation for a check.
Where to act on it
- Let one principal act for another requests, approves, and acts within one.
- Delegations has every operation, from creating one to getting a delegated token.