How to archiving Teams via Graph API

How to archiving Teams via Graph API

Archiving a team or a group can help preserve the content and settings of the team or group, while preventing users from making changes to it. In this article, we will explore three cool Graph API calls that can help you archive teams and groups using HTTP requests.


1. Archive a team

To archive a team, you can use the archive action on the team resource. Archiving a team will make it read-only for all members and owners, and disable most changes to the team settings. However, membership changes are still allowed. Archiving a team is an async operation, which means that the team is archived once the async operation completes successfully, which may occur after the response from the API. To archive a team, the team and group must have an owner. To restore a team from its archived state, you can use the unarchive action. The HTTP request for archiving a team is as follows:

http POST /teams/{id}/archive Content-Type: application/json Body: { "shouldSetSpoSiteReadOnlyForMembers": true }         

The request body can optionally include the shouldSetSpoSiteReadOnlyForMembers parameter, which defines whether to set permissions for team members to read-only on the SharePoint Online site associated with the team. Setting it to false or omitting the body altogether will result in this step being skipped. If the archiving is started successfully, the API will return a 202 Accepted response code, along with a Location header that contains the location of the teamsAsyncOperation that was created to handle archiving of the team. You can check the status of the archiving operation by making a GET request to this location.


2. Archive a group

To archive a group, you can use the archive action on the group resource. Archiving a group will make it read-only for all members and owners, and disable most changes to the group settings. However, membership changes are still allowed. Archiving a group is an async operation, which means that the group is archived once the async operation completes successfully, which may occur after the response from the API. To archive a group, the group must have an owner. To restore a group from its archived state, you can use the unarchive action. The HTTP request for archiving a group is as follows:

http POST /groups/{id}/archive Content-Type: application/json Body:{ "groupTypes": ["Unified"] }        

The request body must include the groupTypes parameter, which specifies the type of the group to be archived. The only supported value is Unified, which indicates a Microsoft 365 group. If the archiving is started successfully, the API will return a 202 Accepted response code, along with a Location header that contains the location of the directoryObject that was created to handle archiving of the group. You can check the status of the archiving operation by making a GET request to this location.


3. List archived teams or groups

To list all the archived teams or groups in your organization, you can use the list operation on the team or group resource, and filter by the isArchived property. The isArchived property indicates whether the team or group is in an archived state. The value is true if the team or group is archived, and false otherwise. The HTTP request for listing archived teams is as follows:

http GET /teams?$filter=isArchived eq true        

The HTTP request for listing archived groups is as follows:

http GET /groups?$filter=isArchived eq true         

Both requests will return a 200 OK response code, along with a collection of team or group objects that match the filter criteria.

I hope you enjoyed reading this article and learned something new. If you want to know more about the Graph API and how to work with Microsoft Teams, you can check out the Microsoft Graph documentation and the Microsoft Teams API overview. Thank you for your interest and have a great day!


Sources

Archive team - Microsoft Graph v1.0 | Microsoft Learn. https://learn.microsoft.com/en-us/graph/api/team-archive?view=graph-rest-1.0.

Use the Microsoft Graph API to work with Microsoft Teams. https://learn.microsoft.com/en-us/graph/api/resources/teams-api-overview?view=graph-rest-1.0.

Use the Microsoft Graph API to work with Microsoft Teams. https://learn.microsoft.com/en-us/graph/api/resources/teams-api-overview?view=graph-rest-1.0.


Hello, is it possible to archive a group chat using power automate??

回复
Ragnar Heil

HanseVision?r?? Microsoft MVP Copilot & M365, Corporate Influencer, Viva Explorer, Employee Experience, Internat.Speaker, Governance Pro

1 年

Great idea.to use it with Rencore Governance which supports HTTP Requests. Would fit well to your former posting about Governance

Kasper Larsen

Microsoft M365 MVP, Senior Solution Architect at Fellowmind Denmark, Maintainer of the PnP Modern search project, " If your Information Architecture is lacking, forget all about a good Search or Copilot experience"

1 年

And for admins with a preference for PowerShell, https://pnp.github.io/powershell/cmdlets/Set-PnPTeamsTeamArchivedState.html

要查看或添加评论,请登录

Marcel Broschk的更多文章

社区洞察

其他会员也浏览了