Delete a message
This endpoint will let you delete a message from 2Chat and from WhatsApp if the message was sent up to 60 hours ago.
Parameters
These are path parameters that should go in the URL you use to invoke the endpoint.
Parameter | Description | Example |
---|---|---|
Session Key | The session key the message belongs to | WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us |
Message UUID | The UUID of the message you want information from | MSG205dec10-523d-4ab3-b739-fd56e7cdeba2 |
Deleting a message you sent in a conversation
Assuming you want to delete a message you sent that has MSG205dec10-523d-4ab3-b739-fd56e7cdeba2
as UUID, and is part of the conversation
with session key WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us
. To delete it, you must make a DELETE request to:
https://api.p.2chat.io/open/whatsapp/message/WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us/MSG205dec10-523d-4ab3-b739-fd56e7cdeba2
.
WhatsApp will only let you delete messages up to 60 hours after you sent them
Deleting a message sent into a WhatsApp group
Deleting messages sent to a group depends on the configuration of the group and whether you are an administrator in such group, and/or if you are the author of the message.
- Administrators can delete any message including the ones they didn't send.
- Normal participants (non-administrators) can only delete messages they send.
If you are not an administrator in the group and you are trying to delete a message sent by someone else, 2Chat will let you process it locally and delete it from our database, but WhatsApp will silently accept the request but not delete the message from the conversation as you don't have the permissions to do so.
Invocation
- cURL
- Python
- NodeJS
- PHP
curl --location --request DELETE 'https://api.p.2chat.io/open/whatsapp/message/WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us/MSG205dec10-523d-4ab3-b739-fd56e7cdeba2' \
--header 'X-User-API-Key: your_api_key_here' \
--data-raw ''
import requests
url = "https://api.p.2chat.io/open/whatsapp/message/WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us/MSG205dec10-523d-4ab3-b739-fd56e7cdeba2"
payload = ""
headers = {
'X-User-API-Key': 'your_api_key_here'
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = '';
var config = {
method: 'DELETE',
url: 'https://api.p.2chat.io/open/whatsapp/message/WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us/MSG205dec10-523d-4ab3-b739-fd56e7cdeba2',
headers: {
'X-User-API-Key': 'your_api_key_here'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.p.2chat.io/open/whatsapp/message/WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us/MSG205dec10-523d-4ab3-b739-fd56e7cdeba2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'X-User-API-Key': 'your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
{
"success": true,
"message_uuid": "MSG205dec10-523d-4ab3-b739-fd56e7cdeba2",
"whatsapp_message_id": "3EB0AFC0D8DFCFAB08A4FB"
}