Pages Menu
TwitterRssFacebook

Posted by on Nov 21, 2021 in Development, Microsoft Teams

You can now hide and unhide Microsoft Teams chats via Graph API calls

You can now hide and unhide Microsoft Teams chats via Graph API calls

Two new API calls have quietly been added to the Microsoft Graph in the past few days, giving developers the ability to hide (and then un-hide) user chats.

Applications will need Chat.ReadWrite permission (Delegated permission only, no Application permission at this time) and if they have the Chat ID can POST the following to hide a chat:

POST /chats/{chatsId}/hideForUser

What’s interesting is that it’s also required to send a JSON payload in the body, containing the tenantID and also the user identity of the user the application want to hide the chat from. Because the only supported permission is delegated, this would seem to be unnecessary, and in fact, the documentation even says this: In delegated mode, users can only hide a chat for themselves.

My guess is that Application support is coming soon, and this is then where this information comes in handy.

Here’s an example payload body for the above call:

POST https://graph.microsoft.com/beta/chats/19:7d.../hideForUser
Content-Type: application/json

{
  "user": {
    "id" : "11e2d645-63db-4c8c-9b8f-5f7023d929b5"
  },
  "tenantId": "d78d296e-5dc9-443a-8091-cecc3bb5b401"
}

There is a corresponding unhide command as well, with all the same permissions and body:

POST /chats/{chatsId}/unhideForUser

It’s worth noting as well that already this will hide the chat for the user, if a Send Message command happens on the chat, this will un-hide it.

Ref:
chat: hideForUser
chat: unhideForUser

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

2 Comments

  1. Hi! I tried to use the resource, but even with the correct payload and the correct call, the following error appears:

    POST: https://graph.microsoft.com/beta/chats/19:…@thread.v2/hideForUser

    {
    “error”: {
    “code”: “NotFound”,
    “message”: “Request path is not supported. Use /chats/chatId/hideForUser”,
    “innerError”: {
    “date”: “2021-12-01T13:21:08”,
    “request-id”: “f03b32cd-0b38-4e84-a9ed-6990f08f2824”,
    “client-request-id”: “f03b32cd-0b38-4e84-a9ed-6990f08f2824”
    }
    }
    }

  2. Interesting, that’s a pretty strange error message as well! Let me see if I can reproduce and see if there’s a problem with the docs, or the API. It’s new so it could well still be rolling out – it might be a case of waiting a bit to see if it fixes itself…

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.