Delete a message
This endpoint will let you delete a message from 2Chat and from WhatsApp if the message was sent up to 15 days 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
.
caution
WhatsApp will only let you delete messages up to 15 days after you sent them
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"
}