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.
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.
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.
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"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.Presence.SetStatusMessage;
using Microsoft.Graph.Beta.Models;
var requestBody = new SetStatusMessagePostRequestBody
{
StatusMessage = new PresenceStatusMessage
{
Message = new ItemBody
{
Content = "Hey I'm currently in a meeting.",
ContentType = BodyType.Text,
},
ExpiryDateTime = new DateTimeTimeZone
{
DateTime = "2022-10-18T17:05:33.2079781",
TimeZone = "Pacific Standard Time",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Users["{user-id}"].Presence.SetStatusMessage.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
mgc-beta users presence set-status-message post --user-id {user-id} --body '{\
"statusMessage": {\
"message": {\
"content": "Hey I'm currently in a meeting.",\
"contentType": "text"\
},\
"expiryDateTime": {\
"dateTime": "2022-10-18T17:05:33.2079781",\
"timeZone": "Pacific Standard Time"\
}\
}\
}\
'
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewSetStatusMessagePostRequestBody()
statusMessage := graphmodels.NewPresenceStatusMessage()
message := graphmodels.NewItemBody()
content := "Hey I'm currently in a meeting."
message.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
message.SetContentType(&contentType)
statusMessage.SetMessage(message)
expiryDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2022-10-18T17:05:33.2079781"
expiryDateTime.SetDateTime(&dateTime)
timeZone := "Pacific Standard Time"
expiryDateTime.SetTimeZone(&timeZone)
statusMessage.SetExpiryDateTime(expiryDateTime)
requestBody.SetStatusMessage(statusMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Users().ByUserId("user-id").Presence().SetStatusMessage().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody setStatusMessagePostRequestBody = new com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody();
PresenceStatusMessage statusMessage = new PresenceStatusMessage();
ItemBody message = new ItemBody();
message.setContent("Hey I'm currently in a meeting.");
message.setContentType(BodyType.Text);
statusMessage.setMessage(message);
DateTimeTimeZone expiryDateTime = new DateTimeTimeZone();
expiryDateTime.setDateTime("2022-10-18T17:05:33.2079781");
expiryDateTime.setTimeZone("Pacific Standard Time");
statusMessage.setExpiryDateTime(expiryDateTime);
setStatusMessagePostRequestBody.setStatusMessage(statusMessage);
graphClient.users().byUserId("{user-id}").presence().setStatusMessage().post(setStatusMessagePostRequestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Presence\SetStatusMessage\SetStatusMessagePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PresenceStatusMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetStatusMessagePostRequestBody();
$statusMessage = new PresenceStatusMessage();
$statusMessageMessage = new ItemBody();
$statusMessageMessage->setContent('Hey I\'m currently in a meeting.');
$statusMessageMessage->setContentType(new BodyType('text'));
$statusMessage->setMessage($statusMessageMessage);
$statusMessageExpiryDateTime = new DateTimeTimeZone();
$statusMessageExpiryDateTime->setDateTime('2022-10-18T17:05:33.2079781');
$statusMessageExpiryDateTime->setTimeZone('Pacific Standard Time');
$statusMessage->setExpiryDateTime($statusMessageExpiryDateTime);
$requestBody->setStatusMessage($statusMessage);
$graphServiceClient->users()->byUserId('user-id')->presence()->setStatusMessage()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.presence.set_status_message.set_status_message_post_request_body import SetStatusMessagePostRequestBody
from msgraph_beta.generated.models.presence_status_message import PresenceStatusMessage
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.date_time_time_zone import DateTimeTimeZone
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetStatusMessagePostRequestBody(
status_message = PresenceStatusMessage(
message = ItemBody(
content = "Hey I'm currently in a meeting.",
content_type = BodyType.Text,
),
expiry_date_time = DateTimeTimeZone(
date_time = "2022-10-18T17:05:33.2079781",
time_zone = "Pacific Standard Time",
),
),
)
await graph_client.users.by_user_id('user-id').presence.set_status_message.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
The following request sets the presence status message as "Hey I am available now" for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3. In Example 3, presence information for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3 is obtained on behalf of another user via a getPresence 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"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.Presence.SetStatusMessage;
using Microsoft.Graph.Beta.Models;
var requestBody = new SetStatusMessagePostRequestBody
{
StatusMessage = new PresenceStatusMessage
{
Message = new ItemBody
{
Content = "Hey I am available now",
ContentType = BodyType.Text,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Users["{user-id}"].Presence.SetStatusMessage.PostAsync(requestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
mgc-beta users presence set-status-message post --user-id {user-id} --body '{\
"statusMessage": {\
"message": {\
"content": "Hey I am available now",\
"contentType": "text"\
}\
}\
}\
'
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewSetStatusMessagePostRequestBody()
statusMessage := graphmodels.NewPresenceStatusMessage()
message := graphmodels.NewItemBody()
content := "Hey I am available now"
message.SetContent(&content)
contentType := graphmodels.TEXT_BODYTYPE
message.SetContentType(&contentType)
statusMessage.SetMessage(message)
requestBody.SetStatusMessage(statusMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Users().ByUserId("user-id").Presence().SetStatusMessage().Post(context.Background(), requestBody, nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody setStatusMessagePostRequestBody = new com.microsoft.graph.beta.users.item.presence.setstatusmessage.SetStatusMessagePostRequestBody();
PresenceStatusMessage statusMessage = new PresenceStatusMessage();
ItemBody message = new ItemBody();
message.setContent("Hey I am available now");
message.setContentType(BodyType.Text);
statusMessage.setMessage(message);
setStatusMessagePostRequestBody.setStatusMessage(statusMessage);
graphClient.users().byUserId("{user-id}").presence().setStatusMessage().post(setStatusMessagePostRequestBody);
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Presence\SetStatusMessage\SetStatusMessagePostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PresenceStatusMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SetStatusMessagePostRequestBody();
$statusMessage = new PresenceStatusMessage();
$statusMessageMessage = new ItemBody();
$statusMessageMessage->setContent('Hey I am available now');
$statusMessageMessage->setContentType(new BodyType('text'));
$statusMessage->setMessage($statusMessageMessage);
$requestBody->setStatusMessage($statusMessage);
$graphServiceClient->users()->byUserId('user-id')->presence()->setStatusMessage()->post($requestBody)->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Import-Module Microsoft.Graph.Beta.Users.Actions
$params = @{
statusMessage = @{
message = @{
content = "Hey I am available now"
contentType = "text"
}
}
}
Set-MgBetaUserPresenceStatusMessage -UserId $userId -BodyParameter $params
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.presence.set_status_message.set_status_message_post_request_body import SetStatusMessagePostRequestBody
from msgraph_beta.generated.models.presence_status_message import PresenceStatusMessage
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SetStatusMessagePostRequestBody(
status_message = PresenceStatusMessage(
message = ItemBody(
content = "Hey I am available now",
content_type = BodyType.Text,
),
),
)
await graph_client.users.by_user_id('user-id').presence.set_status_message.post(request_body)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
This example follows Example 2. Presence information for user fa8bf3dc-eca7-46b7-bad1-db199b62afc3 is obtained on behalf of another user via a getPresence request.
GET https://graph.microsoft.com/beta/users/fa8bf3dc-eca7-46b7-bad1-db199b62afc3/presence
// 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}"].Presence.GetAsync();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
presence, err := graphClient.Users().ByUserId("user-id").Presence().Get(context.Background(), nil)
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Presence result = graphClient.users().byUserId("{user-id}").presence().get();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->users()->byUserId('user-id')->presence()->get()->wait();
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta 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').presence.get()
Important
Microsoft Graph SDKs use the v1.0 version of the API by default, and do not support all the types, properties, and APIs available in the beta version. For details about accessing the beta API with the SDK, see Use the Microsoft Graph SDKs with the beta API.
Because this request gets the presence status for another user, the 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"
}
}
}