Get message by id

Retrieve a specific message by its ID.

POST
https://api.wawp.net/v2/messages/get?access_token=YOUR_ACCESS_TOKEN&chatId=201234567890%40c.us&downloadMedia=true&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/get endpoint
POST
POST

No query parameters required

This endpoint doesn't expect data in the URL.

Best practices

  • Store the messageId in your own database as the primary key for all interactions.

  • Check the 'ack' field to track exactly when a message was delivered and read.

  • Use the 'downloadMedia' flag carefully to manage bandwidth and storage costs.

Precision Access: Mastering Pinpoint Message Retrieval

The /v2/messages/get endpoint is the most granular tool in the Wawp Chat Actions suite. While other endpoints handle lists and overviews, this endpoint is designed for high-fidelity retrieval of a single interaction. It is the primary mechanism for fetching message metadata, tracking status history, and performing "on-demand" media hydration without overloading your network with unnecessary binary data.


🏗️ Technical Workflow: The "Deep Probe" Logic

When you request a message by ID, the Wawp engine performs a targeted index lookup:

  1. Identity Verification: The engine uses the messageId (a unique cryptographic hash) to locate the exact entry in the local sharded database for the given chatId.
  2. State Reconstruction: It gathers not just the body text, but all associated metadata, including sender JID, timestamps, forwarding flags, and current ACK status (Delivered vs. Read).
  3. Media Decryption (Optional): If downloadMedia is enabled, the engine performs an "Active Fetch." It connects to the WhatsApp CDN, downloads the encrypted blob, decrypts it using the keys stored in your session, and returns the result as a Base64 string.

🚀 Optimized Strategic Patterns

1. The "Media on Click" Pattern

For high-performance dashboards, downloading media for every message is a significant performance bottleneck.

  • Workflow:
    1. Fetch the conversation history using /v2/chats/messages with downloadMedia: false.
    2. Render the message list. For images/videos, show a "Download" icon.
    3. When the user clicks the icon, call /v2/messages/get with downloadMedia: true.
  • Benefit: This "Lazy Hydration" approach minimizes bandwidth and CPU usage for both your server and the client's browser.

2. Post-Sent Verification

Use this endpoint to verify exactly what reached the WhatsApp network.

  • Logic: After sending a complex message (like a list or a template), capture the returned messageId. Call /v2/messages/get a few seconds later to verify that the structure was hdyrated correctly and check the current ack status.

🛡️ Best Practices for Identification

  • Handling Non-Existent IDs: If a messageId is incorrect or has been deleted from the phone's local database, the API will return a 404 Not Found. Ensure your application handles this gracefully by showing a "Message no longer available" state.
  • Media TTL (Time To Live): Remember that media files on WhatsApp's CDN are ephemeral (typically 30-90 days). If you try to fetch an old message with downloadMedia: true, the fetch might fail even if the text data is still available.
  • JID Scoping: Always provide the chatId. While message IDs are globally unique, providing the JID allows the engine to narrow its search to the correct conversation partition, improving response speed.

🧩 Advanced Use Cases

Message Interaction Tracking

Build an analytics dashboard.

  • Logic: Periodically call /v2/messages/get for important marketing messages to track the progression of the ack field (from 1=Sent to 2=Delivered to 3=Read). This allows you to calculate "Time to Open" metrics for your campaigns.

Forensic Auditing

In support scenarios where a customer claims a message contained specific info, use this endpoint to fetch the original record from the Wawp engine, bypassing any potential UI-level caching or local database inaccuracies. This ensures your audit trail is 100% consistent with the WhatsApp network state.


⚠️ Important Considerations

  • Base64 Payload Size: When downloading media, the JSON response can become quite large (e.g., several megabytes for a high-res video). Ensure your application layer can handle large JSON buffers.
  • Engine state: The instance must be in the WORKING state to perform network-level media downloads. Metadata retrieval from the local cache may work in other states but is most reliable when active.
  • Forwarded Messages: Pay attention to the contextInfo block in the response. It tells you if a message was a reply to another message or if it was forwarded, providing critical context for AI processing.

Summary of Capabilities:

  • Pinpoint retrieval of any message using its unique ID.
  • On-demand high-speed media downloading and decryption.
  • Comprehensive metadata access (timestamps, sender identity, status).
  • Essential for implementing efficient "Lazy Loading" in CRM UIs.

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

Whether to download and return media content

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/get";
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 "downloadMedia": "true"
11};
12
13fetch(`${baseUrl}${endpoint}${params ? '?' + params : ''}`, {
14 method: "POST",
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 TopicMark as read
Next TopicDelete a message

Command Palette

Search for a command to run...