Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Delegations

Permission for one principal to act for another, within listed permissions, a workspace, and an expiry. The delegate exchanges its API key or session for short-lived delegated tokens, and every check and event keeps both identities.

Delegations explains what a delegation allows, how delegated tokens work, and what ends them.

Paths are relative to https://api.agentpost.tools/v1/identity, and every request follows the API basics. Who may call explains each kind of caller.

Create a delegation

POST /delegations

A principal delegates directly to another principal.

  • Who may call: Your server or a signed-in principal.
  • Access: The delegator uses its own session or API key. Your server names the delegator.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.create(input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Body

Name Type Required Description
delegatorId string No A principal ID, prn_….
delegateId string Yes A principal ID, prn_….
workspaceId string No The workspace the delegation covers. Required, unless identity.connection:use is its only permission.
permissions string[] Yes Each as <resourceType>:<action>, with no wildcard. A delegation never grants more than the delegator holds; 1–100 items.
connections string[] No At least 1.
expiresIn string Yes A duration, such as “15m” or “30d”.
reason string No Up to 1000 characters.

Response

201 Created, with:

Name Type Present Description
delegation Delegation Always

Errors

Any operation can also answer with the codes Conventions lists.

Request a delegation

POST /delegations/requests

The delegate requests a delegation. The delegator approves or denies it. Throttled per delegate.

  • Who may call: A signed-in principal.
  • Access: The delegate, with its own session or API key.
  • Credential: the examples send the principal’s API key, agp_ak_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.request(input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Body

Name Type Required Description
delegatorId string Yes A principal ID, prn_….
workspaceId string No The workspace the delegation covers. Required, unless identity.connection:use is its only permission.
permissions string[] Yes Each as <resourceType>:<action>, with no wildcard. A delegation never grants more than the delegator holds; 1–100 items.
connections string[] No At least 1.
expiresIn string Yes A duration, such as “15m” or “30d”.
reason string No Up to 1000 characters.

Response

201 Created, with:

Name Type Present Description
delegation Delegation Always

Errors

Any operation can also answer with the codes Conventions lists.

List delegations

GET /delegations

Delegations the caller gave or holds, filtered by status, delegator, or delegate.

  • Who may call: Your server or a signed-in principal.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.list(query)
  • Pages: limit, 1 to 500, default 100. The answer holds up to limit items; narrow the query’s filters to reach others.

Query parameters

Name Type Required Description
delegatorId string No A principal ID, prn_….
delegateId string No A principal ID, prn_….
workspaceId string No A workspace ID, wsp_….
status string No One of "requested", "active", "denied", "revoked", or "expired".
limit integer No 1–500; default 100.

Response

200 OK, with:

Name Type Present Description
delegations Delegation array Always

Errors

Any operation can also answer with the codes Conventions lists.

Get a delegation

GET /delegations/:id

One delegation. A delegate that requested one reads it until its status is active or denied.

  • Who may call: Your server or a signed-in principal.
  • Access: Its delegator or delegate.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.get(id)

Path parameters

Name Type Required Description
id string Yes A delegation ID, dlg_…. The id of a Delegation.

Response

200 OK, with:

Name Type Present Description
delegation Delegation Always

Errors

Any operation can also answer with the codes Conventions lists.

Approve a delegation

POST /delegations/:id/approve

Approves a requested delegation.

  • Who may call: Your server or a signed-in principal.
  • Access: Its delegator, with its own session or API key, or your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.approve(id)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A delegation ID, dlg_…. The id of a Delegation.

Response

200 OK, with:

Name Type Present Description
delegation Delegation Always

Errors

Any operation can also answer with the codes Conventions lists.

Deny a delegation

POST /delegations/:id/deny

Denies a requested delegation.

  • Who may call: Your server or a signed-in principal.
  • Access: Its delegator, with its own session or API key, or your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.deny(id)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A delegation ID, dlg_…. The id of a Delegation.

Response

200 OK, with:

Name Type Present Description
delegation Delegation Always

Errors

Any operation can also answer with the codes Conventions lists.

Revoke a delegation

DELETE /delegations/:id

Revokes a delegation. Its delegated tokens and connection access stop at once.

  • Who may call: Your server or a signed-in principal.
  • Access: Its delegator or delegate, or anyone with identity.delegation:revoke in its workspace. Not with a delegated token.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.revoke(id)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A delegation ID, dlg_…. The id of a Delegation.

Response

204 No Content, with no body.

Errors

Any operation can also answer with the codes Conventions lists.

Get a delegated token

POST /delegations/:id/tokens

Exchanges the delegate’s API key or session for a delegated token, lasting the config’s delegations.tokenTtl unless expiresIn is shorter, and never past the delegation’s expiry. Answers conflict until the delegation is approved.

  • Who may call: A signed-in principal.
  • Access: The delegate, with its API key or session.
  • Credential: the examples send the principal’s API key, agp_ak_…, as Authorization: Bearer <token>.
  • SDK: client.delegations.token(id, input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A delegation ID, dlg_…. The id of a Delegation.

Body

The body is optional.

Name Type Required Description
expiresIn string No A duration, such as “15m” or “30d”.

Response

201 Created, with DelegatedToken.

Errors

Any operation can also answer with the codes Conventions lists.

The Delegation object

Permissions a delegator grants its delegate (ih_delegations). permissions are concrete, never wildcards, so they can be checked against what the delegator holds. connections names the provider keys the delegate may fetch the delegator’s connected-account tokens for, which also needs identity.connection:use in permissions.

Name Type Present Description
id string Always A delegation ID, dlg_….
delegatorId string Always A principal ID, prn_….
delegateId string Always A principal ID, prn_….
workspaceId string When set A workspace ID, wsp_….
permissions string[] Always
connections string[] When set
status string Always One of "requested", "active", "denied", "revoked", or "expired".
reason string When set
expiresAt string Always An ISO 8601 date and time.
createdAt string Always An ISO 8601 date and time.
createdBy string Always A principal ID, prn_…, or "trusted_caller".
requestedAt string When set An ISO 8601 date and time.
decidedAt string When set An ISO 8601 date and time.
decidedBy string When set A principal ID, prn_…, or "trusted_caller".
revokedAt string When set An ISO 8601 date and time.
revokedBy string When set A principal ID, prn_…, or "trusted_caller".
expiredAt string When set An ISO 8601 date and time.

The DelegatedToken object

The short-lived token the delegate uses to act for the delegator.

Name Type Present Description
token string Always The bearer token. Shown once.
session Session Always
actor Principal Always The delegate, which makes requests with the token.
onBehalfOf Principal Always The delegator the delegate acts for.
delegation Delegation Always