| title | chat: getAllRetainedMessages |
|---|---|
| description | Get all retained messages from all chats that a user is a participant in, including one-on-one chats, group chats, and meeting chats. |
| author | bkeerthivasa |
| ms.localizationpriority | medium |
| ms.subservice | teams |
| doc_type | apiPageType |
| ms.date | 10/14/2024 |
Namespace: microsoft.graph
Get all retained messages from all chats that a user is a participant in, including one-on-one chats, group chats, and meeting chats.
To learn more about how to use the Microsoft Teams export APIs to export content, see Export content with the Microsoft Teams export APIs.
Note
This API requires Teams retention policies to be configured. For more information, see Learn about retention for Microsoft Teams.
[!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]
GET /users/{id}/chats/getAllRetainedMessagesThis method supports the following OData query parameters to help customize the response. For general information, see OData query parameters.
| Name | Description |
|---|---|
| $filter | The $filter query parameter supports date and time range queries on the lastModifiedDateTime property using date range parameters. |
| $top | Use the $top query parameter to control the number of items per response. |
The following example shows a request that uses the $top and $filter query parameters to get a list of retained chat messages.
GET /users/{id}/chats/getAllRetainedMessages?$top=50&$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z and lastModifiedDateTime lt 2020-06-05T21:00:09.413ZThe following table lists examples that show how to use the $filter parameter.
| Scenario | $filter parameter |
Possible values |
|---|---|---|
| Get messages sent by user identity type | $filter=from/user/userIdentityType eq '{teamworkUserIdentityType}' | aadUser, onPremiseAadUser, anonymousGuest, federatedUser, personalMicrosoftAccountUser, skypeUser, phoneUser |
| Get messages sent by application type | $filter=from/application/applicationIdentityType eq '{teamworkApplicationIdentity}' | aadApplication, bot, tenantBot, office365Connector, outgoingWebhook |
| Get messages sent by user ID | $filter=from/user/id eq '{oid}' | |
| Get control (system event) messages | $filter=messageType eq 'systemEventMessage' | |
| Exclude control (system event) messages | $filter=messageType ne 'systemEventMessage' |
| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
Don't supply a request body for this method.
If successful, this method returns a 200 OK response code and a collection of chatMessage objects in the response body.
The following example shows a request.
GET https://graph.microsoft.com/v1.0/users/8b081ef6-4792-4def-b2c9-c363a1bf41d5/chats/getAllRetainedMessages[!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.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(chatMessage)",
"@odata.count": 10,
"@odata.nextLink": "https://graph.microsoft.com/v1.0/users/8b081ef6-4792-4def-b2c9-c363a1bf41d5/chats/getAllRetainedMessages?$skip=10",
"value": [
{
"@odata.type": "#microsoft.graph.chatMessage",
"id": "1600457965467",
"replyToId": null,
"etag": "1600457965467",
"messageType": "message",
"createdDateTime": "2020-09-18T19:39:25.467Z",
"lastModifiedDateTime": "2020-09-18T19:39:25.467Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": "19:0de69e5e-2da8-4cf2-821f-5e6585b2c65b_5c64e248-3269-4268-a36e-0f80314e9c39@unq.gbl.spaces",
"importance": "normal",
"locale": "en-us",
"webUrl": null,
"channelIdentity": null,
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "0de69e5e-2da8-4cf2-821f-5e6585b2c65b",
"displayName": "Richard Wilson",
"userIdentityType": "aadUser"
}
},
"body": {
"contentType": "html",
"content": "<div>\n<blockquote itemscope=\"\" itemtype=\"http://schema.skype.com/Reply\" itemid=\"1600457867820\">\n<strong itemprop=\"mri\" itemid=\"8:orgid:0de69e5e-2da8-4cf2-821f-5e6585b2c65b\">Richard Wilson</strong><span itemprop=\"time\" itemid=\"1600457867820\"></span>\n<p itemprop=\"preview\">1237</p>\n</blockquote>\n<p>this is a reply</p>\n</div>"
},
"attachments": [],
"mentions": [],
"reactions": []
}
]
}