Edit

Share via


chatMessage: forwardToChat

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 headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

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"
    }
  }
}

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"
    }
  }
}

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"
    }
  }
}

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
    }
  ]
}