Pin a chat message in the specified chat. This API cannot create a new chat; you must use the list chats method to retrieve the ID of an existing chat before you can pin a chat message.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
ChatMessage.Send, Chat.ReadWrite
Delegated (personal Microsoft account)
Not supported.
Application
Chat.ReadWrite.All
HTTP request
POST /chats/{chat-Id}/pinnedMessages
Request headers
Name
Description
Authorization
Bearer {token}. Required.
Content-Type
application/json. Required.
Request body
In the request body, supply the ID of a chat message to pin.
Response
If successful, this method returns a 201 Created response code and a pinnedChatMessageInfo object in the response body.
POST https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/pinnedMessages
Content-Type: application/json
Content-length: 63
{
"message@odata.bind":"https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages/1616964509832"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new PinnedChatMessageInfo
{
AdditionalData = new Dictionary<string, object>
{
{
"message@odata.bind" , "https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages/1616964509832"
},
},
};
var result = await graphClient.Chats["{chat-id}"].PinnedMessages.PostAsync(requestBody);
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new PinnedChatMessageInfo();
$additionalData = [
'message@odata.bind' => 'https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages/1616964509832',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->chats()->byChatId('chat-id')->pinnedMessages()->post($requestBody);