Edit a text message

Edit the content of a previously sent text message.

PUT
https://api.wawp.net/v2/messages/edit?access_token=YOUR_ACCESS_TOKEN&chatId=201234567890%40c.us&instance_id=123456789&messageId=true_..._...&text=Updated+message+text

Authentication Required

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

Log In
Test /v2/messages/edit endpoint
PUT
PUT

No query parameters required

This endpoint doesn't expect data in the URL.

Best practices

  • Store the 'sentAt' timestamp to proactively manage the 15-minute edit window in your UI.

  • Use edits to update 'Status' messages instead of sending new messages for every state change.

  • Always handle 'message.edited' webhooks to keep your local CRM synced with the latest version of the text.

Precision Correction: Mastering the Message Editing Lifecycle

The /v2/messages/edit endpoint allows your application to maintain a high standard of professional communication by correcting errors post-transmission. In a business context, an "Edited" label is significantly more professional than deleting a message and re-sending it, as it preserves the conversational thread while ensuring data accuracy. However, editing is a time-bound and type-constrained operation that requires careful orchestration.


🏗️ Technical Logic of an Edit Operation

When you submit an edit request, the Wawp engine initiates a specialized state update:

  1. Integrity Check: The engine verifies that the messageId was sent by the current instance and that the current time is within the allowed window.
  2. Update Broadcast: A "Message Edit" packet is sent to the WhatsApp network.
  3. Client-Side Hydration: The recipient's device receives the update and replaces the old body with the new one, adding the mandatory "Edited" disclaimer next to the timestamp.

🚀 Advanced Strategic Implementation

1. The "Zero-Downtime" Bot Correction

If your AI bot sends a message that contains a factual error (e.g., a wrong appointment date or pricing):

  • Scenario: The bot detects the error 5 seconds after sending via an internal validation check.
  • Improved UX: Instead of deleting the message (which creates a "deleted" placeholder), call /v2/messages/edit immediately. For the user, it looks like a seamless update, maintaining the flow of the interaction.

2. Live Pricing and Status Updates

For e-commerce integrations, you can use edits to show "Real-Time" status in a single message.

  • Workflow: Send a message like: "Payment Status: Pending...". Once the transaction clears, edit the same message to say "Payment Status: ✅ Success". This prevents chat clutter and provides a single "Source of Truth" for the customer.

🛡️ Best Practices for Message Integrity

  • The 15-Minute Rule: WhatsApp typically allows edits for only 15 minutes after the original message was sent. Your system should track the sentAt timestamp and hide "Edit" buttons in your agent UI once this window closes.
  • Media Caption Constraints: Currently, the primary support is for Text-only messages. Some engine versions may allow editing captions of images/videos, but for maximum reliability, assume that only the type: text messages can be modified.
  • Avoid Substantial Semantic Changes: Use edits for typos, formatting, and minor data corrections. Avoid changing the "intent" of a message significantly (e.g., changing "Yes, I agree" to "No, I disagree") as this can confuse users and undermine conversational trust.

🧩 Advanced Use Case: The "Thinking" Indicator

Build a sophisticated AI interaction:

  1. Initial Message: Send "Please wait, I am generating your report... ⏳".
  2. Process: Run your background AI logic.
  3. Final Edit: Once the result is ready, edit the initial message to contain the full report text. This creates a "dynamic" feeling in the interaction and keeps the history clean.

⚠️ Important Considerations

  • Notification Behavior: Note that edited messages usually do not trigger a second "New Message" notification or ping on the recipient's phone. If the user isn't currently looking at the chat, they might miss the correction unless you send a follow-up.
  • Revision History: While the official WhatsApp app only shows the "current" edited version, some unofficial clients or historical logs might still contain the original text. Never use edits to "hide" sensitive information that was accidentally sent—use /v2/messages/delete for security-related removals.
  • Read State Persistence: Editing a message does not affect its "Seen" (blue tick) status. If it was already read, it remains read.

Summary of Capabilities:

  • Programmatic editing of previously sent text messages.
  • seamless UI updates via the "Edited" label protocol.
  • Preserves conversation thread continuity without deletion artifacts.
  • Ideal for bot self-correction and real-time status updates.

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:
string

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

Command Palette

Search for a command to run...