Share via

Does /teams/{id}/channels/getAllMessages guarantee message ordering?

Jason Perrone 20 Reputation points
2026-05-03T18:55:57.8833333+00:00

Hi,

I'm using the /teams/{teamId}/channels/getAllMessages endpoint with a lastModifiedDateTime date filter.

In my testing, the API appears to return messages in chronological order by createdDateTime, but I cannot find any documentation confirming this is guaranteed behavior.

My questions:

  1. Does this endpoint return messages in a guaranteed order, or is the order implementation-specific and subject to change?
  2. Does it support $orderby=createdDateTime to explicitly control ordering?

SDK: github.com/microsoftgraph/msgraph-sdk-go v1 Endpoint: GET /teams/{team-id}/channels/getAllMessages Filter used: lastModifiedDateTime gt {from} and lastModifiedDateTime lt {to}

Thank you.

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

Answer accepted by question author

  1. Teddie-D 15,050 Reputation points Microsoft External Staff Moderator
    2026-05-04T01:03:46.7766667+00:00

    Hi @Jason Perrone 

    For GET /teams/{team-id}/channels/getAllMessages, ordering is not guaranteed. 

    According to the note in Export content with the Microsoft Teams Export APIs - Microsoft Teams | Microsoft Learn, the order of messages in the response isn't guaranteed to be sorted by any datetime, such as createdDateTime or lastModifiedDateTime

    So even though in testing (and in your observation) results may appear in descending order by createdDateTime, this is not a contractual behavior and should not be relied upon. 

    This endpoint does not support $orderby. Only a limited set of query options such as $filter are supported for the export APIs, and $orderby is not one of them. 

    If your scenario depends on ordering, you should: 

    -Treat the response as unordered 

    -Apply client-side sorting (e.g., by createdDateTime or lastModifiedDateTime

    -Avoid relying on ordering across pages or repeated calls 

    -Also note that when filtering on lastModifiedDateTime, edited messages can appear outside their original creation order, which can affect paging results. 

    I hope this information is helpful. 


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".    

    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. 

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-05-03T18:56:12.76+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more
    1. The documentation for GET /teams/{team-id}/channels/getAllMessages does not state any guaranteed sort order for the returned messages. It only documents support for $top and $filter on lastModifiedDateTime, and explicitly notes that other OData query parameters are not currently supported. Therefore, any apparent ordering (such as chronological by createdDateTime) must be treated as implementation-specific and subject to change.
    2. $orderby is not supported for this endpoint. The docs specify that only $top and $filter (with a dateTime range on lastModifiedDateTime) are supported and that other OData query parameters are not currently supported. This implies $orderby=createdDateTime is not supported for channels/getAllMessages.

    If deterministic ordering is required, the client should sort the returned messages locally by the desired property (for example, createdDateTime).


    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.