channel: archive
Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Archive a channel in a team. When a channel is archived, users can't send new messages or react to existing messages in the channel, edit the channel settings, or make other changes to the channel.
You can delete an archived channel, or add and remove members from it. If you archive a team, its channels are archived for you.
Archiving is asynchronous; a channel is archived after the asynchronous archiving operation completes successfully, which might occur after the response returns.
A channel without an owner, or that belongs to a group that has no owner, can't be archived.
To restore a channel from its archived state, use the unarchive method. A channel can’t be archived or unarchived if its team is archived.
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type | Least privileged permissions | Higher privileged permissions |
---|---|---|
Delegated (work or school account) | ChannelSettings.ReadWrite.All | Not available. |
Delegated (personal Microsoft account) | Not supported. | Not supported. |
Application | ChannelSettings.ReadWrite.All | Not available. |
Note: This API supports admin permissions. Global admins and Microsoft Teams service admins can access teams that they are not a member of.
HTTP request
POST /teams/{team-id}/channels/{channel-id}/archive
POST /groups/{team-id}/team/channels/{channel-id}/archive
Request headers
Header | Value |
---|---|
Authorization | Bearer {token}. Required. |
Request body
In the request, you can optionally include the shouldSetSpoSiteReadOnlyForMembers
parameter in a JSON body, as follows.
{
"shouldSetSpoSiteReadOnlyForMembers": true
}
This optional parameter defines whether to set permissions for channel members to read-only on the SharePoint Online site associated with the team. Setting it to false or omitting the body altogether results in this step being skipped.
Response
If archiving is started successfully, this method returns a 202 Accepted
response code. The response contains a Location
header, which contains the location of the teamsAsyncOperation that was created to handle archiving of the channel in a team. Check the status of the archiving operation by making a GET request to this location.
Examples
Example 1: Archive a channel
The following example shows a request to archive a channel.
Request
POST https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/archive
Response
The following example shows the response.
HTTP/1.1 202 Accepted
Location: /teams/{team-id}/operations/{operation-id}
Content-Type: text/plain
Content-Length: 0
Example 2: Archive a channel when the team is archived
The following example shows a request when the team is archived.
Request
POST https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/archive
Response
The following example shows the 400
error response.
http/1.1 400 Bad Request
Content-Type: application/json
Content-Length: 193
{
"error": {
"code": "BadRequest",
"message": "Team has to be active, for channel to be archived or unarchived: {channel-id}",
"innerError": {
"message": "Team has to be active, for channel to be archived or unarchived: {channel-id}",
"code": "Unknown",
"innerError": {},
"date": "2023-12-11T04:26:35",
"request-id": "8f897345980-f6f3-49dd-83a8-a3064eeecdf8",
"client-request-id": "50a0er33-4567-3f6c-01bf-04d144fc8bbe"
}
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for