Overview
This topic describes the permission model and configuration methods of Agent ID Guard. It explains how to control the inbound permissions of clients that access Agents. It also explains how to control the outbound permissions of Agents that access backend services. Finally, it explains how to link inbound identities with outbound calls through the identity chain. These controls help you build a complete, least-privilege, and auditable permission governance system for AI Agents in Agent ID Guard.
Background information
As AI Agents are deployed at scale in enterprises, an Agent is no longer just a "chatbot" that passively responds to users. Instead, it is a "digital worker" that makes decisions autonomously. It invokes large language models (LLMs), MCP Servers, internal enterprise APIs, and third-party SaaS services on its own. The autonomy and chained invocation of Agents break the traditional "user → application → resource" two-party authorization model. They introduce a new chain-of-delegation problem: "who is acting on behalf of whom, and doing what?"
A typical Agent invocation chain is User → Client → Agent → LLM / third-party service / enterprise service. If strict identity and permission controls are not enforced on each hop, the following risks arise:
Clients call the Agent beyond their permissions: any client application that obtains the API endpoint of the Agent can send requests directly. There is no way to restrict "which application, on behalf of which user" may call a specific Agent.
Agents hold "super permissions": to let an Agent "do everything", developers often grant it Administrator-level downstream access permissions. If a prompt injection attack compromises the Agent, it becomes an "insider" with the highest privileges.
Lost context and identity: in a long chain such as User → Agent A → Agent B → database, the database sees only Agent B. It cannot trace the request back to the user who initiated it, so auditing and compliance cannot be enforced.
Plaintext credential abuse: long-lived credentials such as API keys and client secrets are hardcoded in the Agent code. This poses a serious leakage risk.
Agent identity security in Agent ID Guard centers on the Agent as the core identity. It breaks these risks down into two directions: inbound permissions (Client → Agent) and outbound permissions (Agent → downstream services). It provides fine-grained permission control and auditing for each direction.
For an overview of Agent identity security, see What is Agent identity security.
Agent ID workflow

Core concepts of the permission model
Five roles
Role | Business meaning | Corresponding entity in Agent ID Guard |
User | The natural person who actually "presses the button", for example, the employee Xiao Wang. | Agent ID Guard account (including organizations and groups). |
Client | The front-end entry point that users interact with directly, such as an enterprise portal, a desktop application, or a mini program. | "OIDC With M2M application" (capable of login interaction). |
Agent | An AI service that receives requests from users or clients and autonomously invokes downstream capabilities. | "Agent application" (holds a dual identity: callee + caller). |
Resource Server (downstream service) | The backend that actually hosts business data or capabilities, such as an HR system, a knowledge base, or third-party SaaS. | LLMs, enterprise services, and third-party services, which the Agent invokes as resource services. |
Agent ID Guard | Issues and verifies tokens, and registers authorization relationships. | Alibaba Cloud Agent ID Guard (this product). |
In Agent ID Guard, an Agent plays two roles at the same time. As the "callee" (invoked by clients), it is a Resource Server. As the "caller" (invoking downstream services), it is a Client. This "dual identity" is the foundation for linking outbound and inbound permissions.
Inbound permissions vs. outbound permissions: two edges, two sets of configurations
Permission control diagram

Token Exchange: the "transfer gate" for permission convergence
Token Exchange (RFC 8693) can be understood as a transfer gate in an identity system. You walk up to the gate with your original ticket (the inbound access token). The gate verifies it. It then gives you a new ticket that can only take you to the next stop, in this specific carriage (the outbound access token). The original ticket cannot be used for the next leg. The new ticket cannot take you back to the previous leg.
Concept analogy | Meaning |
Original ticket = inbound access token | Granted by the user to the client, and used when the client calls the Agent. |
Gate = the token endpoint of Agent ID Guard (grant_type = token-exchange) | Verifies the validity of the original ticket and checks the outbound authorization relationships. Issues a new ticket based on the least-privilege principle. |
New ticket = outbound access token | Usable only within the range of "the downstream service being accessed this time + the scopes that were requested". |
Gate record = the _idaas_imp / _idaas_exchange_count records in the outbound access token | Leaves an audit trail for traceability. |
Inbound permissions: which client can call the Agent
Background
Once an Agent is published, in theory any program that obtains its public endpoint may try to call it. Without inbound access control, two types of risks arise:
Unauthorized invocation: an unknown application obtains the URL of the Agent. It forges a token issued by another IdP or constructs arbitrary requests to probe it.
Over-privileged invocation: a legitimate integrator requests overly broad scopes. For example, a client that should only be allowed to "access the Agent" obtains the permission to "call the management APIs of the Agent".
Scenario
In an IDaaS instance, an enterprise portal and a mobile app are both integrated with the same "AI Leave Assistant" Agent. The portal is Client A, an OIDC With M2M application. The app is Client B, another OIDC With M2M application. You must ensure the following:
Both Client A and Client B must be registered in Agent ID Guard before they can call the Agent with an inbound access token.
Client A can enter the Agent only with the minimal scope agent.access. It cannot obtain any other higher-privilege scopes on the Agent.
Client C (not integrated or not authorized) cannot pass the validation of the Agent, even if it forges a seemingly legitimate token.
Pain points
Anti-pattern | Risk |
Writing your own IP address allowlist inside the Agent. | An IP address is a network-layer signal that cannot represent "who is calling". The maintenance cost is high in dynamic environments. |
Having the Agent verify API keys on its own. | A key must be issued for every client that is integrated. Rotation, revocation, and auditing all happen outside Agent ID Guard. |
Not verifying the audience, and only checking the token signature. | A token that was intended for another application may be replayed. This effectively hands the permission boundary entirely to the token holder. |
Solution
The authorization relationship of the "Client → Agent" edge is centralized in Agent ID Guard. Agent ID Guard trims the audience and the scopes based on the authorization relationship when it issues an inbound access token. The Agent strictly verifies the audience and the scopes when it validates the inbound access token.
The three control points for inbound permissions:
Control point | Where it takes effect | Behavior on failure |
1. Whether the client is authorized to call this Agent. | Checked when Agent ID Guard issues the inbound access token. | Agent ID Guard rejects the authorization request outright, or does not issue a token that contains the target audience. |
2. Whether the audience of the inbound access token matches the audience identifier of the Agent. | Checked when the Agent receives the request and validates the inbound access token. | The Agent returns 401/403. |
3. Whether the scope of the inbound access token includes the scopes required for this access. | Checked when the Agent receives the request and validates it against the API route. | The Agent returns 403 with a scope validation failure. |
Outbound permissions: what an Agent can do
Background
After an Agent receives a user request, it often needs to call one or more downstream services to complete the task. The downstream services may be:
Enterprise-owned APIs (such as HR, CRM, and ERP)
Third-party SaaS (such as GitHub, Lark, and Salesforce)
LLMs / vector databases / knowledge bases
To these downstream services, the Agent is a new type of "client". It is not the browser of a specific user. Instead, it is a program that may be shared by multiple users. Its decisions are made by an LLM. Without constraints on the outbound side, the Agent becomes a "super application" that holds access to all downstream services.
Scenario
Continuing the "AI Leave Assistant" example, the assistant needs to call two APIs of the HR system:
GET /user/read → requires the scope user.read
POST /user/write → requires the scope user.write
Requirements:
The Agent can call these two APIs within the user context.
The Agent cannot call other APIs of the HR system (such as admin.*).
The Agent cannot call other downstream services such as CRM or knowledge bases (unless separately authorized).
After the user revokes consent, the Agent immediately loses its outbound invocation capability.
Pain points
Anti-pattern | Risk |
The Agent directly uses the user's inbound access token to call downstream services. | The audience of the inbound access token is the Agent, not the downstream service, so the downstream service should reject it. If the downstream service does not strictly verify the audience, a "token replay" vulnerability is created. |
The Agent uses a fixed Service Account token to call downstream services. | The user context is lost. The downstream service cannot enforce row-level permissions or auditing. |
Hardcoding an AccessKey/AppSecret in the Agent. | Credential rotation is difficult. In multi-Agent scenarios, credentials are reused, which creates an audit blind spot. |
Solution: outbound authorization + Token Exchange
The authorization relationship of the "Agent → downstream service" edge is also centralized in Agent ID Guard:
In Agent ID Guard, declare the downstream service as a Resource Server (an OIDC With M2M application). Also declare its audience identifier and scope list (for example, user.read, user.write, and admin.delete).
In Agent ID Guard, create the outbound authorization for "Agent → downstream service". Select the subset of scopes that the Agent is allowed to request (for example, select only user.read).
Before calling the downstream service, the Agent performs a Token Exchange with the inbound access token it just received. It requests an outbound access token for the target downstream service from Agent ID Guard. The scopes can be freely selected within the outbound authorization. The following figure shows the Token Exchange process:

End-to-end scenario: linking inbound and outbound permissions
This section brings the preceding concepts together into a complete story: the "AI Leave Assistant" queries annual leave on behalf of the employee Xiao Wang.
Roles and configuration
Entity | Identifier in Agent ID Guard |
Agent ID Guard | idaas_jbfqz555uvm3n5a3vfuxyzxxxx / <YOUR-IDAAS>.aliyunidaas.com |
User | user_froj2vye7d46cf32bvp5utxxxx (Xiao Wang) |
Client (OIDC With M2M application) | app_nfiiybmikzo2fnmabpectnxxxx |
Agent application | app_niicndynmcf72rqvkw6szvxxxx, audience: agent-app_niicndynmcf72rqvkw6szvxxxx, scope: agent.access |
Downstream enterprise service (HR) | Audience: example:audience, scopes: user.read and user.write |
Authorization relationships:
Inbound: Client → Agent, authorized with agent.access.
Outbound: Agent → HR service, authorized with user.read and user.write.
User authorization: Xiao Wang has granted authorization to the client.
End-to-end sequence
Xiao Wang → Client: logs on to the enterprise portal.
Client → Agent ID Guard: redirects the user to the authorization page.
Agent ID Guard → Xiao Wang: displays the consent page "Allow the enterprise portal to use the AI Leave Assistant?"
Xiao Wang → Agent ID Guard: clicks Agree.
Agent ID Guard → Client: authorization is complete and the user is returned to the enterprise portal (an inbound access token is obtained).
Xiao Wang → Client: "How many days of annual leave do I have left?"
Client → Agent: sends a request to the AI Leave Assistant with the inbound access token.
Agent: validates the token and determines that the HR system needs to be queried.
Agent → Agent ID Guard: initiates a Token Exchange (target: the HR service; required permission: query user information).
Agent ID Guard: validates the request and checks whether the AI assistant is allowed to access the HR service.
Agent ID Guard → Agent: issues an outbound access token (allows the HR service to be queried on behalf of Xiao Wang).
Agent → HR: queries the annual leave of Xiao Wang with the outbound access token.
HR: validates the token and returns only the data of Xiao Wang.
HR → Agent: returns the annual leave data of Xiao Wang.
Agent → Client: generates a response.
Client → Xiao Wang: "You have X days of annual leave remaining".
FAQ
Why is the scope field empty in the access token that the client receives?
Check the following:
Whether the client passed the scope parameter in the correct format when it requested authorization (it must be in the audience|scope format).
Whether the scopes of the Agent have been granted to the client through inbound authorization.
For scopes of the manual authorization type, whether they have been individually authorized for the currently logged-on user.
How do I troubleshoot a failed Token Exchange API call?
Common causes:
The subject_token has expired or has been revoked.
The audience of the subject_token is not the Agent (that is, the client does not have permission to access the Agent).
The client_id is not a client that is authorized to initiate Token Exchange (it must be the application that corresponds to the Agent node).
The requested audience|scope has not been authorized for this Agent (outbound authorization is missing).
Agent ID Guard does not allow a client to perform a Token Exchange with "a token that it requested itself".
For detailed error codes and troubleshooting methods, see Token Exchange configuration guide.
Why does an Agent not need manual outbound authorization to call an LLM API Key node?
The outbound authorization of LLM nodes and third-party service nodes is essentially a "data permission". When an Agent is created, Agent ID Guard automatically initializes an authorization rule that is exclusive to that Agent. When you add an LLM or third-party service node, the system automatically adds the corresponding credential to this exclusive authorization rule. No manual operation is required. To make changes, you can delete the node directly (which removes the resource from the exclusive authorization rule).
What happens when I delete a node from an Agent workflow?
Deleting a node only disassociates the node from the current Agent. It does not delete the underlying application or credential:
Deleting a client node: revokes the inbound authorization of that client for the Agent. The client application itself is retained (to delete it, go to Application Management → M2M Applications).
Deleting an LLM or third-party service node: removes the credential from the exclusive authorization rule of the Agent. The credential itself is retained (to delete it, go to Asset Center → Credentials).
Deleting an enterprise service node: revokes the outbound authorization of the Agent for the scopes of that enterprise service. The enterprise service application is retained. For details about outbound authorization, see Agent ID Guard outbound authorization.