Manage tool gateway deployment tokens for an agent
Who can manage gateway deployment tokens
Section titled “Who can manage gateway deployment tokens”Developers or administrators who manage an agent’s runtime integration can use this workflow.
Prerequisites
- You need access to the project with
agentRegistry:CUDscope to read token state for the agent. - You also need agent folder access for the specific agent.
- 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
agentIdandprojectId.
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
- Call the
gatewayTokens.listoperation withprojectIdandagentId. - Read
slotsto find the agent deployment slots AOS knows about. - Read
tokensto inspect previously issued tokens for that agent. - Check
agentRetiredbefore planning a new issue. - Use
expiryDaysanddefaultExpiryDaysto 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_FOUNDmeans 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 or rotate a deployment token
Section titled “Issue or rotate a deployment token”Issue a token for a specific applicationId slot.
Numbered steps
- Call
gatewayTokens.issuewithprojectId,agentId, and the targetapplicationId. - Optionally set
expiresInDaysto one of30,90,180, or365. If omitted, AOS uses the default expiry. - Store the returned plaintext token immediately. AOS returns it once and does not store, log, or audit the plaintext value.
- Save the returned
envVar,deploymentIdHeader,toolCallsPath, andtoolsPathwith your runtime configuration. - If
rotatedistrue, replace the previous live token in your runtime or secret store.
Expected result AOS creates a token for the selected slot and returns:
tokenas 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, and365days. - 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
SALTconfiguration.
Common failures
PRECONDITION_FAILEDwith a retired agent: use a non-retired agent.BAD_REQUESTfor an unknownapplicationId: reload slots and choose one returned bylist.PRECONDITION_FAILEDfor missingSALT: ask the AOS operator to configure the instance.CONFLICTmeans 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
- Put the plaintext token into the environment variable name returned by AOS in
envVar. - Send the token as
Authorization: Bearer <token>on gateway requests. - Use
toolCallsPathfor tool execution requests andtoolsPathfor tool listing requests. - Include the deployment identifier in the header name returned as
deploymentIdHeaderwhen your runtime contract requires it. - Only a valid
okresponse 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 serializelistTools()or independent client instances. - Sandbox token chains use the
x-aos-next-tokenresponse 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
okresponse 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
- Call
gatewayTokens.revokewithprojectId,agentId, and the token recordtokenId. - If the token is already revoked, keep the returned token metadata as the current state.
- 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_FOUNDmeans 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.