deleteMessage#
The method deletes a message from a chat.
Request#
To delete a message, you have to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/deleteMessage/{{apiTokenInstance}}
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
chatId | string | Yes | User or group chat Id |
idMessage | string | Yes | Deleted message ID |
Request body example#
{
"chatId": "120363043968066561@g.us",
"idMessage": "BAE5F4886F6F2D05"
}
Response#
Response parameters#
The response body is empty. If successful, the server response is 200.
DeleteMessage 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 | Message by id not found | Missing message field or the message has already been deleted |
500 | Internal Server Error interface conversion: interface {} is bool, not string | Invalid data type specified for field chatId |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/deleteMessage/{{apiTokenInstance}}"
payload = "{\r\n \"chatId\": \"120363043968066561@g.us\, \"idMessage\": \"BAE5F4886F6F2D05\" \"r\n}"
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/deleteMessage/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "79123456789@c.us",
"idMessage": "BAE5F4886F6F2D05"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/deleteMessage/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\"chatId\": \"79123456789@c.us\",\"idMessage\": \"BAE5F4886F6F2D05\"}";
var requestEntity = new HttpEntity<>(jsonBody, headers);
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/deleteMessage/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\"chatId\": \"79123456789@c.us\",\"idMessage\": \"BAE5F4886F6F2D05\"}")
.asString();
System.out.println(response);
Sub deleteMessage()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/deleteMessage/{{apiTokenInstance}}"
' ChatId — the number from which you want to delete the message (@c.us for private chats, @g.us for group chats); idMessage - identifier of the message that needs to be deleted
RequestBody = "{""chatId"":""70123456789@c.us"",""idMessage"":""BAE5F4886F6F2D05""}"
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/json"
.Send RequestBody
End With
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
Range("A1").Value = response
Set http = Nothing
End Sub