| title | presence: setPresence |
|---|---|
| description | Set the presence information for a user's application presence session. |
| author | jsandoval-msft |
| ms.localizationpriority | medium |
| doc_type | apiPageType |
| ms.subservice | cloud-communications |
| ms.date | 04/04/2024 |
Namespace: microsoft.graph
Set the state of a user's presence session as an application.
For more information about presence sessions, states permutations, and timeouts, see Manage presence state using the Microsoft Graph API.
[!INCLUDE national-cloud-support]
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.
[!INCLUDE permissions-table]
POST /users/{id}/presence/setPresence| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
| Content-Type | application/json. Required. |
In the request body, provide a JSON object with the following parameters.
| Parameter | Type | Description |
|---|---|---|
| sessionId | string | The ID of the application's presence session. |
| availability | string | The base presence information. |
| activity | string | The supplemental information to availability. |
| expirationDuration | duration | The expiration of the app presence session. The value is represented in ISO 8601 format for durations.If not provided, a default expiration of 5 minutes is applied. The valid duration range is from 5 to 240 minutes (PT5M to PT4H). |
Important
Provide the ID of the application as sessionId in the request.
Supported combinations of availability and activity are:
| availability | activity | Description |
|---|---|---|
| Available | Available | Updates the presence session as Available. |
| Busy | InACall | Updates the presence session as Busy, InACall. |
| Busy | InAConferenceCall | Updates the presence session as Busy, InAConferenceCall. |
| Away | Away | Updates the presence session as Away. |
| DoNotDisturb | Presenting | Updates the presence session as DoNotDisturb, Presenting. |
If successful, this method returns a 200 OK response code.
The following request shows the application with ID 22553876-f5ab-4529-bffb-cfe50aa89f87 that sets its presence session for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3.
POST https://graph.microsoft.com/v1.0/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setPresence
Content-Type: application/json
{
"sessionId": "22553876-f5ab-4529-bffb-cfe50aa89f87",
"availability": "Available",
"activity": "Available",
"expirationDuration": "PT1H"
}
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
HTTP/1.1 200 OK