Teams Export API - chats that were initiated in another tenant

Eran Otmi 60 Reputation points
2026-09-07T08:03:10.7066667+00:00

Hi,

I have a question about the Teams Export APIs.

Goal: capture all chat communications for a specific monitored user.

Current flow: I call GET /users/{id}/chats to enumerate the user's chats, then GET /chats/{chat-id}/messages for each one. This works for the majority of chats.

The gap: when the monitored user is an external/guest participant in a chat that was initiated in another tenant, the chat data lives in that other tenant, and the chat_id does not surface in GET /users/{id}/chats. Those conversations are therefore never discovered and never exported.

GET /users/{id}/chats/getAllMessages does return messages from those missing chats. But I can't use it as the primary export path: it returns the user's complete message history, and running it for every monitored user in the tenant means pulling a very large volume of data - much of it duplicated, since the API returns both sent and received messages for each user in a thread.

What I tried: use getAllMessages only for discovery, not bulk export -

  1. getAllMessages with $filter=from/user/userIdentityType eq 'federatedUser' or from/user/userIdentityType eq 'anonymousGuest'
  2. collect the distinct chatId values from the results
  3. remove the ones already found via /chats — what remains is the set of missing chats
  4. fetch only those chats' messages

Step 4 is where I'm stuck. I had planned to call getAllMessages filtered by chatId, but per the documentation chatId is not a supported $filter field — the supported filters are from/user/id, from/user/userIdentityType, from/application/applicationIdentityType, messageType, and a lastModifiedDateTime range.

Questions:

  1. Is there a supported way to scope getAllMessages to a specific set of chatId values, or any plan to add one?
  2. For a chat that does not appear in GET /users/{id}/chats because it is owned by another tenant, can I still call GET /chats/{chat-id}/messages for it using application permissions (Chat.Read.All / ChatMessage.Read.Chat) from my tenant? The documentation notes that in application context the request must be made from the tenant the chat owner belongs to, which suggests this would fail - please confirm.
  3. Is there any endpoint that enumerates chats where a given user is an external participant, i.e. the chats /chats omits?
  4. If none of the above is available, what is the recommended pattern for exporting these cross-tenant external conversations without sweeping every user's full message history?

Thanks!

Microsoft Teams | Development
Microsoft Teams | Development

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


2 answers

Sort by: Oldest
  1. Jayden-P 2,520 Reputation points Independent Advisor
    2026-09-07T15:01:20.4166667+00:00

    Hi @Eran Otmi

    Based on the current Microsoft Graph and Teams Export API documentation, I'm not aware there is a supported way to achieve the workflow you're describing.

    1. Based on the current documentation, there is no support for filtering getAllMessages by chatId. The API does not expose chatId as a supported filter property. As a result, there is no supported way today to scope getAllMessages to a specific set of chat IDs.
      Screenshot 2026-09-07 at 21.58.16
    2. The documentation for listing chat messages states that, in application context, the request must be made from the tenant that owns the chat. Therefore, for chats that originate in another tenant, an application registered in your tenant would generally not be able to retrieve messages using GET /chats/{chat-id}/messages even when the monitored user participates in that conversation.
    3. I am not aware of any Graph endpoint that specifically enumerates chats where a user participates as an external or guest user in another tenant when those chats are not returned.
    4. Given the current limitations, the practical approach appears to be using GET /users/{id}/chats/getAllMessages as the authoritative source for exporting cross-tenant conversations, and then reducing volume through incremental export patterns such as lastModifiedDateTime watermarking and message-level deduplication. There does not currently appear to be a supported API that allows discovery of those externally owned chats followed by targeted retrieval of their messages.

    If this capability is important for your scenario, I'd recommend submitting feedback through the Microsoft Graph feedback channels, as support for filtering by chatId on getAllMessages would significantly improve export efficiency for cross-tenant compliance scenarios.

    Was this answer helpful?


  2. Ramjot Singh 861 Reputation points Microsoft Employee
    2026-09-08T08:37:05.8533333+00:00

    First a clarification, users/ID/chats does return the out of tenant chats.

    However, your original question was around duplication and if you could fetch a specific chat just once. This is only partially true. /getAllMessages returns the user's view of messages. If user1, user2 and user3 participated in the convo but user3 was added at later point with limited history sharing, then /getAllMessages on user3 will not return previous messages. Additionally, certain aspects like soft deleted messages may appear in only user's view depending what the user had access to. Similarly, as users leave chat, their view of it gets frozen which would again land you in the problem of partial view.

    Change Notifications achieve what you are looking for but obviously going forward only, not backward.

    Was this answer helpful?


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.