Skip to content

ForwardMessages#

Test Postman

The method is intended for forwarding messages to a personal or group chat. The forwarded message will be added to the sending queue. A message to be sent is stored in the queue for 24 hours and will be sent immediately after the phone is authorized. The rate at which messages are sent from the queue is regulated by the Message sending interval parameter.

Request#

To send it, you need to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/forwardMessages/{{apiTokenInstance}}

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Required Description
chatId string Yes Chat identifier the message is forwarded to
chatIdFrom string Yes Chat identifier the message is forwarded from
messages array Yes Collection of identifiers of the messages being forwarded
typingTime integer No The time the typing notification is displayed in the correspondent's chat.
The time is limited to values from 1000 to 20000 milliseconds (from 1 to 20 seconds).

Instance settings

For the message forwarding mechanism to work correctly, the system must know about the message that will be forwarded. You can make sure that a message is available for forwarding by requesting the journal method getMessage; if the message is not in the system, it is impossible to forward such a message.

  • To forward incoming messages, you need to enable the Receive notifications about incoming messages and files setting.

  • To forward outgoing messages sent from the phone, enable the Receive notifications about messages sent from the phone setting.

This way messages will get into the system and it will be possible to forward them.
You can apply the settings using the SetSettings method or through the console.

To forward an edited message, enable the editedMessageWebhook webhook.

Request body example#

{
    "chatId": "10000000",
    "chatIdFrom": "10000001",
    "messages": [
        "1769666251009",
        "1769666251008",
        "1769666251007"
    ]
}

Response#

Response fields#

Field Type Description
messages array Identifiers of the sent messages

Response body example#

{
  "messages": [
            "1769666251000", 
            "1769666251001", 
            "1769666251002"
  ]
}

ForwardMessages errors#

For the list of errors common to all methods, see the Common errors section

HTTP code Error identifier Description
400 Bad Request
Validation failed
Validation error
400 Validation failed.
Details: 'messages' must contain at least 1 items
Validation error. The messages field must not be empty.

Sending with an incorrect message identifier

If messages is specified incorrectly, the system will return code 200 and the id of the message being sent, but it will not be delivered to the recipient.

The recipient receives an unedited message

An unedited message will arrive to the recipient if the editedMessageWebhook webhook is disabled.

Request body example#

import requests   

url = "{{apiUrl}}/waInstance{{idInstance}}/forwardMessages/{{apiTokenInstance}}"

payload = {
  "chatId": "10000000",
  "chatIdFrom": "10000001",
  "messages": [
    "1769666251000",
    "1769666251001"
  ]
}

headers = {
  'Content-Type': 'application/json'
}

response = requests.post(url, json=payload, headers=headers)

print(response.text.encode('utf8'))
curl --location --request POST '{{apiUrl}}/waInstance{{idInstance}}/forwardMessages/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "10000000",
    "chatIdFrom": "10000001",
    "messages": [
        "1769666251000", 
        "1769666251001", 
        "1769666251002"
    ]
}'