Get presence
Article
06/22/2022
4 minutes to read
5 contributors
In this article
Namespace: microsoft.graph
Get a user's presence information.
Permissions
One of the following permissions is required to call these APIs. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Presence.Read, Presence.Read.All
Delegated (personal Microsoft account)
Not Supported.
Application
Not Supported.
Note: The maximum request rate for this API is 1500 API requests in a 30 second period, per application per tenant.
HTTP Requests
GET /me/presence
GET /users/{id}/presence
GET /communications/presences
Name
Description
Authorization
Bearer {token}. Required.
Request body
Do not supply a request body for this method.
Response
If successful, this method returns a 200 OK
response code and a presence object in the response body.
Examples
The following example shows how to get your own presence information. This operation requires the Presence.Read permission.
Request
GET https://graph.microsoft.com/v1.0/me/presence
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var presence = await graphClient.Me.Presence
.Request()
.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/presence"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphPresence *presence = [[MSGraphPresence alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Presence presence = graphClient.me().presence()
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.Me().Presence().Get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1574
{
"id": "fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
"availability": "Available",
"activity": "Available"
}
The following example shows how to get the presence information for another user. This operation requires the Presence.Read.All permission.
Request
GET https://graph.microsoft.com/v1.0/users/66825e03-7ef5-42da-9069-724602c31f6b/presence
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var presence = await graphClient.Users["{user-id}"].Presence
.Request()
.GetAsync();
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 presence = await client.api('/users/66825e03-7ef5-42da-9069-724602c31f6b/presence')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/users/66825e03-7ef5-42da-9069-724602c31f6b/presence"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphPresence *presence = [[MSGraphPresence alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Presence presence = graphClient.users("66825e03-7ef5-42da-9069-724602c31f6b").presence()
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
userId := "user-id"
result, err := graphClient.UsersById(&userId).Presence().Get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1574
{
"id": "66825e03-7ef5-42da-9069-724602c31f6b",
"availability": "DoNotDisturb",
"activity": "Presenting"
}
The following example shows how to get the presence information for another user. This operation requires the Presence.Read.All permission.
Request
GET https://graph.microsoft.com/v1.0/communications/presences/dc74d9bb-6afe-433d-8eaa-e39d80d3a647
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var presence = await graphClient.Communications.Presences["{presence-id}"]
.Request()
.GetAsync();
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 presence = await client.api('/communications/presences/dc74d9bb-6afe-433d-8eaa-e39d80d3a647')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/communications/presences/dc74d9bb-6afe-433d-8eaa-e39d80d3a647"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphPresence *presence = [[MSGraphPresence alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Presence presence = graphClient.communications().presences("dc74d9bb-6afe-433d-8eaa-e39d80d3a647")
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
presenceId := "presence-id"
result, err := graphClient.Communications().PresencesById(&presenceId).Get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 200 OK
{
"value": [
{
"id": "dc74d9bb-6afe-433d-8eaa-e39d80d3a647",
"availability": "Away",
"activity": "BeRightBack"
}
]
}