| title | Send message in a chat |
|---|---|
| description | Send a new message in a chat. |
| ms.localizationpriority | medium |
| author | RamjotSingh |
| ms.subservice | teams |
| doc_type | apiPageType |
| ms.date | 04/04/2024 |
Namespace: microsoft.graph
Send a new chatMessage in the specified chat. This API can't create a new chat; you must use the list chats method to retrieve the ID of an existing chat before you can create a chat message.
Note: We don't recommend that you use this API for data migration. It doesn't have the throughput necessary for a typical migration.
Note: It is a violation of the terms of use to use Microsoft Teams as a log file. Only send messages that people will read.
[!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 /chats/{chat-id}/messages| Name | Description |
|---|---|
| Authorization | Bearer {code}. Required. |
In the request body, supply a JSON representation of a chatMessage object.
If successful, this method returns a 201 Created response code and a new chatMessage object in the response body.
For a more comprehensive list of examples, see Create chatMessage in a channel or a chat.
The following example shows a request.
POST https://graph.microsoft.com/v1.0/chats/19:2da4c29f6d7041eca70b638b43d45437@thread.v2/messages
Content-type: application/json
{
"body": {
"content": "Hello world"
}
}[!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]
The following example shows the response.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#chats('19%3A2da4c29f6d7041eca70b638b43d45437%40thread.v2')/messages/$entity",
"id": "1616991463150",
"replyToId": null,
"etag": "1616991463150",
"messageType": "message",
"createdDateTime": "2021-03-29T04:17:43.15Z",
"lastModifiedDateTime": "2021-03-29T04:17:43.15Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": "19:2da4c29f6d7041eca70b638b43d45437@thread.v2",
"importance": "normal",
"locale": "en-us",
"webUrl": null,
"channelIdentity": null,
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "8ea0e38b-efb3-4757-924a-5f94061cf8c2",
"displayName": "Robin Kline",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "text",
"content": "Hello World"
},
"attachments": [],
"mentions": [],
"reactions": [],
"messageHistory": []
}