Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
The Teams Export APIs in Microsoft Graph that use /getAllMessages and /getAllRetainedMessages are generally available (GA) endpoints, not beta, but they have specific, documented behaviors and limits that explain what is being seen.
- Relationship between
/getAllMessagesand/getAllRetainedMessages
There are two different concepts in the Teams export story:
- Standard export of messages
- For chats:
GET /users/{id}/chats/getAllMessages - For channels:
GET /teams/{teamId}/channels/getAllMessages - For deleted teams:
GET /teamwork/deletedTeams/{deletedTeamId}/channels/getAllMessages
- For chats:
- Export of retained messages (compliance/hold copies)
- For chats:
GET /users/{id}/chats/getAllRetainedMessages - For channels:
GET /teams/{teamId}/channels/getAllRetainedMessages
- For chats:
The retained variants are specifically tied to Teams retention policies or holds:
-
getAllRetainedMessagesrequires that the tenant be configured with Teams retention policies. - It returns messages from the holds folder (compliance copies), including:
- Messages soft‑deleted by users beyond the normal 21‑day deletion period, if the user is on hold or a valid retention policy is set.
- Previous versions of edited messages, when a valid retention policy is set.
The standard getAllMessages endpoints return the normal export view of chat/channel messages, including support for:
- Messages from active and deleted teams/channels for up to 30 days from the day of deletion.
- Messages for deleted or inactive users for up to 30 days from deletion/inactivation.
Because both APIs can surface deleted content within certain time windows, there can be overlap where deleted messages appear in both getAllMessages and getAllRetainedMessages. That overlap depends on:
- Whether the team/channel/user is within the 30‑day deleted window.
- Whether retention policies/holds are configured and still in effect.
- Why behavior around deleted messages can appear to change
From the documented behavior:
- Export APIs support capturing messages from deleted Teams and channels for a maximum of 30 days from deletion. After 30 days, the team/channel is hard deleted and messages cannot be retrieved.
-
getAllRetainedMessagessupports retrieving deleted channel messages for a maximum of 30 days from the day of deletion when retention/holds apply. - For soft‑deleted messages in chats/channels, if the user is on hold or a valid retention policy is set, messages can be exported beyond the normal 21‑day deletion period, but the API note still caps deleted channel messages at 30 days.
This means:
- In some periods, deleted messages may be visible via
getAllMessages(because the team/channel is still within the 30‑day deleted window) and also viagetAllRetainedMessages(because retention/holds are active). - Once the 30‑day window is passed for deleted teams/channels,
getAllMessageswill stop returning those deleted items, and only retained copies (if any) remain accessible viagetAllRetainedMessages.
If behavior changed from “only via getAllMessages” → “only via getAllRetainedMessages” → “via both”, that typically reflects:
- Changes in retention policy configuration or holds.
- The timing of when deletions occurred relative to the 21‑day and 30‑day windows.
- 30‑day vs 24‑hour behavior for
getAllRetainedMessages
The documented expectation for retained messages is:
- Deleted channel messages can be retrieved for a maximum of 30 days from the day of deletion via
getAllRetainedMessages. - Export APIs also support deleted Teams/channels and deleted/inactive users for up to 30 days.
There is no documented change that limits getAllRetainedMessages to only the last 24 hours. If only the last 24 hours of deleted messages are currently returned, that is not reflected in the published behavior and likely indicates either:
- A change in the tenant’s retention/hold configuration affecting what is retained.
- A service‑side issue or regression that would need to be raised via support, since the documentation still states 30‑day support for deleted messages.
- Stability and GA status
From the documentation:
-
chat: getAllRetainedMessages(GET /users/{id}/chats/getAllRetainedMessages) is documented under the v1.0 (GA) Microsoft Graph namespace and requires application permissions (Chat.Read.AllorChat.ReadWrite.All). -
channel: getAllRetainedMessages(GET /teams/{teamId}/channels/getAllRetainedMessages) is also documented under v1.0 and requiresChannelMessage.Read.Allapplication permission. -
deletedTeam: getAllMessages(GET /teamwork/deletedTeams/{deletedTeamId}/channels/getAllMessages) is likewise in v1.0 and requiresChannelMessage.Read.All.
Being in the v1.0 endpoint set indicates GA status rather than beta. However, even GA export APIs can have:
- Strictly enforced limits (such as the 30‑day windows) that cause apparent behavior changes as data ages.
- Dependence on compliance configuration (retention policies, holds) that, when changed, alter what is returned.
The documentation does not list any upcoming breaking changes, but it does explicitly note current limitations (for example, no private channels for channel: getAllRetainedMessages, no meeting‑related control messages, and specific support windows for deleted entities).
- Expected behavior summary
-
/users/{id}/chats/getAllMessagesand/teams/{teamId}/channels/getAllMessages:- GA (v1.0) export APIs.
- Return chat/channel messages, including deleted Teams/channels and deleted/inactive users, up to 30 days after deletion.
-
/users/{id}/chats/getAllRetainedMessagesand/teams/{teamId}/channels/getAllRetainedMessages:- GA (v1.0) export APIs.
- Require Teams retention policies to be configured.
- Return retained (compliance) copies, including:
- Soft‑deleted messages beyond the normal 21‑day deletion period when on hold or under a valid retention policy.
- Edited history of messages when retention is configured.
- For deleted channel messages, retrieval is supported for a maximum of 30 days from deletion.
If current behavior does not match this (for example, only 24 hours of deleted messages via getAllRetainedMessages), the next step is to verify retention policy configuration and, if still inconsistent, open a support case, as the published contracts for these v1.0 APIs are as described above.
References: