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.
Forward a chat message, a channel message, or a channel message reply to 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
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) |
ChatMessage.Send |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Not supported. |
Not supported. |
HTTP request
Forward a chatMessage in a chat to a chat:
POST /chats/{chatId}/messages/forwardToChat
Forward a chatMessage in a channel to a chat:
POST /teams/{teamId}/channels/{channelId}/messages/forwardToChat
POST /teams/{teamId}/channels/{channelId}/messages/{messageId}/replies/forwardToChat
Request body
In the request body, supply a JSON representation of the parameters.
The following table shows the parameters that can be used with this action.
Parameter |
Type |
Description |
additionalMessage |
chatMessage |
Message body of the forwarded message. |
messageIds |
String collection |
List of message IDs in a chat or channel that are being forwarded. Currently, only one message ID is supported. |
targetChatIds |
String collection |
List of target chat IDs where a message can be forwarded. Currently, only one target chat ID is supported. |
Response
If successful, this method returns a 200 OK
response code and a collection of forwardToChatResult objects in the response body.
Note
Because only a single target chat ID is supported in the request payload, the response contains only one value.
Examples
Example 1: Forward a message from a chat to a chat
The following example shows how to forward a message from a chat to a chat.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/chats/19:[email protected]/messages/forwardToChat
Content-Type: application/json
{
"targetChatIds": [
"19:[email protected]"
],
"messageIds": [
"1728088338580"
],
"additionalMessage": {
"body": {
"content": "Hello World"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Chats.Item.Messages.ForwardToChat;
using Microsoft.Graph.Beta.Models;
var requestBody = new ForwardToChatPostRequestBody
{
TargetChatIds = new List<string>
{
"19:[email protected]",
},
MessageIds = new List<string>
{
"1728088338580",
},
AdditionalMessage = new ChatMessage
{
Body = new ItemBody
{
Content = "Hello World",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Chats["{chat-id}"].Messages.ForwardToChat.PostAsForwardToChatPostResponseAsync(requestBody);
mgc-beta chats messages forward-to-chat post --chat-id {chat-id} --body '{\
"targetChatIds": [\
"19:[email protected]"\
],\
"messageIds": [\
"1728088338580"\
],\
"additionalMessage": {\
"body": {\
"content": "Hello World"\
}\
}\
}\
'
// 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"
graphchats "github.com/microsoftgraph/msgraph-beta-sdk-go/chats"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphchats.NewForwardToChatPostRequestBody()
targetChatIds := []string {
"19:[email protected]",
}
requestBody.SetTargetChatIds(targetChatIds)
messageIds := []string {
"1728088338580",
}
requestBody.SetMessageIds(messageIds)
additionalMessage := graphmodels.NewChatMessage()
body := graphmodels.NewItemBody()
content := "Hello World"
body.SetContent(&content)
additionalMessage.SetBody(body)
requestBody.SetAdditionalMessage(additionalMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
forwardToChat, err := graphClient.Chats().ByChatId("chat-id").Messages().ForwardToChat().PostAsForwardToChatPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.chats.item.messages.forwardtochat.ForwardToChatPostRequestBody forwardToChatPostRequestBody = new com.microsoft.graph.beta.chats.item.messages.forwardtochat.ForwardToChatPostRequestBody();
LinkedList<String> targetChatIds = new LinkedList<String>();
targetChatIds.add("19:[email protected]");
forwardToChatPostRequestBody.setTargetChatIds(targetChatIds);
LinkedList<String> messageIds = new LinkedList<String>();
messageIds.add("1728088338580");
forwardToChatPostRequestBody.setMessageIds(messageIds);
ChatMessage additionalMessage = new ChatMessage();
ItemBody body = new ItemBody();
body.setContent("Hello World");
additionalMessage.setBody(body);
forwardToChatPostRequestBody.setAdditionalMessage(additionalMessage);
var result = graphClient.chats().byChatId("{chat-id}").messages().forwardToChat().post(forwardToChatPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const actionResultPart = {
targetChatIds: [
'19:[email protected]'
],
messageIds: [
'1728088338580'
],
additionalMessage: {
body: {
content: 'Hello World'
}
}
};
await client.api('/chats/19:[email protected]/messages/forwardToChat')
.version('beta')
.post(actionResultPart);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Chats\Item\Messages\ForwardToChat\ForwardToChatPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\ChatMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ForwardToChatPostRequestBody();
$requestBody->setTargetChatIds(['19:[email protected]', ]);
$requestBody->setMessageIds(['1728088338580', ]);
$additionalMessage = new ChatMessage();
$additionalMessageBody = new ItemBody();
$additionalMessageBody->setContent('Hello World');
$additionalMessage->setBody($additionalMessageBody);
$requestBody->setAdditionalMessage($additionalMessage);
$result = $graphServiceClient->chats()->byChatId('chat-id')->messages()->forwardToChat()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
targetChatIds = @(
"19:[email protected]"
)
messageIds = @(
"1728088338580"
)
additionalMessage = @{
body = @{
content = "Hello World"
}
}
}
Invoke-MgBetaForwardChatMessageToChat -ChatId $chatId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.chats.item.messages.forward_to_chat.forward_to_chat_post_request_body import ForwardToChatPostRequestBody
from msgraph_beta.generated.models.chat_message import ChatMessage
from msgraph_beta.generated.models.item_body import ItemBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ForwardToChatPostRequestBody(
target_chat_ids = [
"19:[email protected]",
],
message_ids = [
"1728088338580",
],
additional_message = ChatMessage(
body = ItemBody(
content = "Hello World",
),
),
)
result = await graph_client.chats.by_chat_id('chat-id').messages.forward_to_chat.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.forwardToChatResult)",
"value": [
{
"@odata.type": "#microsoft.graph.forwardToChatResult",
"targetChatId": "19:[email protected]",
"forwardedMessageId": "1730918320559",
"error": null
}
]
}
Example 2: Forward a message from a channel to a chat
The following example shows how to forward a message from a channel to a chat.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/teams/1e769eab-06a8-4b2e-ac42-1f040a4e52a1/channels/19:[email protected]/messages/forwardToChat
Content-Type: application/json
{
"targetChatIds": [
"19:[email protected]"
],
"messageIds": [
"1728088338580"
],
"additionalMessage": {
"body": {
"content": "Hello World"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Teams.Item.Channels.Item.Messages.ForwardToChat;
using Microsoft.Graph.Beta.Models;
var requestBody = new ForwardToChatPostRequestBody
{
TargetChatIds = new List<string>
{
"19:[email protected]",
},
MessageIds = new List<string>
{
"1728088338580",
},
AdditionalMessage = new ChatMessage
{
Body = new ItemBody
{
Content = "Hello World",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teams["{team-id}"].Channels["{channel-id}"].Messages.ForwardToChat.PostAsForwardToChatPostResponseAsync(requestBody);
mgc-beta teams channels messages forward-to-chat post --team-id {team-id} --channel-id {channel-id} --body '{\
"targetChatIds": [\
"19:[email protected]"\
],\
"messageIds": [\
"1728088338580"\
],\
"additionalMessage": {\
"body": {\
"content": "Hello World"\
}\
}\
}\
'
// 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"
graphteams "github.com/microsoftgraph/msgraph-beta-sdk-go/teams"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphteams.NewForwardToChatPostRequestBody()
targetChatIds := []string {
"19:[email protected]",
}
requestBody.SetTargetChatIds(targetChatIds)
messageIds := []string {
"1728088338580",
}
requestBody.SetMessageIds(messageIds)
additionalMessage := graphmodels.NewChatMessage()
body := graphmodels.NewItemBody()
content := "Hello World"
body.SetContent(&content)
additionalMessage.SetBody(body)
requestBody.SetAdditionalMessage(additionalMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
forwardToChat, err := graphClient.Teams().ByTeamId("team-id").Channels().ByChannelId("channel-id").Messages().ForwardToChat().PostAsForwardToChatPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.teams.item.channels.item.messages.forwardtochat.ForwardToChatPostRequestBody forwardToChatPostRequestBody = new com.microsoft.graph.beta.teams.item.channels.item.messages.forwardtochat.ForwardToChatPostRequestBody();
LinkedList<String> targetChatIds = new LinkedList<String>();
targetChatIds.add("19:[email protected]");
forwardToChatPostRequestBody.setTargetChatIds(targetChatIds);
LinkedList<String> messageIds = new LinkedList<String>();
messageIds.add("1728088338580");
forwardToChatPostRequestBody.setMessageIds(messageIds);
ChatMessage additionalMessage = new ChatMessage();
ItemBody body = new ItemBody();
body.setContent("Hello World");
additionalMessage.setBody(body);
forwardToChatPostRequestBody.setAdditionalMessage(additionalMessage);
var result = graphClient.teams().byTeamId("{team-id}").channels().byChannelId("{channel-id}").messages().forwardToChat().post(forwardToChatPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const actionResultPart = {
targetChatIds: [
'19:[email protected]'
],
messageIds: [
'1728088338580'
],
additionalMessage: {
body: {
content: 'Hello World'
}
}
};
await client.api('/teams/1e769eab-06a8-4b2e-ac42-1f040a4e52a1/channels/19:[email protected]/messages/forwardToChat')
.version('beta')
.post(actionResultPart);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Teams\Item\Channels\Item\Messages\ForwardToChat\ForwardToChatPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\ChatMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ForwardToChatPostRequestBody();
$requestBody->setTargetChatIds(['19:[email protected]', ]);
$requestBody->setMessageIds(['1728088338580', ]);
$additionalMessage = new ChatMessage();
$additionalMessageBody = new ItemBody();
$additionalMessageBody->setContent('Hello World');
$additionalMessage->setBody($additionalMessageBody);
$requestBody->setAdditionalMessage($additionalMessage);
$result = $graphServiceClient->teams()->byTeamId('team-id')->channels()->byChannelId('channel-id')->messages()->forwardToChat()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
targetChatIds = @(
"19:[email protected]"
)
messageIds = @(
"1728088338580"
)
additionalMessage = @{
body = @{
content = "Hello World"
}
}
}
Invoke-MgBetaForwardTeamChannelMessageToChat -TeamId $teamId -ChannelId $channelId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.teams.item.channels.item.messages.forward_to_chat.forward_to_chat_post_request_body import ForwardToChatPostRequestBody
from msgraph_beta.generated.models.chat_message import ChatMessage
from msgraph_beta.generated.models.item_body import ItemBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ForwardToChatPostRequestBody(
target_chat_ids = [
"19:[email protected]",
],
message_ids = [
"1728088338580",
],
additional_message = ChatMessage(
body = ItemBody(
content = "Hello World",
),
),
)
result = await graph_client.teams.by_team_id('team-id').channels.by_channel_id('channel-id').messages.forward_to_chat.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.forwardToChatResult)",
"value": [
{
"@odata.type": "#microsoft.graph.forwardToChatResult",
"targetChatId": "19:[email protected]",
"forwardedMessageId": "1730918320559",
"error": null
}
]
}
Example 3: Forward a reply message from a channel to a chat
The following example shows how to forward a reply message from a channel to a chat.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/teams/1e769eab-06a8-4b2e-ac42-1f040a4e52a1/channels/19:[email protected]/messages/1727810802267/replies/forwardToChat
Content-Type: application/json
{
"targetChatIds": [
"19:[email protected]"
],
"messageIds": [
"1728088338580"
],
"additionalMessage": {
"body": {
"content": "Hello World"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Teams.Item.Channels.Item.Messages.Item.Replies.ForwardToChat;
using Microsoft.Graph.Beta.Models;
var requestBody = new ForwardToChatPostRequestBody
{
TargetChatIds = new List<string>
{
"19:[email protected]",
},
MessageIds = new List<string>
{
"1728088338580",
},
AdditionalMessage = new ChatMessage
{
Body = new ItemBody
{
Content = "Hello World",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Teams["{team-id}"].Channels["{channel-id}"].Messages["{chatMessage-id}"].Replies.ForwardToChat.PostAsForwardToChatPostResponseAsync(requestBody);
mgc-beta teams channels messages replies forward-to-chat post --team-id {team-id} --channel-id {channel-id} --chat-message-id {chatMessage-id} --body '{\
"targetChatIds": [\
"19:[email protected]"\
],\
"messageIds": [\
"1728088338580"\
],\
"additionalMessage": {\
"body": {\
"content": "Hello World"\
}\
}\
}\
'
// 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"
graphteams "github.com/microsoftgraph/msgraph-beta-sdk-go/teams"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphteams.NewForwardToChatPostRequestBody()
targetChatIds := []string {
"19:[email protected]",
}
requestBody.SetTargetChatIds(targetChatIds)
messageIds := []string {
"1728088338580",
}
requestBody.SetMessageIds(messageIds)
additionalMessage := graphmodels.NewChatMessage()
body := graphmodels.NewItemBody()
content := "Hello World"
body.SetContent(&content)
additionalMessage.SetBody(body)
requestBody.SetAdditionalMessage(additionalMessage)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
forwardToChat, err := graphClient.Teams().ByTeamId("team-id").Channels().ByChannelId("channel-id").Messages().ByChatMessageId("chatMessage-id").Replies().ForwardToChat().PostAsForwardToChatPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.teams.item.channels.item.messages.item.replies.forwardtochat.ForwardToChatPostRequestBody forwardToChatPostRequestBody = new com.microsoft.graph.beta.teams.item.channels.item.messages.item.replies.forwardtochat.ForwardToChatPostRequestBody();
LinkedList<String> targetChatIds = new LinkedList<String>();
targetChatIds.add("19:[email protected]");
forwardToChatPostRequestBody.setTargetChatIds(targetChatIds);
LinkedList<String> messageIds = new LinkedList<String>();
messageIds.add("1728088338580");
forwardToChatPostRequestBody.setMessageIds(messageIds);
ChatMessage additionalMessage = new ChatMessage();
ItemBody body = new ItemBody();
body.setContent("Hello World");
additionalMessage.setBody(body);
forwardToChatPostRequestBody.setAdditionalMessage(additionalMessage);
var result = graphClient.teams().byTeamId("{team-id}").channels().byChannelId("{channel-id}").messages().byChatMessageId("{chatMessage-id}").replies().forwardToChat().post(forwardToChatPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const actionResultPart = {
targetChatIds: [
'19:[email protected]'
],
messageIds: [
'1728088338580'
],
additionalMessage: {
body: {
content: 'Hello World'
}
}
};
await client.api('/teams/1e769eab-06a8-4b2e-ac42-1f040a4e52a1/channels/19:[email protected]/messages/1727810802267/replies/forwardToChat')
.version('beta')
.post(actionResultPart);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Teams\Item\Channels\Item\Messages\Item\Replies\ForwardToChat\ForwardToChatPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\ChatMessage;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ForwardToChatPostRequestBody();
$requestBody->setTargetChatIds(['19:[email protected]', ]);
$requestBody->setMessageIds(['1728088338580', ]);
$additionalMessage = new ChatMessage();
$additionalMessageBody = new ItemBody();
$additionalMessageBody->setContent('Hello World');
$additionalMessage->setBody($additionalMessageBody);
$requestBody->setAdditionalMessage($additionalMessage);
$result = $graphServiceClient->teams()->byTeamId('team-id')->channels()->byChannelId('channel-id')->messages()->byChatMessageId('chatMessage-id')->replies()->forwardToChat()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams
$params = @{
targetChatIds = @(
"19:[email protected]"
)
messageIds = @(
"1728088338580"
)
additionalMessage = @{
body = @{
content = "Hello World"
}
}
}
Invoke-MgBetaForwardTeamChannelMessageReplyToChat -TeamId $teamId -ChannelId $channelId -ChatMessageId $chatMessageId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.teams.item.channels.item.messages.item.replies.forward_to_chat.forward_to_chat_post_request_body import ForwardToChatPostRequestBody
from msgraph_beta.generated.models.chat_message import ChatMessage
from msgraph_beta.generated.models.item_body import ItemBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ForwardToChatPostRequestBody(
target_chat_ids = [
"19:[email protected]",
],
message_ids = [
"1728088338580",
],
additional_message = ChatMessage(
body = ItemBody(
content = "Hello World",
),
),
)
result = await graph_client.teams.by_team_id('team-id').channels.by_channel_id('channel-id').messages.by_chat_message_id('chatMessage-id').replies.forward_to_chat.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.forwardToChatResult)",
"value": [
{
"@odata.type": "#microsoft.graph.forwardToChatResult",
"targetChatId": "19:[email protected]",
"forwardedMessageId": "1730918320559",
"error": null
}
]
}