ChatMessage.Send
Allows an app to send one-to-one and group chat messages in Microsoft Teams, on behalf of the signed-in user.
Permission Details
Send user chat messages
Allows an app to send one-to-one and group chat messages in Microsoft Teams, on behalf of the signed-in user.
116b7235-7cc6-461e-b163-8e55691d839e
Properties
Properties is shown from stable Microsoft Graph v1.0 metadata.
| Property | Type | Description |
|---|---|---|
attachments |
chatMessageAttachment collection |
References to attached objects like files, tabs, meetings etc. |
body |
itemBody |
Plaintext/HTML representation of the content of the chat message. Representation is specified by the contentType inside the body. The content is always in HTML if the chat message contains a chatMessageMention. |
chatId |
stringNullable |
If the message was sent in a chat, represents the identity of the chat. |
channelIdentity |
channelIdentity |
If the message was sent in a channel, represents identity of the channel. |
createdDateTime |
dateTimeOffsetNullable |
Timestamp of when the chat message was created. |
deletedDateTime |
dateTimeOffsetNullable |
Read only. Timestamp at which the chat message was deleted, or null if not deleted. |
etag |
stringNullable |
Read-only. Version number of the chat message. |
eventDetail |
eventMessageDetail |
Read-only. If present, represents details of an event that happened in a chat, a channel, or a team, for example, adding new members. For event messages, the messageType property will be set to systemEventMessage. |
from |
chatMessageFromIdentitySet |
Details of the sender of the chat message. Can only be set during migration. |
id |
String |
Read-only. Unique ID of the message. IDs are unique within a chat/channel/reply-to-message, but might be duplicated in other chats/channels/reply-to-messages. |
importance |
string |
The importance of the chat message. The possible values are: normal, high, urgent. |
lastModifiedDateTime |
dateTimeOffsetNullable |
Read only. Timestamp when the chat message is created (initial setting) or modified, including when a reaction is added or removed. |
lastEditedDateTime |
dateTimeOffsetNullable |
Read only. Timestamp when edits to the chat message were made. Triggers an "Edited" flag in the Teams UI. If no edits are made the value is null. |
locale |
string |
Locale of the chat message set by the client. Always set to en-us. |
mentions |
chatMessageMention collection |
List of entities mentioned in the chat message. Supported entities are: user, bot, team, channel, chat, and tag. |
Showing 15 of 25 properties.
JSON Representation
JSON representation is shown from stable Microsoft Graph v1.0 metadata.
{
"attachments": [
{
"@odata.type": "microsoft.graph.chatMessageAttachment"
}
],
"body": {
"@odata.type": "microsoft.graph.itemBody"
},
"channelIdentity": {
"@odata.type": "microsoft.graph.channelIdentity"
},
"chatId": "String",
"createdDateTime": "String (timestamp)",
"deletedDateTime": "String (timestamp)",
"etag": "String",
"eventDetail": {
"@odata.type": "microsoft.graph.eventMessageDetail"
},
"from": {
"@odata.type": "microsoft.graph.chatMessageFromIdentitySet"
},
"id": "String (identifier)",
"importance": "String",
"lastEditedDateTime": "String (timestamp)",
"lastModifiedDateTime": "String (timestamp)",
"locale": "String",
"mentions": [
{
"@odata.type": "microsoft.graph.chatMessageMention"
}
],
"messageHistory": [
{
"@odata.type": "microsoft.graph.chatMessageHistoryItem"
}
],
"messageType": "String",
"policyViolation": {
"@odata.type": "microsoft.graph.chatMessagePolicyViolation"
},
"reactions": [
{
"@odata.type": "microsoft.graph.chatMessageReaction"
}
],
"replyToId": "String (identifier)",
"subject": "String",
"summary": "String",
"webUrl": "String"
}
Relationships
Relationships is shown from stable Microsoft Graph v1.0 metadata.
| Relationship | Type | Description |
|---|---|---|
hostedContents |
chatMessageHostedContent collection |
Content in a message hosted by Microsoft Teams - for example, images or code snippets. |
replies |
chatMessage collection |
Replies for a specified message. Supports $expand for channel messages. |
attachments |
chatMessageAttachment collection |
References to attached objects like files, tabs, meetings etc. |
body |
itemBody |
Related body data exposed by this resource. |
importance |
chatMessageImportance |
Related importance data exposed by this resource. |
mentions |
chatMessageMention collection |
List of entities mentioned in the chat message. Supported entities are: user, bot, team, channel, chat, and tag. |
messageHistory |
chatMessageHistoryItem collection |
List of activity history of a message item, including modification time and actions, such as reactionAdded, reactionRemoved, or reaction changes, on the message. |
messageType |
chatMessageType |
Related messageType data exposed by this resource. |
reactions |
chatMessageReaction collection |
Reactions for this chat message (for example, Like). |
Graph Methods
Microsoft Graph v1.0 endpoints are mapped directly from refreshed Microsoft Learn permissions tables.
Microsoft Graph beta endpoints are mapped directly from refreshed Microsoft Learn permissions tables.
Microsoft Graph PowerShell v1.0 commands are mapped directly from refreshed Microsoft Learn PowerShell snippets.
| Commands |
|---|
New-MgChatMessage
/chats/{chat-id}/messages
Send message in a chat
|
New-MgChatPinnedMessage
/chats/{chat-Id}/pinnedMessages
Pin a message in a chat
|
Microsoft Graph PowerShell beta commands are mapped directly from refreshed Microsoft Learn PowerShell snippets.
Code Examples
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new PinnedChatMessageInfo
{
AdditionalData = new Dictionary<string, object>
{
{
"[email protected]" , "https://graph.microsoft.com/v1.0/chats/19:[email protected]/messages/1616964509832"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Chats["{chat-id}"].PinnedMessages.PostAsync(requestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const chatMessage = {
messageIds: [
'1728088338580'
],
replyMessage: {
body: {
content: 'Hello World'
}
}
};
await client.api('/chats/19:[email protected]/messages/replyWithQuote')
.post(chatMessage);
Import-Module Microsoft.Graph.Teams
$params = @{
"[email protected]" = "https://graph.microsoft.com/v1.0/chats/19:[email protected]/messages/1616964509832"
}
New-MgChatPinnedMessage -ChatId $chatId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.pinned_chat_message_info import PinnedChatMessageInfo
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = PinnedChatMessageInfo(
additional_data = {
"message@odata_bind" : "https://graph.microsoft.com/v1.0/chats/19:[email protected]/messages/1616964509832",
}
)
result = await graph_client.chats.by_chat_id('chat-id').pinned_messages.post(request_body)
App Registration
Navigate to Azure Portal
Go to App registrations in Microsoft Entra admin center
Add API Permission
Select your app → API permissions → Add a permission → Microsoft Graph
Select Permission Type
Choose Delegated permissions and search for ChatMessage.Send
Grant Admin Consent
Users can consent to this permission during sign-in.