Graph API to read Teams latest channel messages based on timestamp field

Kiran Varkala 0 Reputation points
2025-09-18T03:02:19.87+00:00

Hi,

Is there any Graph API to read a Team channel's latest messages based on timestamp field.

I am looking for documentation around this.

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

3 answers

Sort by: Most helpful
  1. Kudos-Ng 15,050 Reputation points Microsoft External Staff Moderator
    2025-09-18T06:09:23.5866667+00:00

    Hi Kiran Varkala,

    Thank you for posting your question in the Microsoft Q&A forum. 

    I understand you're looking to retrieve the latest message from a specific Teams channel based on a timestamp field. The chatMessage resource includes several timestamp properties such as createdDateTime, lastModifiedDateTime, deletedDateTime, and lastEditedDateTime. Based on your phrasing, I assume you're specifically interested in sorting by createdDateTime.

    After researching, here are a few suggestions and insights:

    • The standard API GET /teams/{team-id}/channels/{channel-id}/messages does not support $orderby=createdDateTime. Messages are returned based on lastModifiedDateTime, and the only supported query options are $top and $expand. To get the latest message by creation time, you’ll need to fetch a batch (e.g., using $top=50) and sort them manually on the client side. Once you identify the message you're interested in, you can use the endpoint GET /teams/{team-id}/channels/{channel-id}/messages/{message-id} to retrieve its full details.
      User's image User's image
    • For a more dedicated and real-time approach, consider using the Change Notifications API. You can subscribe to message events (create/update/delete) in a channel and receive push notifications when new messages are posted. This avoids the need for polling and gives you immediate access to the latest content.

    Reference:

    I hope these resources help!


    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.

    Was this answer helpful?


  2. Sayali-MSFT 6,396 Reputation points Microsoft External Staff Moderator
    2025-09-18T05:02:55.7233333+00:00

    Hello Kiran Varkala , Yes, Microsoft Graph API supports reading messages from Teams channels and filtering them based on timestamps.

    1. List Channel Messages
    1. Get All Messages Across Channels
    1. Search API for Teams Messages
    1. Get Specific Message by ID

    Was this answer helpful?


  3. AI answer

    2025-09-18T03:02:20.21+00:00

    Yes, you can use the Microsoft Graph API to read the latest messages from a Team channel. Specifically, you can utilize the API endpoint that allows you to list messages across channels in a team. This will enable you to retrieve messages and filter them based on the timestamp field.

    For more detailed information on how to implement this, you can refer to the Microsoft Graph documentation for working with Teams messaging APIs.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    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.