Share via

Retrieving deleted messages using Teams Export API

Eran Otmi 40 Reputation points
2026-04-29T11:26:54.6066667+00:00

Hi!

I have a Teams retention policy in place.
up until a few days ago, when calling /getAllMessages or /getAllRetainedMessages - the API response included deleted messages from up to a few weeks ago.
but since then, when calling these endpoints, the response only includes deleted messages from up to 24 hours ago.

I looked at the official documentation regarding Teams Export API and can't understand why that is happening.
No changes were done to my Teams` policies, but the behavior has changed.
There are older (than 24H) deleted messages that I expect to retrieve but are not included in the response.

Is that a temporary bug?
did something change with these endpoints in the past week?

Thanks

Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs

0 comments No comments

2 answers

Sort by: Most helpful
  1. Vergil-V 12,530 Reputation points Microsoft External Staff Moderator
    2026-04-29T13:13:18.08+00:00

    Hi @Eran Otmi   

    In addition to the insight provided by the Q&A Assist, I would like to confirm the following details to better understand your situation. 

    1/ According to the official documentation, deleted messages can be exported from the Teams API for up to 21 days. At the same time, as you mentioned, messages deleted more than 24 hours ago may not appear when running the endpoints. Could you please help confirm whether messages that are older than 24 hours but still within the 21-day window are not being returned in the endpoint results? 

    To help validate this behavior, you may consider using the $filter parameter as shown in the example below. 

    GET /users/{id}/chats/getAllMessages?$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z and lastModifiedDateTime lt 2020-06-05T21:00:09.413Z 

    2/ Could you also double check the Teams retention policy currently applied in your environment, and confirm which option you selected in the configuration shown in the image below?

     image

    At this moment, I have not found any recent reports or official documentation that directly address this behavior. That said, if you have any updates or additional findings, please feel free to share them. 


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Q&A Assist
    2026-04-29T11:27:20.74+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The behavior is explained by how Teams retention and the Export APIs work rather than by a documented recent change.

    Key points from the documentation:

    1. Retention policies control how long deleted/edited content is kept for export
      • When a Teams retention policy is configured to retain chats or channel messages, deleted or edited messages are stored in a secured location and remain available for eDiscovery and export until the end of the configured retention period or while another retention policy or eDiscovery hold applies.
      • When a retention policy is configured to delete chats or channel messages (and no longer retain them), those messages become eligible for permanent deletion from the secured location and will no longer be returned by eDiscovery or Export APIs once the retention period expires.

      “Permanent deletion of this data doesn't happen before the end of the configured retention period, or if another retention policy is configured to retain this data, or it's subject to an eDiscovery hold.”
      “If the messages were previously subject to a retain action and have been edited or deleted by users, these messages will now be deleted from the secured location and no longer returned in eDiscovery searches.”

    2. getAllRetainedMessages has explicit time limits for deleted content
      For retained messages, the API supports:
      • Soft‑deleted messages beyond the standard 21‑day deletion period only if the user is on hold or there is a valid retention policy.
      • Edited history when a valid retention policy is configured.
      • Deleted channel messages from deleted Teams and channels only up to 30 days from the day of deletion; after 30 days, teams/channels are hard deleted and messages cannot be retrieved.

      “The /getAllRetainedMessages API enables the retrieval of deleted channel messages for a maximum of 30 days from the day of deletion. After 30 days, the teams and channels are hard deleted, and messages can't be retrieved.”

    3. Export APIs support deleted users/teams only for limited time windows
      Export APIs support capturing messages from:
      • Deleted Teams and channels for a maximum of 30 days from deletion.
      • Deleted users and inactive users for up to 30 days from deletion/inactivation.
      After those windows, messages are no longer available via the Export APIs.
    4. End‑user experience confirms that retention‑deleted messages cannot be recovered
      From the end‑user perspective, when messages are deleted by a retention policy, a system message appears and:

      “Messages deleted by a retention policy can’t be recovered.”

    Putting this together for the described scenario:

    • If older deleted messages (more than 24 hours old) were previously returned and now are not, the most likely explanations consistent with the documentation are:
      • Those messages have now passed the configured retention period (or a shorter policy has started to apply), so they have been permanently deleted from the secured location and are no longer available to the Export APIs.
      • If they were in deleted teams/channels or associated with deleted/inactive users, they may have passed the 30‑day post‑deletion window during which Export APIs can still retrieve them.
    • The documentation does not state any recent change to the /getAllMessages or /getAllRetainedMessages endpoints that would globally reduce availability to 24 hours. Instead, availability is governed by:
      • The tenant’s Teams retention policies (retain vs delete and duration),
      • eDiscovery holds, and
      • The 30‑day limits for deleted teams/channels/users.

    Recommended checks:

    1. Verify the exact retention policy settings for Teams chats and channel messages (retain vs delete, and duration). Even if no changes were intentionally made, confirm that:
      • No new policy with a shorter retention period was created and applied to these locations.
      • No existing policy’s duration or action was changed from “retain” to “delete” or to a shorter period.
    2. Confirm whether the missing messages belong to:
      • Teams/channels that have since been deleted (and may now be beyond the 30‑day window), or
      • Users that have been deleted or made inactive more than 30 days ago.
    3. If the policies and timelines do not explain the behavior (for example, retention is configured to retain for significantly longer than a few weeks and the teams/users are not deleted), open a support case with Microsoft 365 support and provide:
      • Examples of message IDs/timestamps that used to be returned and are no longer returned, and
      • Confirmation of the applicable retention policies and their scopes.

    The documentation supports that message availability via Export APIs is strictly bound to retention and deletion timelines; it does not document a change to a 24‑hour limit on deleted messages. Any discrepancy beyond those documented rules should be investigated via support.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.