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.
Undo soft deletion of a single chatMessage or a chat message reply in a channel or a chat.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permissions for channel
Permission type |
Permissions (from least to most privileged) |
Delegated (work or school account) |
ChannelMessage.ReadWrite |
Delegated (personal Microsoft account) |
Not supported |
Application |
Not supported |
Note: Permissions marked with ** are supported only for backward compatibility. We recommend that you update your solutions to use an alternative permission listed in the previous table and avoid using these permissions going forward.
Permissions for chat
Permission type |
Permissions (from least to most privileged) |
Delegated (work or school account) |
Chat.ReadWrite |
Delegated (personal Microsoft account) |
Not supported |
Application |
Not supported |
HTTP request
To undo soft deletion of a chatMessage in a channel:
POST /teams/{teamsId}/channels/{channelId}/messages/{chatMessageId}/undoSoftDelete
POST /teams/{teamId}/channels/{channelId}/messages/{messageId}/replies/{replyId}/undoSoftDelete
To undo soft deletion of a chatMessage in a chat:
POST /users/{userId}/chats/{chatsId}/messages/{chatMessageId}/undoSoftDelete
Request body
Don't supply a request body for this method.
Response
If successful, this action returns a 204 No Content
response code.
Examples
Example 1: Undo soft deletion of a message in a chat
Request
POST https://graph.microsoft.com/beta/users/8f98f01d-1a73-401a-b9e9-9fd1e6f5e5ap/chats/19:[email protected]/messages/1649864053377/undoSoftDelete
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Users["{user-id}"].Chats["{chat-id}"].Messages["{chatMessage-id}"].UndoSoftDelete.PostAsync();
mgc-beta users chats messages undo-soft-delete post --user-id {user-id} --chat-id {chat-id} --chat-message-id {chatMessage-id}
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Users().ByUserId("user-id").Chats().ByChatId("chat-id").Messages().ByChatMessageId("chatMessage-id").UndoSoftDelete().Post(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.users().byUserId("{user-id}").chats().byChatId("{chat-id}").messages().byChatMessageId("{chatMessage-id}").undoSoftDelete().post();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/users/8f98f01d-1a73-401a-b9e9-9fd1e6f5e5ap/chats/19:[email protected]/messages/1649864053377/undoSoftDelete')
.version('beta')
.post();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->users()->byUserId('user-id')->chats()->byChatId('chat-id')->messages()->byChatMessageId('chatMessage-id')->undoSoftDelete()->post()->wait();
Import-Module Microsoft.Graph.Beta.Teams
Undo-MgBetaUserChatMessageSoftDelete -UserId $userId -ChatId $chatId -ChatMessageId $chatMessageId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.users.by_user_id('user-id').chats.by_chat_id('chat-id').messages.by_chat_message_id('chatMessage-id').undo_soft_delete.post()
Response
HTTP/1.1 204 No Content
Example 2: Undo soft deletion of a message in a channel
Request
POST https://graph.microsoft.com/beta/teams/172b0cce-e65d-44ce-9a49-91d9f2e8593a/channels/19:[email protected]/messages/1649864053377/undoSoftDelete
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Teams["{team-id}"].Channels["{channel-id}"].Messages["{chatMessage-id}"].UndoSoftDelete.PostAsync();
mgc-beta teams channels messages undo-soft-delete post --team-id {team-id} --channel-id {channel-id} --chat-message-id {chatMessage-id}
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Teams().ByTeamId("team-id").Channels().ByChannelId("channel-id").Messages().ByChatMessageId("chatMessage-id").UndoSoftDelete().Post(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.teams().byTeamId("{team-id}").channels().byChannelId("{channel-id}").messages().byChatMessageId("{chatMessage-id}").undoSoftDelete().post();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/teams/172b0cce-e65d-44ce-9a49-91d9f2e8593a/channels/19:[email protected]/messages/1649864053377/undoSoftDelete')
.version('beta')
.post();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->teams()->byTeamId('team-id')->channels()->byChannelId('channel-id')->messages()->byChatMessageId('chatMessage-id')->undoSoftDelete()->post()->wait();
Import-Module Microsoft.Graph.Beta.Teams
Undo-MgBetaTeamChannelMessageSoftDelete -TeamId $teamId -ChannelId $channelId -ChatMessageId $chatMessageId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.teams.by_team_id('team-id').channels.by_channel_id('channel-id').messages.by_chat_message_id('chatMessage-id').undo_soft_delete.post()
Response
HTTP/1.1 204 No Content
Example 3: Undo soft deletion of a message of a reply in a channel
Request
POST https://graph.microsoft.com/beta/teams/172b0cce-e65d-44ce-9a49-91d9f2e8593a/channels/19:[email protected]/messages/1649864053377/undoSoftDelete
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Teams["{team-id}"].Channels["{channel-id}"].Messages["{chatMessage-id}"].UndoSoftDelete.PostAsync();
mgc-beta teams channels messages undo-soft-delete post --team-id {team-id} --channel-id {channel-id} --chat-message-id {chatMessage-id}
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Teams().ByTeamId("team-id").Channels().ByChannelId("channel-id").Messages().ByChatMessageId("chatMessage-id").UndoSoftDelete().Post(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.teams().byTeamId("{team-id}").channels().byChannelId("{channel-id}").messages().byChatMessageId("{chatMessage-id}").undoSoftDelete().post();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/teams/172b0cce-e65d-44ce-9a49-91d9f2e8593a/channels/19:[email protected]/messages/1649864053377/undoSoftDelete')
.version('beta')
.post();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->teams()->byTeamId('team-id')->channels()->byChannelId('channel-id')->messages()->byChatMessageId('chatMessage-id')->undoSoftDelete()->post()->wait();
Import-Module Microsoft.Graph.Beta.Teams
Undo-MgBetaTeamChannelMessageSoftDelete -TeamId $teamId -ChannelId $channelId -ChatMessageId $chatMessageId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.teams.by_team_id('team-id').channels.by_channel_id('channel-id').messages.by_chat_message_id('chatMessage-id').undo_soft_delete.post()
Response
HTTP/1.1 204 No Content