Skip to content

Manage tool gateway deployment tokens for an agent

Developers or administrators who manage an agent’s runtime integration can use this workflow.

Prerequisites

  1. You need access to the project with agentRegistry:CUD scope to read token state for the agent.
  2. You also need agent folder access for the specific agent.
  3. To issue, rotate, or revoke a token, you additionally need project:update.

Where to start This guide describes the internal agent-builder gatewayTokens router contract for a project and agent. It does not establish a public SDK method or an external HTTP endpoint for token management.

Expected result You can list deployment slots and token records, then issue a new token, rotate an existing live token for the same slot, or revoke a token.

Common failures

  • If the project permission check fails, request the required project scope.
  • If agent folder access fails, ask an administrator to grant access to that agent.
  • If the agent does not exist in the project, verify the agentId and projectId.

List slots and existing tokens for an agent

Section titled “List slots and existing tokens for an agent”

Use the list operation before issuing a token.

Numbered steps

  1. Call the gatewayTokens.list operation with projectId and agentId.
  2. Read slots to find the agent deployment slots AOS knows about.
  3. Read tokens to inspect previously issued tokens for that agent.
  4. Check agentRetired before planning a new issue.
  5. Use expiryDays and defaultExpiryDays to choose a supported token lifetime for a later issue request.

Expected result AOS returns:

  • deployment slots, including applicationId, slotId, and whether each slot is current or already deployed
  • token records with creation, expiry, last use, and revocation fields
  • whether the agent is retired
  • supported expiry information

Defaults and ceilings

  • AOS returns at most 50 token records in this list call.
  • Deployment attempts considered for slot discovery are limited to 200 records.

Common failures

  • NOT_FOUND means the agent was not found in the project.
  • An empty slot list means AOS could not resolve a current or previously deployed application slot for that agent from the stored definition metadata and deployment history.

Issue a token for a specific applicationId slot.

Numbered steps

  1. Call gatewayTokens.issue with projectId, agentId, and the target applicationId.
  2. Optionally set expiresInDays to one of 30, 90, 180, or 365. If omitted, AOS uses the default expiry.
  3. Store the returned plaintext token immediately. AOS returns it once and does not store, log, or audit the plaintext value.
  4. Save the returned envVar, deploymentIdHeader, toolCallsPath, and toolsPath with your runtime configuration.
  5. If rotated is true, replace the previous live token in your runtime or secret store.

Expected result AOS creates a token for the selected slot and returns:

  • token as the plaintext secret
  • token metadata such as id, applicationId, slotId, displayToken, and expiry timestamps
  • integration constants for runtime configuration
  • whether the request rotated an earlier token for the same slot

Configuration and defaults

  • Supported expiries are exactly 30, 90, 180, and 365 days.
  • Issuing a token revokes previous unrevoked tokens for the same slot in the same transaction, including any that have already expired.
  • A retired agent cannot receive a new gateway token.
  • Token issuance requires instance SALT configuration.

Common failures

  • PRECONDITION_FAILED with a retired agent: use a non-retired agent.
  • BAD_REQUEST for an unknown applicationId: reload slots and choose one returned by list.
  • PRECONDITION_FAILED for missing SALT: ask the AOS operator to configure the instance.
  • CONFLICT means another token was issued for the same slot at the same time; reload and try again.

Illustrative response fields

{
"token": "SECRET_TOKEN_VALUE",
"applicationId": "APPLICATION_ID",
"slotId": "SLOT_ID",
"envVar": "ENV_VAR_NAME",
"deploymentIdHeader": "HEADER_NAME",
"toolCallsPath": "/api/agent-gateway/v1/tool-calls",
"toolsPath": "/api/agent-gateway/v1/tools",
"rotated": true
}

Use the returned token in a runtime integration

Section titled “Use the returned token in a runtime integration”

After issuing a token, configure your runtime to call the AOS tool gateway with the returned values.

Numbered steps

  1. Put the plaintext token into the environment variable name returned by AOS in envVar.
  2. Send the token as Authorization: Bearer <token> on gateway requests.
  3. Use toolCallsPath for tool execution requests and toolsPath for tool listing requests.
  4. Include the deployment identifier in the header name returned as deploymentIdHeader when your runtime contract requires it.
  5. Only a valid ok response confirms execution to this client. An error, timeout, or malformed response does not prove the tool did not run; do not retry side effects without the appropriate idempotency contract.

Expected result Your runtime can list allowed tools and call the tool gateway using the deployment token AOS issued for the selected slot.

Technical behavior

  • The reference client default timeout is 10 seconds unless overridden.
  • The reference client serializes its call() requests one at a time. This does not serialize listTools() or independent client instances.
  • Sandbox token chains use the x-aos-next-token response header; when present, later requests must use the new token.
  • For tool listing, anything except a valid listed response is treated as not listed.
  • For tool calls, only a valid ok response is considered executed.

The source includes a reference createToolGatewayClient, not a documented standalone SDK import. Its HTTP request builder sends Bearer authorization but does not implement the returned deployment-ID header. A production adapter must implement its required deployment contract explicitly. Use the returned environment variable name instead of guessing one, and keep the token out of logs.

Revoke a token when a slot should lose runtime authority

Section titled “Revoke a token when a slot should lose runtime authority”

Revoke a token when you no longer want that deployment slot to access the tool gateway.

Numbered steps

  1. Call gatewayTokens.revoke with projectId, agentId, and the token record tokenId.
  2. If the token is already revoked, keep the returned token metadata as the current state.
  3. Remove the revoked plaintext token from your runtime or secret store.

Expected result The token record is marked revoked with revocation metadata and should no longer be used by the runtime.

Common failures

  • NOT_FOUND means the token does not belong to that project and agent, or does not exist.
  • If your runtime still holds the old secret after revocation, update or restart the runtime through your normal operational process.