[go: up one dir, main page]

Skip to content

ForwardMessages#

Test Postman

The method is intended for forwarding messages to a personal or group chat. The forwarded messages will be added to the send queue. The message will be kept for 24 hours in the queue and will be sent immediately after phone authorization. The rate at which messages are sent from the queue is managed by Message sending delay parameter.

Request#

For forwarding, you need to make a request to:

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

For apiUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
chatId string Yes Chat Id, where the message is forwarded
chatIdFrom string Yes Chat Id, from which the message is being forwarded
messages array Yes Collection of IDs of forwarded messages

Request body example#

Forwarding a message to a chat:

{
    "chatId": "11001234567@c.us",
    "chatIdFrom": "11001234567@c.us",
    "messages": [
       "BAE587FA1CECF760",
       "BAE5608BC86F2B59"
    ]
}

Response#

Response parameters#

Parameter Type Description
messages array Ids of sent messages

Response body example#

{
  "messages": [
    "BAE5DBB8DEABDA22",
    "BAE5BBA9BE3142D8"
  ]
}

Recipient display example#

Example of a forwarded message

ForwardMessages errors#

For a list of errors common to all methods, refer to 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. Field messages must not be empty.

Sending with invalid messages ID

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

Request examples#

import requests   

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

payload = {
  "chatId": "11001234567@c.us",
  "chatIdFrom": "11001234567@c.us",
  "messages": [
    "BAE587FA1CECF760",
    "BAE5608BC86F2B59"
  ]
}

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": "11001234567@c.us",
    "chatIdFrom": "11001234567@c.us",
    "messages": [
        "BAE587FA1CECF760",
        "BAE5608BC86F2B59"
    ]
}'