Microsoft Graph API - User Presence Endpoints

Microsoft Graph is a REST web API that empowers you to access Microsoft Cloud service resources. After we register our app and get authentication tokens for a user or service, we can make requests to the Microsoft Graph API to access data on the following Microsoft 365 services.
  1. Office 365 services: Delve, Excel, Microsoft Bookings, Microsoft Teams, OneDrive, OneNote, Outlook/Exchange, Planner, and SharePoint
  2. Enterprise Mobility and Security services: Advanced Threat Analytics, Advanced Threat Protection, Azure Active Directory, Identity Manager, and Intune
  3. Windows 10 services: activities, devices, notifications
  4. Dynamics 365 Business Central
In this article I am going to explain about the new presence API endpoints introduced by Microsoft Graph API team. We can use these endpoints to read availability about the current logged in user or any other users, as long as we have proper permissions to access that user/s.  (Possible values are Available, AvailableIdle, Away, BeRightBack, Busy, BusyIdle, DoNotDisturb, Offline, PresenceUnknown) and activity information (possible values are Available, Away, BeRightBack, Busy,  DoNotDisturb, InACall, InAConferenceCall, Inactive, InAMeeting, Offline, OffWork, OutOfOffice, PresenceUnknown, Presenting, UrgentInterruptionsOnly.) 
 
In order to access the presence API, we will need to configure Presence.Read and Presence.Read.All permission scopes in Azure AD Application. Unfortunately, application permission type is not currently supported for these endpoints but feel free to vote for this idea in the user voice site.
 
Disclaimer: Presence API endpoints are currently under the beta version. That means these endpoints are subject to change and not recommended to use in production.
 
Use case 1 – Get current user presence details
 
Method GET
Endpoint https://graph.microsoft.com/beta/me/presence
Header Authorization Bearer {token}
Request https://graph.microsoft.com/beta/me/presence
Response “id”: “44285e03-f57e-42da-9069-724602c31f6b”, “availability”: “DoNotDisturb”, “activity”: “Presenting”
 
Use case 2 – Get other user’s presence details
 
Method GET
Endpoint https://graph.microsoft.com/beta/users/{userid}/presence
Header Authorization Bearer {token}
Request https://graph.microsoft.com/beta/users/55285e03-f57e-42da-9069-724602c31f6b/presence
Response “id”: “55285e03-f57e-42da-9069-724602c31f6b”, “availability”: “DoNotDisturb”, “activity”: “Presenting”
 
Use case 3 – Get more than one user presence details
 
Method POST
Endpoint https://graph.microsoft.com/beta/communications/getPresencesByUserId
Header Authorization: Bearer {token} Content-Type: application/json
Request https://graph.microsoft.com/beta/communications/getPresencesByUserId
Body { “ids”: [“33285e03-f57e-42da-9069-724602c31f6b“, “55285e03-f57e-42da-9069-724602c31f6b“] }
Response { “value”: [{ “id”: “33285e03-f57e-42da-9069-724602c31f6b“, “availability”: “Busy”, “activity”: “InAMeeting” }, { “id”: “55285e03-f57e-42da-9069-724602c31f6b“, “availability”: ” DoNotDisturb “, “activity”: ” Presenting ” } ] }
 
Hope you found this article helpful! Let me know if I might have missed anything or could do anything  better.