All skills
github avatar

/entra-agent-user

@cc2d5ac official
by githubgithub/awesome-copilot40k stars
5,040

Create Agent Users in Microsoft Entra ID from Agent Identities, enabling AI agents to act as digital workers with user identity capabilities in Microsoft 365 and Azure environments.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/entra-agent-user

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ50 tokens always: the name and description. β‰ˆ2.3k when used: this file.

SKILL: Creating Agent Users in Microsoft Entra Agent ID

Overview

An agent user is a specialized user identity in Microsoft Entra ID that enables AI agents to act as digital workers. It allows agents to access APIs and services that strictly require user identities (e.g., Exchange mailboxes, Teams, org charts), while maintaining appropriate security boundaries.

Agent users receive tokens with idtyp=user, unlike regular agent identities which receive idtyp=app.


Prerequisites

  • A Microsoft Entra tenant with Agent ID capabilities
  • An agent identity (service principal of type ServiceIdentity) created from an agent identity blueprint
  • One of the following permissions:
    • AgentIdUser.ReadWrite.IdentityParentedBy (least privileged)
    • AgentIdUser.ReadWrite.All
    • User.ReadWrite.All
  • The caller must have at minimum the Agent ID Administrator role (in delegated scenarios)

Important: The identityParentId must reference a true agent identity (created via an agent identity blueprint), NOT a regular application service principal. You can verify by checking that the service principal has @odata.type: #microsoft.graph.agentIdentity and servicePrincipalType: ServiceIdentity.


Architecture

Agent Identity Blueprint (application template)
    β”‚
    β”œβ”€β”€ Agent Identity (service principal - ServiceIdentity)
    β”‚       β”‚
    β”‚       └── Agent User (user - agentUser) ← 1:1 relationship
    β”‚
    └── Agent Identity Blueprint Principal (service principal in tenant)
Component Type Token Claim Purpose
Agent Identity Service Principal idtyp=app Backend/API operations
Agent User User (agentUser) idtyp=user Act as a digital worker in M365

Step 1: Verify the Agent Identity Exists

Before creating an agent user, confirm the agent identity is a proper agentIdentity type:

GET https://graph.microsoft.com/beta/servicePrincipals/{agent-identity-id}
Authorization: Bearer <token>

Verify the response contains:

{
  "@odata.type": "#microsoft.graph.agentIdentity",
  "servicePrincipalType": "ServiceIdentity",
  "agentIdentityBlueprintId": "<blueprint-id>"
}

PowerShell

Connect-MgGraph -Scopes "Application.Read.All" -TenantId "<tenant>" -UseDeviceCode -NoWelcome
Invoke-MgGraphRequest -Method GET `
  -Uri "https://graph.microsoft.com/beta/servicePrincipals/<agent-identity-id>" | ConvertTo-Json -Depth 3

Common mistake: Using an app registration's appId or a regular application service principal's id will fail. Only agent identities created from blueprints work.


Step 2: Create the Agent User

HTTP Request

POST https://graph.microsoft.com/beta/users/microsoft.graph.agentUser
Content-Type: application/json
Authorization: Bearer <token>

{
  "accountEnabled": true,
  "displayName": "My Agent User",
  "mailNickname": "my-agent-user",
  "userPrincipalName": "my-agent-user@yourtenant.onmicrosoft.com",
  "identityParentId": "<agent-identity-object-id>"
}

Required Properties

Property Type Description
accountEnabled Boolean true to enable the account
displayName String Human-friendly name
mailNickname String Mail alias (no spaces/special chars)
userPrincipalName String UPN β€” must be unique in the tenant (alias@verified-domain)
identityParentId String Object ID of the parent agent identity

PowerShell

Connect-MgGraph -Scopes "User.ReadWrite.All" -TenantId "<tenant>" -UseDeviceCode -NoWelcome

$body = @{
  accountEnabled    = $true
  displayName       = "My Agent User"
  mailNickname      = "my-agent-user"
  userPrincipalName = "my-agent-user@yourtenant.onmicrosoft.com"
  identityParentId  = "<agent-identity-object-id>"
} | ConvertTo-Json

Invoke-MgGraphRequest -Method POST `
  -Uri "https://graph.microsoft.com/beta/users/microsoft.graph.agentUser" `
  -Body $body -ContentType "application/json" | ConvertTo-Json -Depth 3

Key Notes

  • No password β€” agent users cannot have passwords. They authenticate via their parent agent identity's credentials.
  • 1:1 relationship β€” each agent identity can have at most one agent user. Attempting to create a second returns 400 Bad Request.
  • The userPrincipalName must be unique. Don't reuse an existing user's UPN.

Step 3: Assign a Manager (Optional)

Assigning a manager allows the agent user to appear in org charts (e.g., Teams).

PUT https://graph.microsoft.com/beta/users/{agent-user-id}/manager/$ref
Content-Type: application/json
Authorization: Bearer <token>

{
  "@odata.id": "https://graph.microsoft.com/beta/users/{manager-user-id}"
}

PowerShell

$managerBody = '{"@odata.id":"https://graph.microsoft.com/beta/users/<manager-user-id>"}'
Invoke-MgGraphRequest -Method PUT `
  -Uri "https://graph.microsoft.com/beta/users/<agent-user-id>/manager/`$ref" `
  -Body $managerBody -ContentType "application/json"

Step 4: Set Usage Location and Assign Licenses (Optional)

A license is needed for the agent user to have a mailbox, Teams presence, etc. Usage location must be set first.

Set Usage Location

PATCH https://graph.microsoft.com/beta/users/{agent-user-id}
Content-Type: application/json
Authorization: Bearer <token>

{
  "usageLocation": "US"
}

List Available Licenses

GET https://graph.microsoft.com/beta/subscribedSkus?$select=skuPartNumber,skuId,consumedUnits,prepaidUnits
Authorization: Bearer <token>

Requires Organization.Read.All permission.

Assign a License

POST https://graph.microsoft.com/beta/users/{agent-user-id}/assignLicense
Content-Type: application/json
Authorization: Bearer <token>

{
  "addLicenses": [
    { "skuId": "<sku-id>" }
  ],
  "removeLicenses": []
}

PowerShell (all in one)

Connect-MgGraph -Scopes "User.ReadWrite.All","Organization.Read.All" -TenantId "<tenant>" -NoWelcome

# Set usage location
Invoke-MgGraphRequest -Method PATCH `
  -Uri "https://graph.microsoft.com/beta/users/<agent-user-id>" `
  -Body '{"usageLocation":"US"}' -ContentType "application/json"

# Assign license
$licenseBody = '{"addLicenses":[{"skuId":"<sku-id>"}],"removeLicenses":[]}'
Invoke-MgGraphRequest -Method POST `
  -Uri "https://graph.microsoft.com/beta/users/<agent-user-id>/assignLicense" `
  -Body $licenseBody -ContentType "application/json"

Tip: You can also assign licenses via the Entra admin center under Identity β†’ Users β†’ All users β†’ select the agent user β†’ Licenses and apps.


Provisioning Times

Service Estimated Time
Exchange mailbox 5–30 minutes
Teams availability 15 min – 24 hours
Org chart / People search Up to 24–48 hours
SharePoint / OneDrive 5–30 minutes
Global Address List Up to 24 hours

Agent User Capabilities

  • βœ… Added to Microsoft Entra groups (including dynamic groups)
  • βœ… Access user-only APIs (idtyp=user tokens)
  • βœ… Own a mailbox, calendar, and contacts
  • βœ… Participate in Teams chats and channels
  • βœ… Appear in org charts and People search
  • βœ… Added to administrative units
  • βœ… Assigned licenses

Agent User Security Constraints

  • ❌ Cannot have passwords, passkeys, or interactive sign-in
  • ❌ Cannot be assigned privileged admin roles
  • ❌ Cannot be added to role-assignable groups
  • ❌ Permissions similar to guest users by default
  • ❌ Custom role assignment not available

Troubleshooting

Error Cause Fix
Agent user IdentityParent does not exist identityParentId points to a non-existent or non-agent-identity object Verify the ID is an agentIdentity service principal, not a regular app
400 Bad Request (identityParentId already linked) The agent identity already has an agent user Each agent identity supports only one agent user
409 Conflict on UPN The userPrincipalName is already taken Use a unique UPN
License assignment fails Usage location not set Set usageLocation before assigning licenses

References

Source: SKILL.md on GitHub

1 warning16d5 checks Β· Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides standard educational content and examples for managing Microsoft Entra ID Agent Users using Microsoft Graph API requests and PowerShell snippets. It includes no executable code or risk indicators.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW Β· No issues

  • Runlayer7mo

    1/1 file flagged

  • ZeroLeaks5mo

    Score: 93/100 Β· 2 sections analyzed

Signed by skilld at cc2d5ac. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 18 hours ago.

Activeupdated 7 months ago
  • entra
  • agent-id
  • microsoft-graph
  • identity
  • user-provisioning
  • microsoft-365
  • azure
  • powershell

README badge

README badge for github/awesome-copilot/entra-agent-user

Creates agent users in Microsoft Entra ID by linking them to agent identities, enabling AI agents to authenticate with user-level tokens (idtyp=user) and access user-restricted APIs like Exchange mailboxes, Teams, and org charts. Requires an existing agent identity created from a blueprint and appropriate Entra permissions.

Generated from the current SKILL.md.

What is the difference between an agent identity and an agent user?
An agent identity is a service principal that receives `idtyp=app` tokens for backend/API operations. An agent user is a user identity parented by an agent identity that receives `idtyp=user` tokens, enabling access to user-only APIs like Exchange mailboxes, Teams, and org charts.
Can I create multiple agent users from a single agent identity?
No. Each agent identity supports at most one agent user. A 1:1 relationship is enforced; attempting to create a second returns a 400 Bad Request error.
What permissions do I need to create an agent user?
You need one of: `AgentIdUser.ReadWrite.IdentityParentedBy` (least privileged), `AgentIdUser.ReadWrite.All`, or `User.ReadWrite.All`, plus the Agent ID Administrator role in delegated scenarios.
Can agent users sign in interactively or use passwords?
No. Agent users have no passwords, passkeys, or interactive sign-in capability. They authenticate via their parent agent identity's credentials.
How long does it take for mailbox and Teams access to be available?
Exchange mailboxes and SharePoint/OneDrive provisioning take 5–30 minutes. Teams availability takes 15 minutes to 24 hours. Org chart and People search indexing can take up to 24–48 hours.

Generated from the current SKILL.md. These answers refresh after source changes.