Delete a message

Delete a specific message by its ID.

DELETE
https://api.wawp.net/v2/messages/delete?access_token=YOUR_ACCESS_TOKEN&chatId=201234567890%40c.us&instance_id=123456789&messageId=true_..._...

Authentication Required

Login to swap the placeholders with your real Instance ID and Access Token.

Log In
Test /v2/messages/delete endpoint
DELETE
DELETE

No query parameters required

This endpoint doesn't expect data in the URL.

Best practices

  • Store the message timestamp locally to check if 'Delete for Everyone' is still feasible.

  • Use deletion to maintain group safety by removing spam or inappropriate content automatically.

  • Always handle the 'message.revoked' webhook to keep your external CRM in sync with deletions.

Controlled Erasure: Mastering the Message Deletion Lifecycle

In a professional messaging ecosystem, the ability to remove content is just as important as the ability to send it. The /v2/messages/delete endpoint provides a programmatic way to invoke WhatsApp's deletion protocols. However, deletion is not a simple "remove" command; it is a complex negotiation between your instance, the WhatsApp network, and the recipient's device states.


🏗️ Technical Logic: "Delete for Everyone" vs. "Delete for Me"

WhatsApp distinguishes between local and network-wide deletion. Wawp attempts to execute the most effective deletion based on the context:

  1. Delete for Everyone (Network-Wide):
    • The Signature: The original message is replaced by a system placeholder: "This message was deleted".
    • The Handshake: Your instance sends a "Revocation" packet. The WhatsApp server then broadcasts this to all active recipients.
    • Constraint: This only works if the message was sent by your instance and is within the ~48-hour window.
  2. Delete for Me (Local Cleanup):
    • If the time limit has passed, or if you are deleting a message sent by someone else (and you are not a group admin), the deletion is local. The message disappears from your Wawp instance and linked devices, but remains visible to the sender and other recipients.

🚀 Strategic Use Cases for Deletion

1. Compliance and Data Privacy (GDPR)

If a customer exercises their "Right to Erasure," you must remove their messages.

  • Workflow: Identify all messageId strings associated with the customer's JID in your local database and iterate through them using this endpoint to ensure they are removed from the Wawp engine's storage.

2. Correcting Bot Hallucinations

If an AI bot sends incorrect information (e.g., a wrong price or private data):

  • Immediate Action: Call the delete endpoint for that messageId within seconds. Even if the user saw the notification, removing the content prevents it from being archived or used as a reference point later.

3. Group Moderation

As a Group Admin, your Wawp instance has the power to "Delete for Everyone" regardless of who sent the message.

  • Implementation: Build a "Profanity Filter." When a webhook detects a message with blacklisted words, automatically trigger a deletion to keep the group professional and safe.

🛡️ Best Practices for Effective Cleanup

  • The 48-Hour Threshold: Always log the timestamp of outgoing messages. Do not attempt a "Delete for Everyone" UI action if the message is older than 48 hours, as the API will likely fallback to a local delete, which might confuse your agents.
  • Handle "Ghost" Messages: Occasionally, a deletion packet might reach a recipient's phone while it's offline. When they reconnect, the message might briefly appear before being deleted. This is a network-level behavior; your system should handle the message.revoked webhook to update your local CRM UI.
  • Media Persistence: Deleting a message that contained media typically removes the pointer to that media. However, if the recipient has "Auto-Download to Gallery" enabled on their phone, the file may still exist in their physical phone storage even after being "deleted for everyone."

🧩 Advanced Use Case: The "Secret" Handover

In high-security support scenarios, you might need to send a temporary credential or link.

  • Logic: Send the message, wait for the message.ack (blue tick), and then automatically call the delete endpoint after 60 seconds. This ensures the data is only available during the active interaction window.

⚠️ Important Considerations

  • Admin Requirements: You MUST be an admin to delete messages sent by others in a group. Use /v2/groups/participants to verify your status.
  • Linked Devices Sync: Deletions are high-priority sync events. They will propagate to your WhatsApp Web and Mobile instances almost instantly.
  • No "Undo": Once a message is deleted for everyone, there is no "undelete" action. Always implement a "Confirm Deletion" step in your human-agent UI.

Summary of Capabilities:

  • Programmatic "Delete for Everyone" (within the WhatsApp time window).
  • Local "Delete for Me" for history management and hygiene.
  • Administrative deletion of participant messages in group chats.
  • Full integration with Webhooks to track revocation status.

Request Parameters

Configure the parameters required to interact with this endpoint. All query and body arguments are listed below with their details.

Request Body

Sent as a JSON object
string

WhatsApp Instance ID

Example:
string

API Access Token

Example:
string

Target Chat ID (phone@c.us or group@g.us)

Example:
string

Unique ID of the message

Example:

Request Samples

Use these ready-to-go code snippets to integrate our API into your project quickly and efficiently. Choose your preferred language and library.

1const baseUrl = "https://api.wawp.net";
2const endpoint = "/v2/messages/delete";
3const params = new URLSearchParams({
4 "instance_id": "123456789",
5 "access_token": "YOUR_ACCESS_TOKEN",
6 "chatId": "201234567890@c.us",
7 "messageId": "true_..._..."
8}).toString();
9
10
11fetch(`${baseUrl}${endpoint}${params ? '?' + params : ''}`, {
12 method: "DELETE",
13 headers: { "Content-Type": "application/json" },
14
15})
16 .then(async (response) => {
17 if (response.ok) {
18 const data = await response.json();
19 console.log("Success:", data);
20 return data;
21 }
22
23 // Error Handling
24 if (response.status === 400) {
25 console.error("Error 400: Bad Request - Missing Required Parameter(s)");
26 }
27 if (response.status === 400) {
28 console.error("Error 400: Bad Request (XML Format)");
29 }
30 if (response.status === 400) {
31 console.error("Error 400: Bad Request (Plain Text)");
32 }
33 if (response.status === 401) {
34 console.error("Error 401: Unauthorized - Invalid or Missing Access Token");
35 }
36 if (response.status === 401) {
37 console.error("Error 401: Unauthorized (XML Format)");
38 }
39 if (response.status === 404) {
40 console.error("Error 404: Not Found - Session Does Not Exist");
41 }
42 if (response.status === 404) {
43 console.error("Error 404: Not Found (XML Format)");
44 }
45 if (response.status === 500) {
46 console.error("Error 500: Internal Server Error - Unexpected Failure");
47 }
48 if (response.status === 500) {
49 console.error("Error 500: Internal Server Error (HTML)");
50 }
51 if (response.status === 502) {
52 console.error("Error 502: Bad Gateway - Connection Failed to Upstream");
53 }
54 if (response.status === 502) {
55 console.error("Error 502: Bad Gateway (XML Format)");
56 }
57
58 const errorText = await response.text();
59 console.error(`Error ${response.status}: ${errorText}`);
60 })
61 .catch((error) => console.error("Network Error:", error));
Interactive Samples
Ln 61, Col 1javascript

Expected Responses

Explore all possible responses and outcomes from the server. We have documented each status code with data examples to make success and error handling easier.

Success - Request completed successfully
Type:
application/json
boolean *
string *

Example

{
"success": true,
"message": "Operation completed successfully"
}
Bad Request - Missing Required Parameter(s)
Unauthorized - Invalid or Missing Access Token
Not Found - Session Does Not Exist
Internal Server Error - Unexpected Failure
Bad Gateway - Connection Failed to Upstream
Previous TopicGet message by id
Next TopicEdit a text message

Command Palette

Search for a command to run...