Microsoft Entra Agent ID skill

Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmi_path, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar.

by microsoft·MIT license·★ 1,532 Stars on the repo·GitHub ↗

Use now

Files of Microsoft Entra Agent ID

microsoft/main1 file shown
SKILL.md
Show the full text357 lines

Microsoft Entra Agent ID

Create and manage OAuth 2.0-capable identities for AI agents using Microsoft Graph. Every agent instance gets a distinct identity, audit trail, and independently-scoped permission grants.

Quick Reference

Property Value
Service Microsoft Entra Agent ID
API Microsoft Graph (https://graph.microsoft.com/v1.0)
Required role Agent Identity Developer, Agent Identity Administrator, or Application Administrator
Object model Blueprint (application) → BlueprintPrincipal (SP) → Agent Identity (SP)
Runtime exchange Two-step fmi_path exchange (autonomous and OBO)
.NET helper Microsoft.Identity.Web.AgentIdentities
Polyglot helper Microsoft Entra SDK for AgentID (sidecar container)

When to Use This Skill

  • Provisioning a new Agent Identity Blueprint and BlueprintPrincipal
  • Creating per-instance Agent Identities under a Blueprint
  • Configuring credentials (FIC, Managed Identity, or client secret) on the Blueprint
  • Implementing the two-step fmi_path runtime token exchange (autonomous or OBO)
  • Cross-tenant agent token flows
  • Deploying the Microsoft Entra SDK for AgentID sidecar for polyglot agents (Python, Node, Go, Java)
  • Granting per-Agent-Identity application (appRoleAssignments) or delegated (oauth2PermissionGrants) permissions
  • Diagnosing Agent ID errors such as AADSTS82001, AADSTS700211, or PropertyNotCompatibleWithAgentIdentity

MCP Tools

Tool Use
mcp_azure_mcp_documentation Search Microsoft Learn for current Agent ID setup, Graph API shapes, and SDK configuration

There is no dedicated Agent Identity MCP server today. This skill guides direct Microsoft Graph API calls (PowerShell or Python requests). Use mcp_azure_mcp_documentation to verify request bodies and endpoints against current docs before running.

Before You Start

Use the mcp_azure_mcp_documentation tool to search Microsoft Learn for current Agent ID documentation:

  • "Microsoft Entra Agent ID setup instructions"
  • "Microsoft Entra SDK for AgentID"

Verify request bodies and endpoints against the installed SDK version — Graph API shapes evolve.

Conceptual Model

Agent Identity Blueprint (application)         ← one per agent type/project
  └── BlueprintPrincipal (service principal)    ← MUST be created explicitly
        ├── Agent Identity (SP): agent-1        ← one per agent instance
        ├── Agent Identity (SP): agent-2
        └── Agent Identity (SP): agent-3
Concept Description
Blueprint Application object that defines a type/class of agent. Holds credentials (secret, certificate, federated identity).
BlueprintPrincipal Service principal for the Blueprint in the tenant. Not auto-created.
Agent Identity Service-principal-only identity for a single agent instance. Cannot hold its own credentials.
Sponsor A User (or Group, for Agent Identity) who is responsible for the identity. Required on creation.

Prerequisites

Required Entra Roles

One of: Agent Identity Developer, Agent Identity Administrator, or Application Administrator.

PowerShell (interactive setup)
# PowerShell 7+
Install-Module Microsoft.Graph.Applications -Scope CurrentUser -Force
Python (programmatic provisioning)
pip install azure-identity requests

Authentication

DefaultAzureCredential is not supported. Azure CLI tokens carry Directory.AccessAsUser.All, which Agent Identity APIs hard-reject (403). Use a dedicated app registration with client_credentials, or Connect-MgGraph with explicit delegated scopes.

PowerShell (delegated)
Connect-MgGraph -Scopes @(
    "AgentIdentityBlueprint.Create",
    "AgentIdentityBlueprint.ReadWrite.All",
    "AgentIdentityBlueprintPrincipal.Create",
    "AgentIdentity.Create.All",
    "User.Read"
)
Python (application)
import os, requests
from azure.identity import ClientSecretCredential

credential = ClientSecretCredential(
    tenant_id=os.environ["AZURE_TENANT_ID"],
    client_id=os.environ["AZURE_CLIENT_ID"],
    client_secret=os.environ["AZURE_CLIENT_SECRET"],
)
token = credential.get_token("https://graph.microsoft.com/.default")

GRAPH = "https://graph.microsoft.com/v1.0"
headers = {
    "Authorization": f"Bearer {token.token}",
    "Content-Type": "application/json",
    "OData-Version": "4.0",
}

Core Workflow

Step 1: Create Agent Identity Blueprint

Use the typed endpoint. Sponsors must be Users at Blueprint creation. This snippet assumes the requests client and headers dict from the Python authentication block above.

import subprocess
import requests

user_id = subprocess.run(
    ["az", "ad", "signed-in-user", "show", "--query", "id", "-o", "tsv"],
    capture_output=True, text=True, check=True,
).stdout.strip()

blueprint_body = {
    "displayName": "My Agent Blueprint",
    "[email protected]": [
        f"https://graph.microsoft.com/v1.0/users/{user_id}"
    ],
}
resp = requests.post(
    f"{GRAPH}/applications/microsoft.graph.agentIdentityBlueprint",
    headers=headers, json=blueprint_body,
)
resp.raise_for_status()

blueprint = resp.json()
app_id = blueprint["appId"]
blueprint_obj_id = blueprint["id"]
Step 2: Create BlueprintPrincipal

Mandatory. Creating a Blueprint does NOT auto-create its service principal. Skipping this step produces: 400: The Agent Blueprint Principal for the Agent Blueprint does not exist.

sp_body = {"appId": app_id}
resp = requests.post(
    f"{GRAPH}/servicePrincipals/microsoft.graph.agentIdentityBlueprintPrincipal",
    headers=headers, json=sp_body,
)
resp.raise_for_status()

Make your provisioning scripts idempotent — always check for the BlueprintPrincipal even when the Blueprint already exists.

Step 3: Create Agent Identities

Sponsors for an Agent Identity may be Users or Groups.

agent_body = {
    "displayName": "my-agent-instance-1",
    "agentIdentityBlueprintId": app_id,
    "[email protected]": [
        f"https://graph.microsoft.com/v1.0/users/{user_id}"
    ],
}
resp = requests.post(
    f"{GRAPH}/servicePrincipals/microsoft.graph.agentIdentity",
    headers=headers, json=agent_body,
)
resp.raise_for_status()
agent = resp.json()
agent_sp_id = agent["id"]

Runtime Authentication

Agents authenticate at runtime using credentials configured on the Blueprint (not on the Agent Identity — Agent Identities can't hold credentials).

Option Use case Credential on Blueprint
Managed Identity + WIF Production (Azure-hosted) Federated Identity Credential
Client secret Local dev / testing Password credential
Microsoft Entra SDK for AgentID Polyglot / 3P agents Sidecar container acquires tokens over HTTP

For the two-step fmi_path exchange (parent token → per-Agent-Identity Graph token) that gives each agent instance a distinct sub claim and audit trail, see references/runtime-token-exchange.md.

For OBO (agent acting on behalf of a user), see references/obo-blueprint-setup.md.

For the containerized polyglot auth sidecar (Python, Node, Go, Java — no SDK embedding), see references/sdk-sidecar.md.

For MI+WIF and client-secret setup details, see references/oauth2-token-flow.md.

.NET quick path

For .NET services, use Microsoft.Identity.Web.AgentIdentities — it handles Federated Identity Credential management and the two-step exchange for you. See the package README at github.com/AzureAD/microsoft-identity-web under src/Microsoft.Identity.Web.AgentIdentities/.

Granting Permissions (Per Agent Identity)

Agent Identities support both application permissions (autonomous) and delegated permissions (OBO). Grants are scoped per Agent Identity, not to the BlueprintPrincipal.

Application permissions (autonomous)
graph_sp = requests.get(
    f"{GRAPH}/servicePrincipals?$filter=appId eq '00000003-0000-0000-c000-000000000000'",
    headers=headers,
).json()["value"][0]

user_read_all = next(r for r in graph_sp["appRoles"] if r["value"] == "User.Read.All")

requests.post(
    f"{GRAPH}/servicePrincipals/{agent_sp_id}/appRoleAssignments",
    headers=headers,
    json={
        "principalId": agent_sp_id,
        "resourceId": graph_sp["id"],
        "appRoleId": user_read_all["id"],
    },
).raise_for_status()
Delegated permissions (OBO)
from datetime import datetime, timedelta, timezone

expiry = (datetime.now(timezone.utc) + timedelta(days=3650)).strftime("%Y-%m-%dT%H:%M:%SZ")

requests.post(
    f"{GRAPH}/oauth2PermissionGrants",
    headers=headers,
    json={
        "clientId": agent_sp_id,
        "consentType": "AllPrincipals",
        "resourceId": graph_sp["id"],
        "scope": "User.Read Tasks.ReadWrite Mail.Send",
        "expiryTime": expiry,
    },
).raise_for_status()

Browser-based admin consent URLs do not work for Agent Identities — use oauth2PermissionGrants for programmatic delegated consent.

Cross-Tenant Agent Identities

Blueprints can be multi-tenant (signInAudience: AzureADMultipleOrgs). When exchanging tokens cross-tenant:

Step 1 of the parent token exchange MUST target the Agent Identity's home tenant, not the Blueprint's. Wrong tenant → AADSTS700211: No matching federated identity record found.

See references/runtime-token-exchange.md for full cross-tenant examples.

API Reference

Operation Method Endpoint
Create Blueprint POST /applications/microsoft.graph.agentIdentityBlueprint
Create BlueprintPrincipal POST /servicePrincipals/microsoft.graph.agentIdentityBlueprintPrincipal
Create Agent Identity POST /servicePrincipals/microsoft.graph.agentIdentity
Add FIC to Blueprint POST /applications/{id}/microsoft.graph.agentIdentityBlueprint/federatedIdentityCredentials
List Agent Identities GET /servicePrincipals/microsoft.graph.agentIdentity
Grant app permission POST /servicePrincipals/{id}/appRoleAssignments
Grant delegated permission POST /oauth2PermissionGrants
Delete Agent Identity DELETE /servicePrincipals/{id}
Delete Blueprint DELETE /applications/{id}

Base URL: https://graph.microsoft.com/v1.0.

Required Graph Permissions

Permission Purpose
AgentIdentityBlueprint.Create Create Blueprints
AgentIdentityBlueprint.ReadWrite.All Read/update Blueprints
AgentIdentityBlueprintPrincipal.Create Create BlueprintPrincipals
AgentIdentity.Create.All Create Agent Identities
AgentIdentity.ReadWrite.All Read/update Agent Identities
Application.ReadWrite.All Blueprint CRUD on application objects
AppRoleAssignment.ReadWrite.All Grant application permissions
DelegatedPermissionGrant.ReadWrite.All Grant delegated permissions

Grant admin consent (required for application permissions):

az ad app permission admin-consent --id <client-id>

After admin consent, tokens may not include new claims for 30–120 seconds — retry with exponential backoff.

Best Practices

  1. Always create BlueprintPrincipal after Blueprint — not auto-created.
  2. Use typed endpoints (/applications/microsoft.graph.agentIdentityBlueprint) instead of raw /applications with @odata.type.
  3. Credentials live on the Blueprint — Agent Identities can't hold secrets/certs (PropertyNotCompatibleWithAgentIdentity).
  4. Include OData-Version: 4.0 on every Graph request.
  5. Use Workload Identity Federation for production — client secrets only for local dev.
  6. Set identifierUris: ["api://{appId}"] on the Blueprint before OAuth2 scope resolution.
  7. Never use Azure CLI tokens for Agent Identity APIs — Directory.AccessAsUser.All causes hard 403.
  8. Use fmi_path with client_credentials — NOT RFC 8693 urn:ietf:params:oauth:grant-type:token-exchange (returns AADSTS82001).
  9. Always use /.default scope in both steps of the exchange — individual scopes fail.
  10. Step 1 targets the Agent Identity's home tenant in cross-tenant flows.
  11. Grant permissions per Agent Identity, not to the BlueprintPrincipal.
  12. Handle permission-propagation delays — retry 403s with 30–120s backoff after admin consent.
  13. Keep the Entra SDK for AgentID on localhost — never expose via LoadBalancer or Ingress.

Troubleshooting

Error Cause Fix
AADSTS82001 Used RFC 8693 token-exchange grant Use client_credentials with fmi_path
AADSTS700211 Step 1 parent token targeted wrong tenant Target Agent Identity's home tenant
AADSTS50013 OBO user token targets Graph, not Blueprint Use api://{blueprint_app_id}/access_as_user
AADSTS65001 Missing grant or used individual scopes Use /.default and verify oauth2PermissionGrants
403 Authorization_RequestDenied No grant on this Agent Identity Add via appRoleAssignments or oauth2PermissionGrants
PropertyNotCompatibleWithAgentIdentity Tried to add credential to Agent Identity SP Put credentials on the Blueprint
Agent Blueprint Principal does not exist BlueprintPrincipal not created Step 2 of the Core Workflow
AADSTS650051 on admin consent SP already exists from partial consent Grant directly via appRoleAssignments

References

File Contents
references/runtime-token-exchange.md Two-step fmi_path exchange: autonomous + OBO, cross-tenant
references/oauth2-token-flow.md MI + WIF (production) and client secret (local dev)
references/obo-blueprint-setup.md Configuring the Blueprint as an OAuth2 API for OBO
references/sdk-sidecar.md Microsoft Entra SDK for AgentID — architecture, configuration, endpoints
references/sdk-sidecar-deployment.md SDK code patterns (Python/TypeScript), Docker/Kubernetes manifests, security, troubleshooting
references/known-limitations.md Documented gaps organized by category
Resource URL
Agent ID Setup Guide https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-setup-instructions
AI-Guided Setup https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-ai-guided-setup
Microsoft Entra SDK for AgentID https://learn.microsoft.com/en-us/entra/msidweb/agent-id-sdk/overview
Microsoft.Identity.Web.AgentIdentities (.NET) https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web.AgentIdentities/README.AgentIdentities.md
1---
2name: entra-agent-id
3description: "Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmi_path, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmi_path token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry)."
4license: MIT
5metadata:
6 author: Microsoft
7 version: "1.1.1"
8---
9 
10# Microsoft Entra Agent ID
11 
12Create and manage OAuth 2.0-capable identities for AI agents using Microsoft Graph. Every agent instance gets a distinct identity, audit trail, and independently-scoped permission grants.
13 
14## Quick Reference
15 
16| Property | Value |
17|----------|-------|
18| Service | Microsoft Entra Agent ID |
19| API | Microsoft Graph (`https://graph.microsoft.com/v1.0`) |
20| Required role | Agent Identity Developer, Agent Identity Administrator, or Application Administrator |
21| Object model | Blueprint (application) → BlueprintPrincipal (SP) → Agent Identity (SP) |
22| Runtime exchange | Two-step `fmi_path` exchange (autonomous and OBO) |
23| .NET helper | `Microsoft.Identity.Web.AgentIdentities` |
24| Polyglot helper | Microsoft Entra SDK for AgentID (sidecar container) |
25 
26## When to Use This Skill
27 
28- Provisioning a new Agent Identity Blueprint and BlueprintPrincipal
29- Creating per-instance Agent Identities under a Blueprint
30- Configuring credentials (FIC, Managed Identity, or client secret) on the Blueprint
31- Implementing the two-step `fmi_path` runtime token exchange (autonomous or OBO)
32- Cross-tenant agent token flows
33- Deploying the Microsoft Entra SDK for AgentID sidecar for polyglot agents (Python, Node, Go, Java)
34- Granting per-Agent-Identity application (`appRoleAssignments`) or delegated (`oauth2PermissionGrants`) permissions
35- Diagnosing Agent ID errors such as `AADSTS82001`, `AADSTS700211`, or `PropertyNotCompatibleWithAgentIdentity`
36 
37## MCP Tools
38 
39| Tool | Use |
40|------|-----|
41| `mcp_azure_mcp_documentation` | Search Microsoft Learn for current Agent ID setup, Graph API shapes, and SDK configuration |
42 
43There is no dedicated Agent Identity MCP server today. This skill guides direct Microsoft Graph API calls (PowerShell or Python `requests`). Use `mcp_azure_mcp_documentation` to verify request bodies and endpoints against current docs before running.
44 
45## Before You Start
46 
47Use the `mcp_azure_mcp_documentation` tool to search Microsoft Learn for current Agent ID documentation:
48- "Microsoft Entra Agent ID setup instructions"
49- "Microsoft Entra SDK for AgentID"
50 
51Verify request bodies and endpoints against the installed SDK version — Graph API shapes evolve.
52 
53## Conceptual Model
54 
55```
56Agent Identity Blueprint (application) ← one per agent type/project
57 └── BlueprintPrincipal (service principal) ← MUST be created explicitly
58 ├── Agent Identity (SP): agent-1 ← one per agent instance
59 ├── Agent Identity (SP): agent-2
60 └── Agent Identity (SP): agent-3
61```
62 
63| Concept | Description |
64|---------|-------------|
65| **Blueprint** | Application object that defines a type/class of agent. Holds credentials (secret, certificate, federated identity). |
66| **BlueprintPrincipal** | Service principal for the Blueprint in the tenant. Not auto-created. |
67| **Agent Identity** | Service-principal-only identity for a single agent instance. Cannot hold its own credentials. |
68| **Sponsor** | A User (or Group, for Agent Identity) who is responsible for the identity. Required on creation. |
69 
70## Prerequisites
71 
72### Required Entra Roles
73 
74One of: **Agent Identity Developer**, **Agent Identity Administrator**, or **Application Administrator**.
75 
76### PowerShell (interactive setup)
77 
78```powershell
79# PowerShell 7+
80Install-Module Microsoft.Graph.Applications -Scope CurrentUser -Force
81```
82 
83### Python (programmatic provisioning)
84 
85```bash
86pip install azure-identity requests
87```
88 
89## Authentication
90 
91> **`DefaultAzureCredential` is not supported.** Azure CLI tokens carry `Directory.AccessAsUser.All`, which Agent Identity APIs hard-reject (403). Use a dedicated app registration with `client_credentials`, or `Connect-MgGraph` with explicit delegated scopes.
92 
93### PowerShell (delegated)
94 
95```powershell
96Connect-MgGraph -Scopes @(
97 "AgentIdentityBlueprint.Create",
98 "AgentIdentityBlueprint.ReadWrite.All",
99 "AgentIdentityBlueprintPrincipal.Create",
100 "AgentIdentity.Create.All",
101 "User.Read"
102)
103```
104 
105### Python (application)
106 
107```python
108import os, requests
109from azure.identity import ClientSecretCredential
110 
111credential = ClientSecretCredential(
112 tenant_id=os.environ["AZURE_TENANT_ID"],
113 client_id=os.environ["AZURE_CLIENT_ID"],
114 client_secret=os.environ["AZURE_CLIENT_SECRET"],
115)
116token = credential.get_token("https://graph.microsoft.com/.default")
117 
118GRAPH = "https://graph.microsoft.com/v1.0"
119headers = {
120 "Authorization": f"Bearer {token.token}",
121 "Content-Type": "application/json",
122 "OData-Version": "4.0",
123}
124```
125 
126## Core Workflow
127 
128### Step 1: Create Agent Identity Blueprint
129 
130Use the typed endpoint. Sponsors must be **Users** at Blueprint creation. This snippet assumes the `requests` client and `headers` dict from the Python authentication block above.
131 
132```python
133import subprocess
134import requests
135 
136user_id = subprocess.run(
137 ["az", "ad", "signed-in-user", "show", "--query", "id", "-o", "tsv"],
138 capture_output=True, text=True, check=True,
139).stdout.strip()
140 
141blueprint_body = {
142 "displayName": "My Agent Blueprint",
143 "[email protected]": [
144 f"https://graph.microsoft.com/v1.0/users/{user_id}"
145 ],
146}
147resp = requests.post(
148 f"{GRAPH}/applications/microsoft.graph.agentIdentityBlueprint",
149 headers=headers, json=blueprint_body,
150)
151resp.raise_for_status()
152 
153blueprint = resp.json()
154app_id = blueprint["appId"]
155blueprint_obj_id = blueprint["id"]
156```
157 
158### Step 2: Create BlueprintPrincipal
159 
160> Mandatory. Creating a Blueprint does NOT auto-create its service principal. Skipping this step produces:
161> `400: The Agent Blueprint Principal for the Agent Blueprint does not exist.`
162 
163```python
164sp_body = {"appId": app_id}
165resp = requests.post(
166 f"{GRAPH}/servicePrincipals/microsoft.graph.agentIdentityBlueprintPrincipal",
167 headers=headers, json=sp_body,
168)
169resp.raise_for_status()
170```
171 
172Make your provisioning scripts idempotent — always check for the BlueprintPrincipal even when the Blueprint already exists.
173 
174### Step 3: Create Agent Identities
175 
176Sponsors for an Agent Identity may be **Users or Groups**.
177 
178```python
179agent_body = {
180 "displayName": "my-agent-instance-1",
181 "agentIdentityBlueprintId": app_id,
182 "[email protected]": [
183 f"https://graph.microsoft.com/v1.0/users/{user_id}"
184 ],
185}
186resp = requests.post(
187 f"{GRAPH}/servicePrincipals/microsoft.graph.agentIdentity",
188 headers=headers, json=agent_body,
189)
190resp.raise_for_status()
191agent = resp.json()
192agent_sp_id = agent["id"]
193```
194 
195## Runtime Authentication
196 
197Agents authenticate at runtime using credentials configured on the **Blueprint** (not on the Agent Identity — Agent Identities can't hold credentials).
198 
199| Option | Use case | Credential on Blueprint |
200|--------|----------|------------------------|
201| **Managed Identity + WIF** | Production (Azure-hosted) | Federated Identity Credential |
202| **Client secret** | Local dev / testing | Password credential |
203| **Microsoft Entra SDK for AgentID** | Polyglot / 3P agents | Sidecar container acquires tokens over HTTP |
204 
205For the two-step `fmi_path` exchange (parent token → per-Agent-Identity Graph token) that gives each agent instance a distinct `sub` claim and audit trail, see [references/runtime-token-exchange.md](references/runtime-token-exchange.md).
206 
207For OBO (agent acting on behalf of a user), see [references/obo-blueprint-setup.md](references/obo-blueprint-setup.md).
208 
209For the containerized polyglot auth sidecar (Python, Node, Go, Java — no SDK embedding), see [references/sdk-sidecar.md](references/sdk-sidecar.md).
210 
211For MI+WIF and client-secret setup details, see [references/oauth2-token-flow.md](references/oauth2-token-flow.md).
212 
213### .NET quick path
214 
215For .NET services, use **`Microsoft.Identity.Web.AgentIdentities`** — it handles Federated Identity Credential management and the two-step exchange for you. See the package README at `github.com/AzureAD/microsoft-identity-web` under `src/Microsoft.Identity.Web.AgentIdentities/`.
216 
217## Granting Permissions (Per Agent Identity)
218 
219Agent Identities support both application permissions (autonomous) and delegated permissions (OBO). Grants are scoped **per Agent Identity**, not to the BlueprintPrincipal.
220 
221### Application permissions (autonomous)
222 
223```python
224graph_sp = requests.get(
225 f"{GRAPH}/servicePrincipals?$filter=appId eq '00000003-0000-0000-c000-000000000000'",
226 headers=headers,
227).json()["value"][0]
228 
229user_read_all = next(r for r in graph_sp["appRoles"] if r["value"] == "User.Read.All")
230 
231requests.post(
232 f"{GRAPH}/servicePrincipals/{agent_sp_id}/appRoleAssignments",
233 headers=headers,
234 json={
235 "principalId": agent_sp_id,
236 "resourceId": graph_sp["id"],
237 "appRoleId": user_read_all["id"],
238 },
239).raise_for_status()
240```
241 
242### Delegated permissions (OBO)
243 
244```python
245from datetime import datetime, timedelta, timezone
246 
247expiry = (datetime.now(timezone.utc) + timedelta(days=3650)).strftime("%Y-%m-%dT%H:%M:%SZ")
248 
249requests.post(
250 f"{GRAPH}/oauth2PermissionGrants",
251 headers=headers,
252 json={
253 "clientId": agent_sp_id,
254 "consentType": "AllPrincipals",
255 "resourceId": graph_sp["id"],
256 "scope": "User.Read Tasks.ReadWrite Mail.Send",
257 "expiryTime": expiry,
258 },
259).raise_for_status()
260```
261 
262Browser-based admin consent URLs do not work for Agent Identities — use `oauth2PermissionGrants` for programmatic delegated consent.
263 
264## Cross-Tenant Agent Identities
265 
266Blueprints can be multi-tenant (`signInAudience: AzureADMultipleOrgs`). When exchanging tokens cross-tenant:
267 
268> **Step 1 of the parent token exchange MUST target the Agent Identity's home tenant**, not the Blueprint's. Wrong tenant → `AADSTS700211: No matching federated identity record found`.
269 
270See [references/runtime-token-exchange.md](references/runtime-token-exchange.md) for full cross-tenant examples.
271 
272## API Reference
273 
274| Operation | Method | Endpoint |
275|-----------|--------|----------|
276| Create Blueprint | `POST` | `/applications/microsoft.graph.agentIdentityBlueprint` |
277| Create BlueprintPrincipal | `POST` | `/servicePrincipals/microsoft.graph.agentIdentityBlueprintPrincipal` |
278| Create Agent Identity | `POST` | `/servicePrincipals/microsoft.graph.agentIdentity` |
279| Add FIC to Blueprint | `POST` | `/applications/{id}/microsoft.graph.agentIdentityBlueprint/federatedIdentityCredentials` |
280| List Agent Identities | `GET` | `/servicePrincipals/microsoft.graph.agentIdentity` |
281| Grant app permission | `POST` | `/servicePrincipals/{id}/appRoleAssignments` |
282| Grant delegated permission | `POST` | `/oauth2PermissionGrants` |
283| Delete Agent Identity | `DELETE` | `/servicePrincipals/{id}` |
284| Delete Blueprint | `DELETE` | `/applications/{id}` |
285 
286Base URL: `https://graph.microsoft.com/v1.0`.
287 
288## Required Graph Permissions
289 
290| Permission | Purpose |
291|-----------|---------|
292| `AgentIdentityBlueprint.Create` | Create Blueprints |
293| `AgentIdentityBlueprint.ReadWrite.All` | Read/update Blueprints |
294| `AgentIdentityBlueprintPrincipal.Create` | Create BlueprintPrincipals |
295| `AgentIdentity.Create.All` | Create Agent Identities |
296| `AgentIdentity.ReadWrite.All` | Read/update Agent Identities |
297| `Application.ReadWrite.All` | Blueprint CRUD on application objects |
298| `AppRoleAssignment.ReadWrite.All` | Grant application permissions |
299| `DelegatedPermissionGrant.ReadWrite.All` | Grant delegated permissions |
300 
301Grant admin consent (required for application permissions):
302 
303```bash
304az ad app permission admin-consent --id <client-id>
305```
306 
307After admin consent, tokens may not include new claims for 30–120 seconds — retry with exponential backoff.
308 
309## Best Practices
310 
3111. **Always create BlueprintPrincipal after Blueprint** — not auto-created.
3122. **Use typed endpoints** (`/applications/microsoft.graph.agentIdentityBlueprint`) instead of raw `/applications` with `@odata.type`.
3133. **Credentials live on the Blueprint** — Agent Identities can't hold secrets/certs (`PropertyNotCompatibleWithAgentIdentity`).
3144. **Include `OData-Version: 4.0`** on every Graph request.
3155. **Use Workload Identity Federation for production** — client secrets only for local dev.
3166. **Set `identifierUris: ["api://{appId}"]` on the Blueprint** before OAuth2 scope resolution.
3177. **Never use Azure CLI tokens** for Agent Identity APIs — `Directory.AccessAsUser.All` causes hard 403.
3188. **Use `fmi_path`** with `client_credentials` — NOT RFC 8693 `urn:ietf:params:oauth:grant-type:token-exchange` (returns `AADSTS82001`).
3199. **Always use `/.default` scope** in both steps of the exchange — individual scopes fail.
32010. **Step 1 targets the Agent Identity's home tenant** in cross-tenant flows.
32111. **Grant permissions per Agent Identity**, not to the BlueprintPrincipal.
32212. **Handle permission-propagation delays** — retry 403s with 30–120s backoff after admin consent.
32313. **Keep the Entra SDK for AgentID on localhost** — never expose via LoadBalancer or Ingress.
324 
325## Troubleshooting
326 
327| Error | Cause | Fix |
328|-------|-------|-----|
329| `AADSTS82001` | Used RFC 8693 token-exchange grant | Use `client_credentials` with `fmi_path` |
330| `AADSTS700211` | Step 1 parent token targeted wrong tenant | Target Agent Identity's home tenant |
331| `AADSTS50013` | OBO user token targets Graph, not Blueprint | Use `api://{blueprint_app_id}/access_as_user` |
332| `AADSTS65001` | Missing grant or used individual scopes | Use `/.default` and verify `oauth2PermissionGrants` |
333| `403 Authorization_RequestDenied` | No grant on this Agent Identity | Add via `appRoleAssignments` or `oauth2PermissionGrants` |
334| `PropertyNotCompatibleWithAgentIdentity` | Tried to add credential to Agent Identity SP | Put credentials on the Blueprint |
335| `Agent Blueprint Principal does not exist` | BlueprintPrincipal not created | Step 2 of the Core Workflow |
336| `AADSTS650051` on admin consent | SP already exists from partial consent | Grant directly via `appRoleAssignments` |
337 
338## References
339 
340| File | Contents |
341|------|----------|
342| [references/runtime-token-exchange.md](references/runtime-token-exchange.md) | Two-step `fmi_path` exchange: autonomous + OBO, cross-tenant |
343| [references/oauth2-token-flow.md](references/oauth2-token-flow.md) | MI + WIF (production) and client secret (local dev) |
344| [references/obo-blueprint-setup.md](references/obo-blueprint-setup.md) | Configuring the Blueprint as an OAuth2 API for OBO |
345| [references/sdk-sidecar.md](references/sdk-sidecar.md) | Microsoft Entra SDK for AgentID — architecture, configuration, endpoints |
346| [references/sdk-sidecar-deployment.md](references/sdk-sidecar-deployment.md) | SDK code patterns (Python/TypeScript), Docker/Kubernetes manifests, security, troubleshooting |
347| [references/known-limitations.md](references/known-limitations.md) | Documented gaps organized by category |
348 
349### External Links
350 
351| Resource | URL |
352|----------|-----|
353| Agent ID Setup Guide | https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-setup-instructions |
354| AI-Guided Setup | https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-ai-guided-setup |
355| Microsoft Entra SDK for AgentID | https://learn.microsoft.com/en-us/entra/msidweb/agent-id-sdk/overview |
356| Microsoft.Identity.Web.AgentIdentities (.NET) | https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web.AgentIdentities/README.AgentIdentities.md |
357 

Discussion

Alternatives

API and interface designGuides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.Coding · MITContext7Pulls up-to-date, version-specific library docs and code examples into the prompt so the AI stops inventing old APIs.Coding · MITContext7 Documentation LookupFetch up-to-date documentation and code examples for any library, framework, SDK, CLI tool, or cloud service. Use whenever the user asks about a specific library — even well-known ones like React, Next.js, Prisma, Express, Tailwind, Django, or Spring Boot — because training data may not reflect recent API changes or version updates. Always use for: API syntax questions, configuration options, version migration issues, "how do I" questions mentioning a library name, debugging that involves library-specific behavior, setup instructions, and CLI tool usage. Use even when you think you know the answer. Do not rely on training data for API details, signatures, or configuration options — they are frequently out of date. Prefer this over web search for library documentation.Coding · MITAdaptyv Bio Foundry APIHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.Science · MIT