ForwardMessages#
Beta version
The functionality is in beta. Features may change and may also work unstably.
The method is used to forward messages from one Instagram Direct chat to another.
The method uses the limits on the number of requests per second.
On an instance authorized by the Login method, messages are forwarded one by one: if Instagram rejects forwarding one of the messages, the messages forwarded before it remain in the recipient chat.
Limitations with the browser session authorization
On an instance authorized through a browser session, the same kinds of messages are forwarded as in the browser: text, a message with a link, an image, a video, a share of a post or a Reel and a profile card.
A voice message, a sticker, a GIF animation, a story share and a location are not forwarded by such an instance: the method responds with 400 and the text audioMessage forwarding not supported if instance authorized using extension.
All the messages from messages are checked before forwarding: if at least one of them cannot be forwarded, none is forwarded.
A poll is not forwarded by any instance. If messages contains only polls, the method responds with 400 and the text pollMessage forwarding not supported. If polls are only a part of the list, the other messages are forwarded: only they get into the response, and for each poll the outgoingMessageStatus notification comes with the failed status and the pollMessage forwarding not supported reason.
Request#
To forward messages, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/forwardMessages/{{apiTokenInstance}}
For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Request parameters#
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
chatId | string | Yes | Chat identifier - the numeric identifier of an account or of a group chat, or a username with the @ prefix |
chatIdFrom | string | Yes | Chat identifier the messages are forwarded from - the numeric identifier of an account or of a group chat, or a username with the @ prefix |
messages | array | Yes | The collection of the identifiers of the messages to forward |
Request body example#
Forwarding two messages to a group chat:#
{
"chatId": "340282366841710300949128174631143137232",
"chatIdFrom": "49547665464",
"messages": [
"32992354783594572492903878028689408",
"32992354783594572492903878028689409"
]
}
Forwarding one message by the recipient's username:#
{
"chatId": "@green_api",
"chatIdFrom": "49547665464",
"messages": ["32992354783594572492903878028689408"]
}
Response#
Response parameters#
| Field | Type | Description |
|---|---|---|
messages | array | The identifiers of the new messages in the order of the request |
Response body example#
{
"messages": [
"32992354783594572492903878028689500",
"32992354783594572492903878028689501"
]
}
ForwardMessages errors#
For a list of errors common to all methods, refer to the Common errors section
| HTTP code | Error ID | Description |
|---|---|---|
| 400 | Bad Request Validation failed | Validation error |
| 400 | Validation failed. Details: 'chatIdFrom' must be the numeric account or thread id, or a nickname prefixed with '@' | The chat to forward from (chatIdFrom) has an invalid format |
| 400 | Validation failed. Details: 'messages' is required | The messages are not specified |
| 400 | Validation failed. Details: 'messages' does not contain 1 required value(s) | The list of messages is empty |
| 400 | Validation failed. Details: 'messages[0]' must be the numeric message id | An item of the messages list must contain digits only. The square brackets contain the item number, starting from zero |
| 400 | Messages by IDs not found: 32992354783594572492903878028689408,32992354783594572492903878028689409 | Some of the messages are not in the source chat, nothing is forwarded. The comma-separated list contains the identifiers from messages that are not there |
| 400 | audioMessage forwarding not supported if instance authorized using extension | On an imported session a message of this type is not forwarded |
| 400 | pollMessage forwarding not supported | All the messages from messages are polls: a poll is not forwarded |
| 400 | request rejected | The instance is authorized by the Login method: Instagram has rejected the forwarding - for example, there is no such message in the source chat |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/forwardMessages/{{apiTokenInstance}}"
payload = {
"chatId": "340282366841710300949128174631143137232",
"chatIdFrom": "49547665464",
"messages": ["32992354783594572492903878028689408"]
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/forwardMessages/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "340282366841710300949128174631143137232",
"chatIdFrom": "49547665464",
"messages": ["32992354783594572492903878028689408"]
}'