presence: setStatusMessage

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Set a presence status message for a user. An optional expiration date and time can be supplied.

Permissions

The following permission is required to call the API. To learn more, including how to choose permissions, see Permissions.

Permission type Permissions (from least to most privileged)
Delegated (work or school account) Presence.ReadWrite
Delegated (personal Microsoft account) Not supported.
Application Presence.ReadWrite.All

HTTP Request

POST /users/{userId}/presence/setStatusMessage

Request headers

Name Description
Authorization Bearer {token}. Required.
Content-Type application/json. Required.

Request body

In the request body, provide a JSON object with the following parameters.

Parameter Type Description
statusMessage microsoft.graph.presenceStatusMessage It can be set to display the presence status message of a user.

Response

If successful, this method returns a 200 OK response code.

Examples

Example 1: Set status message with expiry date

The following request sets the presence status message as "Hey I'm currently in a meeting." for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3, with the expiration on 2022-10-18 at 17:05:33.2079781 Pacific Standard Time.

Request

POST https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setStatusMessage
Content-Type: application/json

{
  "statusMessage": {
    "message": {
        "content": "Hey I'm currently in a meeting.",
        "contentType": "text"
    },
    "expiryDateTime": {
        "dateTime": "2022-10-18T17:05:33.2079781",
        "timeZone": "Pacific Standard Time"
    }
  }
}

Response

HTTP/1.1 200 OK

Example 2: Set status message of another user

The following request sets the presence status message as "Hey I'm currently in a meeting." for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3. Then presence for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3 is obtained on behalf of other user via a getPresence request.

Request

POST https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence/setStatusMessage
Content-Type: application/json

{
  "statusMessage": {
    "message": {
      "content": "Hey I am available now",
      "contentType": "text"
    }
  }
}

Response

HTTP/1.1 200 OK

Example 3: Get another user presence

This request should be executed on behalf of another user.

Request

GET https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence

Response

Since this presence request does not qualify as a self presence request, statusMessage.expiryDateTime and statusMessage.publishedDateTime properties are not included in the response body.

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "fa8bf3dc-eca7-46b7-bad1-db199b62afc3",
  "availability": "Available",
  "activity": "Available",
  "outOfOfficeSettings": {
    "message": null,
    "isOutOfOffice": false
  },
  "statusMessage": {
    "message": {
      "content": "Hey I am available now",
      "contentType": "text"
    }
  }
}