Skip to content

Latest commit

 

History

History
352 lines (273 loc) · 11.9 KB

File metadata and controls

352 lines (273 loc) · 11.9 KB
title chatMessage: forwardToChat
description Forward a chat message, a channel message, or a channel message reply to a chat.
author sumanac
ms.subservice teams
doc_type apiPageType
ms.localizationpriority medium
ms.date 02/20/2025

chatMessage: forwardToChat

Namespace: microsoft.graph

[!INCLUDE beta-disclaimer]

Forward a chat message, a channel message, or a channel message reply to a chat.

[!INCLUDE national-cloud-support]

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.

[!INCLUDE permissions-table]

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:97641583cf154265a237da28ebbde27a@thread.v2/messages/forwardToChat
Content-Type: application/json

{
  "targetChatIds": [
    "19:e2ed97baac8e4bffbb91299a38996790@thread.v2"
  ],
  "messageIds": [
    "1728088338580"
  ],
  "additionalMessage": {
    "body": {
      "content": "Hello World"
    }
  }
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


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:e2ed97baac8e4bffbb91299a38996790@thread.v2",
      "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:b6343216390d46cba965fe36bd877674@thread.tacv2/messages/forwardToChat
Content-Type: application/json

{
  "targetChatIds": [
    "19:e2ed97baac8e4bffbb91299a38996790@thread.v2"
  ],
  "messageIds": [
    "1728088338580"
  ],
  "additionalMessage": {
    "body": {
      "content": "Hello World"
    }
  }
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


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:e2ed97baac8e4bffbb91299a38996790@thread.v2",
      "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:b6343216390d46cba965fe36bd877674@thread.tacv2/messages/1727810802267/replies/forwardToChat
Content-Type: application/json

{
  "targetChatIds": [
    "19:e2ed97baac8e4bffbb91299a38996790@thread.v2"
  ],
  "messageIds": [
    "1728088338580"
  ],
  "additionalMessage": {
    "body": {
      "content": "Hello World"
    }
  }
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


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:e2ed97baac8e4bffbb91299a38996790@thread.v2",
      "forwardedMessageId": "1730918320559",
      "error": null
    }
  ]
}