With the market success of Teams and the simplicity of using chats to communicate, it’s no wonder there are many chats happening outside of a Teams channel. One-to-one, group meetings, and bot chats all provide a quick way to communicate and work in Teams.
The New Chat and Channels Experience and threaded layout feature in Teams reflects on the idea that the reason these changes were introduced is because chats are the dominant method of communication within Teams rather than in segmented channel conversations.
Many organizations’ compliance teams consider content stored within users’ OneDrive for Business accounts, including Teams chats, to pose potential data risks. Without appropriate retention controls in place, content will be removed if the user leaves, removed by the user without oversight, or retained beyond any regulatory or legal timelines. To help mitigate some of the data risk, organizations often prioritize the timely removal of Teams chat data as their initial starting point. This is easy to configure in Purview with a retention policy scoped to Teams chats. (Figure 1)

This policy applies the retention and/or deletion settings to the messages from one-to-one, group meeting, and bot chats for users within scope of the policy. If you want chats deleted after 20 days, a retention policy is the right way to achieve the goal. Due care and attention are required when configuring a policy of this type to avoid the unintentional deletion of too many chats. (Teams Retention Error Removes Data).
What a retention policy doesn’t do is act on any of the files that may have been shared in those chats. Because the retention policies for Teams focus on messages, files are simply not included. If we look at files users share/upload in one-to-one and group chats, they are stored in a folder automatically created by Microsoft at the root of the user’s OneDrive called Microsoft Teams Chat Files. If an organization wants to delete these files in addition to the chats, this operation must be managed separately with a retention label applied to the content in that folder.
Configure a Retention Label and Auto-apply Policy
Because it is not possible to apply a retention policy to just 1 folder, you must apply a retention label to content within the folder with an auto-apply retention label policy. This means that Purview will delete files within the Microsoft Teams Chat Files folder and no other folder.
You can search against OneDrive data sources with this Keyword Query Language (KeyQL) query condition to find the files in that folder for an account:
Parentlink:”Microsoft Teams Chat Files”
Purview will apply the retention label to files in this folder for each OneDrive account that it processes.
Disclaimer: The auto-apply capability requires E5 compliance or equivalent for all users whose OneDrive accounts are within the scope of the auto-label policy.
Steps Taken
In this example, an organization wants to delete one-to-one and group chat files after 20 days. These are the steps to take in Purview Data Lifecycle Management or Records Management:
- Create a retention label with the option to Enforce actions after a specific period, with the period set to 20 days. Because there is no retention setting in the label, a user can freely delete files at any time prior to the 20 days, even with the label applied.
- Create an auto-apply retention label policy for the label created in step 1 and select the option to Apply label to content that contains specific words or phrases, or properties (Figure 2)

3. To target all content within the “Microsoft Teams Chat Files” folder, enter Parentlink:”Microsoft Teams Chat Files” as the condition: (Figure 3).

If you want to exclude some files from being deleted in the folder (for instance, Loop files that may be in active use in other apps), you can add an additional condition to exclude files based on their file extension. For example, this is the condition to exclude files with the .loop file extension: (Figure 4)
Parentlink:”Microsoft Teams Chat Files” AND NOT fileextension=loop

4. Scope the policy to only OneDrive accounts you want to apply the label on. You can use either a static or adaptive scope to identify the OneDrive accounts.
5. Run the policy in simulation mode to verify results before turning it on.
6. Turn on the policy when you are satisfied with the simulation results.
Important to know
- It can take up to 7 days for the retention label to be applied to chat files. To validate that the files were labeled, use Purview Content search against the OneDrive data sources you scoped in the label policy with the query condition:
Parentlink:”Microsoft Teams Chat Files” AND ComplianceTag:”Your retention label”
- Even if you configure the retention label to have a retention period shorter than 7 days, it can take up to 7 days for Purview to apply the label. In other words, the file may exist longer than 7 days.
- Like all auto-label policies, this policy applies the retention label to the files within the folder, not to the folder itself.
- If the user created a subfolder with the same name elsewhere in their OneDrive, those files will also have the retention label applied.
- You cannot see the retention label inside OneDrive without first selecting a file and viewing the retention label in the details pane.
- The principles of retention still apply. For example, if you had a retention policy targeting a User’s OneDrive to retain for 2 years and then delete, the labeled files in the “Microsoft Teams Chat Files” folder would still be retained for 2 years even if they had a retention label on them to “delete after 20 days”. (Principles of Retention).
Closing thoughts
Although this Purview configuration is straightforward, it has a significant impact on end users with a work preference for chats. For this reason, users should be notified in advance to avoid surprises when their chats and files are deleted automatically.
Since Teams chats are widespread, compliance-driven controls like this can be contentious, which may encourage users to move some discussions to Teams channels. This may be seen as a positive side effect by the organization, if not by users.