EditMessage#
Beta version
The functionality is in beta. Features may change and may also work unstably.
The method is used to change the text of a sent message in an Instagram Direct chat.
Only your own text message can be edited. A message of the contact is rejected by the method with a 400 error. The period during which a message can be edited is set by Instagram.
The method uses the limits on the number of requests per second.
Request#
To change the text of a message, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{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 |
idMessage | string | Yes | The identifier of the message whose text is being changed |
message | string | Yes | The new text of the message. The maximum length is 1000 characters |
Request body example#
{
"chatId": "49547665464",
"idMessage": "32992354783594572492903878028689408",
"message": "The corrected text"
}
Response#
Response parameters#
| Field | Type | Description |
|---|---|---|
idMessage | string | The identifier of the edit event |
The edited message itself keeps the identifier passed in the request: in the journals it has the new text and the
isEditedflag. The identifier from the response arrives in theidMessagefield of theeditedMessagenotification.
Response body example#
{
"idMessage": "32992354783594572492903915434680320"
}
EditMessage 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: 'idMessage' is required | The message is not specified |
| 400 | Validation failed. Details: 'message' is required | The new text is not specified |
| 400 | Validation failed. Details: 'message' is not allowed to be empty | The new text is empty |
| 400 | message text is required | The new text consists of spaces only |
| 400 | Validation failed. Details: 'message' length must be less than or equal to 1000 characters long | The new text is longer than 1000 characters |
| 400 | Editing incoming messages not supported | The message was sent by the contact |
| 400 | Message by id not found | There is no such message in the specified chat |
| 400 | Message already was deleted | The message has been deleted |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}"
payload = {
"chatId": "49547665464",
"idMessage": "32992354783594572492903878028689408",
"message": "The corrected text"
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/editMessage/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "49547665464",
"idMessage": "32992354783594572492903878028689408",
"message": "The corrected text"
}'