Namespace: microsoft.graph
Returns the user or organizational contact assigned as the user's manager. Optionally, you can expand the manager's chain up to the root node.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
User.Read.All |
Directory.Read.All, Directory.ReadWrite.All, User.ReadWrite.All |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Not supported. |
Not supported. |
Important
When an application queries a relationship that returns a directoryObject type collection, if it doesn't have permission to read a certain resource type, members of that type are returned but with limited information. For example, only the @odata.type property for the object type and the id is returned, while other properties are indicated as null
. With this behavior, applications can request the least privileged permissions they need, rather than rely on the set of Directory.* permissions. For details, see Limited information returned for inaccessible member objects.
HTTP request
Get the manager:
GET /me/manager
GET /users/{id | userPrincipalName}/manager
Note
Calling the /me
endpoint requires a signed-in user and therefore a delegated permission. Application permissions aren't supported when using the /me
endpoint.
Get the management chain:
GET /users?$expand=manager
GET /users/{id | userPrincipalName}/?$expand=manager($levels=n)
Optional query parameters
This method supports the $select
and $expand
OData query parameters to help customize the response. When using the $expand
query parameter:
- The
n
value of $levels
can be max
(to return all managers) or a number between 1 and 1000.
- When the
$levels
parameter is not specified, only the immediate manager is returned.
- You can specify
$select
inside $expand
to select the individual manager's properties: $expand=manager($levels=max;$select=id,displayName)
.
$levels
parameter is only supported on a single user (/users/{id}
or me
endpoints) and not on the entire list of users.
- Use of
$levels
requires the ConsistencyLevel header set to eventual
. For more information about the use of ConsistencyLevel, see Advanced query capabilities on directory objects.
Header |
Value |
Authorization |
Bearer {token}. Required. Learn more about authentication and authorization. |
ConsistencyLevel |
eventual. Required when the request includes the $levels=n in the $expand query parameter. |
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 200 OK
response code and a user object in the response body. If the user isn't assigned a manager, this method returns a 404 Not Found
error code.
Examples
Example 1: Get manager
The following example shows a request to get the manager.
Request
GET https://graph.microsoft.com/v1.0/users/{id|userPrincipalName}/manager
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].Manager.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
manager, err := graphClient.Users().ByUserId("user-id").Manager().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DirectoryObject result = graphClient.users().byUserId("{user-id}").manager().get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let directoryObject = await client.api('/users/{id|userPrincipalName}/manager')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->users()->byUserId('user-id')->manager()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.users.by_user_id('user-id').manager.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "7d54cb02-aaa3-4016-9f9c-a4b49422dd9b",
"displayName": "Sara Davis",
"jobTitle": "Finance VP",
"mail": "[email protected]",
"userPrincipalName": "[email protected]"
}
Example 2: Get manager chain up to the root level
The following example shows a request to get the manager chain up to the root level.
Request
GET https://graph.microsoft.com/v1.0/me?$expand=manager($levels=max;$select=id,displayName)&$select=id,displayName
ConsistencyLevel: eventual
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Expand = new string []{ "manager($levels=max;$select=id,displayName)" };
requestConfiguration.QueryParameters.Select = new string []{ "id","displayName" };
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc users get --user-id {user-id} --select "id,displayName" --expand "manager(\$levels=max;\$select=id,displayName)" --consistency-level "eventual"
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("ConsistencyLevel", "eventual")
requestParameters := &graphusers.MeRequestBuilderGetQueryParameters{
Expand: [] string {"manager($levels=max;$select=id,displayName)"},
Select: [] string {"id","displayName"},
}
configuration := &graphusers.MeRequestBuilderGetRequestConfiguration{
Headers: headers,
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
me, err := graphClient.Me().Get(context.Background(), configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
User result = graphClient.me().get(requestConfiguration -> {
requestConfiguration.queryParameters.expand = new String []{"manager($levels=max;$select=id,displayName)"};
requestConfiguration.queryParameters.select = new String []{"id", "displayName"};
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let user = await client.api('/me')
.header('ConsistencyLevel','eventual')
.expand('manager($levels=max;$select=id,displayName)')
.select('id,displayName')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Me\MeRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new UserItemRequestBuilderGetRequestConfiguration();
$headers = [
'ConsistencyLevel' => 'eventual',
];
$requestConfiguration->headers = $headers;
$queryParameters = UserItemRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->expand = ["manager(\$levels=max;\$select=id,displayName)"];
$queryParameters->select = ["id","displayName"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->me()->get($requestConfiguration)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Users
# A UPN can also be used as -UserId.
Get-MgUser -UserId $userId -ExpandProperty "manager(`$levels=max;`$select=id,displayName)" -Property "id,displayName" -ConsistencyLevel eventual
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.me.me_request_builder import MeRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = MeRequestBuilder.MeRequestBuilderGetQueryParameters(
expand = ["manager($levels=max;$select=id,displayName)"],
select = ["id","displayName"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.me.get(request_configuration = request_configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response. Transitive managers are displayed hierarchically.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "a97733ce-92a4-4e7e-8d45-8e1f3e6a69d8",
"displayName": "Individual Contributor",
"manager": {
"id": "7d54cb02-aaa3-4016-9f9c-a4b49422dd9b",
"displayName": "Alex Wilber",
"manager": {
"id": "343a3f95-377c-47a9-b697-480487bfcdf7",
"displayName": "Bianca Pisani",
"manager": {
"id": "8e07b731-5ba7-4081-b482-15e6eca35c45",
"displayName": "Patti Fernandez"
}
}
}
}