Server API/Messaging/Message management/Forward a message
# Forward a message

Forwards a specified message to a user, group chat or thread.

**Notice**：Notes: 
- [Bot ability](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) must be enabled.  
- To forward a message to a user, the bot must be [available](https://open.larksuite.com/document/home/introduction-to-scope-and-authorization/availability) for the user.
 - To forward a message to the group, the bot needs to be in the group.
 - This API has the following restrictions: 
    - Message types such as red envelopes, voting, audio and schedule transfers are not supported.
    - Re-forwarding a sub-message (the message with  ==upper_message_id== field) in merge-forward messages is not supported.
- To avoid disturbing users, the frequency limit for sending messages to the same user is ==5 QPS==, and the frequency limit for sending messages to the same group is ==5 QPS== shared by bots in the group.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.larksuite.com/open-apis/im/v1/messages/:message_id/forward
HTTP Method | POST
Rate Limit | [1000 per minute、50 per second](https://open.larksuite.com/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App、Store App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.**<br>Enable any scope from the list | Read and send messages in private and group chats(im:message)<br>Send messages as an app(im:message:send_as_bot)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

### Path parameters

Parameter | Type | Description
---|---|---
message_id | string | ID of message to forward.  For the description, refer to [Message ID description](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/intro#ac79c1c2).<br>**Example value**: "om_dc13264520392913993dd051dba21dcf"

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
receive_id_type | string | Yes | ID type of the message receiver, which can be open_id, user_id, union_id, email, or chat_id<br>**Example value**: open_id<br>**Optional values are**:<br>- open_id：Identifies a user to an app. The same user has different Open IDs in different apps. [How to get Open ID](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-openid)<br>- user_id：Identifies a user to a tenant. The same user has different User IDs in different tenants. In one single tenant, a user has the same User ID in all apps （including store apps）. User ID is usually used to communicate user data between different apps. [How to get User ID](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)<br>- union_id：Identifies a user to a tenant that acts as a developer. A user has the same Union ID in apps developed by the same developer, and has different Union IDs in apps developed by different developers. A developer can use Union ID to link the same user's identities in multiple apps. [How to get Union ID](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-union-id)<br>- email：Identifies users by "email", which is the user's actual email address<br>- chat_id：Identifies group chats by chat_id. You can call the API [Search for groups visible to a user or bot](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/search) to obtain the chat_id value. For group ID description, refer to [Group ID description](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-id-description)<br>- thread_id：Identifies thread by thread_id.  For thread ID description,  refer to [Thread Introduction](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/thread-introduction)<br>**When the value is `user_id`, the following field scopes are required:**<br>Obtain user ID(contact:user.employee_id:readonly)
uuid | string | No | A unique string sequence generated by the developer to forward message requests deduplicate; requests with the same uuid can only be successfully forwarded to the same target once within 1 hour.<br>**Example value**: b13g2t38-1jd2-458b-8djf-dtbca5104204<br>**Data validation rules**:<br>- Maximum length: `50` characters

### Request body

Parameter | Type | Required | Description
---|---|---|---
receive_id | string | Yes | According to the value of `receive_id_type`, fill in the ID of the corresponding forwarding target<br>**Example value**: "ou_a0553eda9014c201e6969b478895c230"

### Request body example
```json
{
    "receive_id": "ou_a0553eda9014c201e6969b478895c230"
}
```

**cURL Example**

```json 
curl --location --request POST 'https://open.larksuite.com/open-apis/im/v1/messages/om_dc13264520392913993dd051dba21dcf/forward?receive_id_type=open_id' \
--header 'Authorization: Bearer Bearer t-XXX' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '{
    "receive_id": "ou_a0553eda9014c201e6969b478895c230"
}'
```

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | message | \-
message_id | string | Message ID; for the description, refer to [Message ID description](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/intro#ac79c1c2)
root_id | string | Root message ID; used for replying to message scenarios; for the description, refer to [Message ID description](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/intro#ac79c1c2)
parent_id | string | Parent message ID; used for replying to message scenarios; for the description, refer to [Message ID description](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/intro#ac79c1c2)
thread_id | string | The thread ID to which the message belongs (not returned indicates that the message is not a thread message).  For the description, refer to [Thread Introduction](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/thread-introduction)
msg_type | string | Message types include: text, post, image, file, audio, media, sticker, interactive, share_chat, and share_user; for the definitions of types, refer to [Received message content](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/events/message_content)
create_time | string | Message generation timestamp (in ms)
update_time | string | Message update timestamp (in ms)
deleted | boolean | Whether the message is recalled
updated | boolean | Whether the message is updated
chat_id | string | Group of the message
sender | sender | Sender, which can be the user or app
id | string | This field identifies the sender's ID
id_type | string | This field identifies the sender's ID type<br>**Optional values are:**<br>- `open_id`<br>- `app_id`
sender_type | string | This field identifies the sender type<br>**Optional values are:**<br>- `user`<br>- `app`<br>- `anonymous`<br>- `unknown`
tenant_key | string | A tenant's unique ID in Lark. It can be used to obtain tenant_access_token, and can also be used as a tenant's unique ID in an app.
body | message_body | Message content
content | string | Message content, which is a string after the serialization of the JSON structure; different msg_type values correspond to different contents; message types include text, post, image, file, audio, media, sticker, interactive, share_chat, and share_user; for the definitions of types, refer to [Received Message Content](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/events/message_content)
mentions | mention\[\] | List of IDs of the mentioned users or bots
key | string | Serial number of the mentioned user or bot; for example, for the third mentioned member, the value is "@_user_3"
id | string | open_id of the mentioned user or bot
id_type | string | ID type of the mentioned user or bot; currently, only `open_id` is supported ([What is Open ID?](https://open.larksuite.com/document/home/user-identity-introduction/open-id))
name | string | Name of the mentioned user or bot
tenant_key | string | A tenant's unique ID in Lark. It can be used to obtain tenant_access_token, and can also be used as a tenant's unique ID in an app.
upper_message_id | string | message_id in the upper level of the combined and forwarded message; for the description, refer to [Message ID description](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/intro#ac79c1c2)

### Response body example
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "message_id": "om_dc13264520392913993dd051dba21dcf",
        "root_id": "om_40eb06e7b84dc71c03e009ad3c754195",
        "parent_id": "om_d4be107c616aed9c1da8ed8068570a9f",
        "msg_type": "text",
        "create_time": "1615380573411",
        "update_time": "1615380573411",
        "deleted": false,
        "updated": false,
        "chat_id": "oc_5ad11d72b830411d72b836c20",
        "sender": {
            "id": "cli_9f427eec54ae901b",
            "id_type": "app_id",
            "sender_type": "app",
            "tenant_key": "736588c9260f175e"
        },
        "body": {
            "content": "{\"text\":\"test content\"}"
        }
    }
}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
400 | 230001 | Your request contains an invalid request parameter. | Parameter error. Please check the input parameter according to the error message returned by the interface and refer to the document.
400 | 230002 | The bot can not be outside the group. | The bot isn't in the group chat.
400 | 230006 | Bot ability is not activated. | [Bot ability](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability) is not enabled. The bot ability can be added on the [Developer Console](https://open.larksuite.com/app) -> Features -> Add Features, and it will take effect after a new version is released.
400 | 230013 | Bot has NO availability to this user. | The bot is not [available](https://open.larksuite.com/document/home/introduction-to-scope-and-authorization/availability) for the user. You can edit the available scope of the application on the [Developer Console](https://open.larksuite.com/app)  -> App Versions -> Version Management & Release -> Create a version, and it will take effect after the new version is released.
400 | 230018 | These operations are NOT allowed at current group settings. | The current action is blocked by group settings. Please check the group settings or contact the group administrator.
400 | 230019 | The thread does NOT exist. | The thread you want to forward to does not exist.
400 | 230020 | This operation triggers the frequency limit. | The current action triggers the frequency limit. Please reduce the request frequency.
400 | 230027 | Lack of necessary permissions. | This operation is not currently supported in external groups.
400 | 230029 | User has resigned. | The user is terminated.
400 | 230034 | The receive_id is invalid | The receive_id in request body is invalid, please check it.
400 | 230035 | Send Message Permission deny. | Do not have permission to send messages. Please check whether the group has been muted, or is controlled by the communication permission of the tenant dimension.
400 | 230036 | Tenant crypt key has been deleted. | The tenant encryption key has been deleted, please contact the enterprise administrator.
400 | 230038 | Cross tenant p2p chat operate forbid. | Cross tenant P2P chat is not allowed to send messages through this interface.
400 | 230049 | The message is being sent. | The message is being sent, please try again later.
400 | 230050 | The message is invisible to the operator. | This operation cannot be performed on invisible messages.
400 | 230053 | The user has stopped the bot from sending messages. | The target user has been set to no longer receive bot messages, and cannot actively send single chat messages to the user.
400 | 230061 | The message type does not support forwarding. | System message, red envelope, voting, audio, schedule transfer and other message types do not support forwarding.
400 | 230062 | No permission to forward to third-party encryption group. | No permission to forward to third-party encryption groups.
400 | 230063 | The chat_id of group to forward is invalid. | The chat_id you want to forward to is invalid, check if the corresponding group chat_id exists.
400 | 230064 | The message to be forwarded is invalid. | The messages to be forwarded are invalid, such as non-existent, recalled, and invisible to the operator.
400 | 230065 | The message to be forwarded has been recalled. | All messages to be forwarded have been recalled.
400 | 230066 | The message to be forwarded is in a secret group, forwarding is not supported. | Forwarding messages from secret groups is not supported.
400 | 230070 | Forwarding of messages in restricted mode is not allowed. | Forwarding restricted messages is not supported. Please check whether the message has been set as restricted or the group has enabled the restricted mode.
400 | 230074 | The target thread is invisible to the operator. | The thread to be forwarded to is not visible to the operator. If "New members can see chat history" is turned off in the group chat and the thread was created before the operator entered the group chat, the thread needs to be passively subscribed by the operator to be visible, such as other users @ the operator in the thread.
400 | 230110 | Action unavailable as the message has been deleted. | Action unavailable as the message has been deleted.
400 | 232009 | Your request specifies a chat which has already been dissolved. | Your request specifies a chat which has already been dissolved.

