Export content with the Microsoft Teams Export APIs

Teams Export APIs allow you to export 1:1 and group chat messages from Microsoft Teams. If your organization needs to export Microsoft Teams messages, you can be able to extract them using Teams Export APIs. Chat Message represents an individual chat message within a channel or chat. The chat message can be a root chat message or part of a reply thread that is defined by the replyToId property in the chat message.

Here are some examples on how you can use these export APIs:

  • Example 1: If you have enabled Microsoft Teams in your organization and want to export all the Microsoft Teams messages to date programmatically by passing the date range for a given user.
  • Example 2: If you want to programmatically export all user messages daily by providing a date range. Export APIs can retrieve all the messages created or updated during the given date range.

What is supported by the Teams Export APIs?

  • Bulk Export of Teams Message: Teams Export APIs support up to 200 RPS Per App Per tenant and 600 RPS for an Application, with these limits you should be able to bulk export of Teams messages.

  • Application Context: To call Microsoft Graph, your app must acquire an access token from the Microsoft identity platform. The access token contains information about your app and the permissions it has for the resources and APIs available through Microsoft Graph. To get an access token, your app must be registered with the Microsoft identity platform and be authorized by either a user or an administrator for access to the Microsoft Graph resources it needs.

    If you are already familiar with integrating an app with the Microsoft identity platform to get tokens, see the Next Steps section for information and samples specific to Microsoft Graph.

  • Hybrid Environment: Export APIs support messages sent by users who are provisioned on Hybrid Environment (on-premises Exchange and Teams). Any messages that are sent by users who are configured for hybrid environment will be accessible using Export APIs.

  • User Deleted Messages: Messages that are deleted by user from Teams client can be accessed using export APIs up to 30 days from the time of deletion.

  • Message Attachments: Export APIs include the links to the attachments that are sent as part of messages. Using Export APIs you can retrieve the files attached in the messages.

  • Chat Message Properties: Refer to the complete list of properties that Teams Export APIs support here.

How to access Teams Export APIs

  • Example 1 is a simple query to retrieve all the messages of a user without any filters:

    GET https://graph.microsoft.com/beta/users/{id}/chats/allMessages
  • Example 2 is a sample query to retrieve all the messages of a user by specifying date time filters and top 50 messages:

    GET https://graph.microsoft.com/beta/users/{id}/chats/allMessages?$top=50&$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z and lastModifiedDateTime lt 2020-06-05T21:00:09.413Z


The API returns response with next page link in case of multiple results. For getting next set of results, simply call GET on the url from @odata.nextlink. If @odata.nextlink is not present or null then all messages are retrieved.

Prerequisites to access Teams Export APIs

  • Teams Export APIs are currently in preview. It will only be available to users and tenants that have the required licenses for APIs. In the future, Microsoft may require you or your customers to pay additional fees based on the amount of data accessed through the API.

  • Microsoft Teams APIs in Microsoft Graph that access sensitive data are considered protected APIs. Export APIs require that you have additional validation, beyond permissions and consent, before you can use them. To request access to these protected APIs, complete the request form.

  • Application permissions are used by apps that run without a signed-in user present; application permissions can only be consented by an administrator. The following permissions are needed:

    • Chat.Read.All: enables access to all 1:1 and Group chat messages
    • User.Read.All: enables access to the list of users for a tenant

JSON representation

The following example is a JSON representation of the resource:

Namespace: microsoft.graph

"id": "string (identifier)",
"replyToId": "string (identifier)",
"from": {"@odata.type": "microsoft.graph.identitySet"},
"etag": "string",
"messageType": "string",
"createdDateTime": "string (timestamp)",
"lastModifiedDateTime": "string (timestamp)",
"deletedDateTime": "string (timestamp)",
"subject": "string",
"from": {
                "application": null,
                "device": null,
                "conversation": null,
                "user": {
                    "id": "0de69e5e-2da8-4cf2-821f-5e6585b2c65b",
                    "displayName": "User Name",
                    "userIdentityType": "aadUser"                }
"body": {"@odata.type": "microsoft.graph.itemBody"},
"summary": "string",
"chatId": "19:0de69e5e-2da8-4cf2-821f-5e6585b2c65b_5c64e248-3269-4268-a36e-0f80314e9c39@unq.gbl.spaces"
"attachments": \[{"@odata.type": "microsoft.graph.chatMessageAttachment"}\],
"mentions": \[{"@odata.type": "microsoft.graph.chatMessageMention"}\],
"importance": "string",
"locale": "string",


For more details on chatMessage resource, see the chatMessage resource type article.