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 -
-
getAllMessages with $filter=from/user/userIdentityType eq 'federatedUser' or from/user/userIdentityType eq 'anonymousGuest'
- collect the distinct
chatId values from the results
- remove the ones already found via
/chats — what remains is the set of missing chats
- 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:
- Is there a supported way to scope
getAllMessages to a specific set of chatId values, or any plan to add one?
- 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.
- Is there any endpoint that enumerates chats where a given user is an external participant, i.e. the chats
/chats omits?
- 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!