Get a specific message information
This endpoint will let you get information about a message you sent or received using 2Chat.
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 |
Obtaning message information
Assuming you want to obtain information about 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 get it, you must make a GET request to:
https://api.p.2chat.io/open/whatsapp/message/WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us/MSG205dec10-523d-4ab3-b739-fd56e7cdeba2
.
Every time you make a request to send a message using this API, we reply with the message's UUID. You can store and use this value later to obtain information about that message.
Invocation
- cURL
- Python
- NodeJS
- PHP
curl --location --request GET '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("GET", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = '';
var config = {
method: 'get',
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 => 'GET',
CURLOPT_HTTPHEADER => array(
'X-User-API-Key': 'your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
The API will return whether it succeded or not to queue the message for sending
{
"success": true,
"message": {
"id": "MSG205dec10-523d-4ab3-b739-fd56e7cdeba2",
"uuid": "MSG205dec10-523d-4ab3-b739-fd56e7cdeba2",
"session_key": "WW-WPN66037eca-9ad1-4c96-9eff-526a90a48c77-5215511112222@c.us",
"message": {
"text": "the content of the message"
},
"created_at": "2024-04-02T23:02:03Z",
"remote_phone_number": "+5215511112222",
"sent_by": "agent",
"is_from_flow_run": false,
"is_from_api": false,
"is_from_chatter": true,
"is_from_agent": false,
"wa_msg_id": "3A8AE0BEDA97E2F99557",
"wa_msg_ack": 3,
"sent": true,
"received": true,
"read": true,
"read_at": "2024-04-02T23:03:15Z",
}
}
Field | Description |
---|---|
id | The unique identifier of the message |
uuid | Same as id |
timestamp | Timestamp of the message in UTC |
session_key | The chat session key that corresponds to this message |
message | The payload of the message |
message.text | The text content of the message, if present |
message.media.url | The 2Chat-hosted media file URL sent or received |
message.media.type | The type of media message |
message.media.mime_type | The MIME type of the message |
remote_phone_number | The WhatsApp phone number of the other end of the conversation |
channel_phone_number | The WhatsApp phone number where the message arrived |
sent_by | Who sent the message. E.g.: api , agent , user |
is_from_flow_run | true if the message was sent by a flow reply |
is_from_api | true if the message was sent using 2Chat's API |
is_from_chatter | true if the message was sent by the remote party of the conversation, i.e., not you or an agent using 2Chat |
is_from_agent | true if the message was sent by you, any of your agents using 2Chat, or someone sending messages directly from the WhatsApp application |
wa_msg_id | Internal ID WhatsApp gave to this message on their network |
wa_msg_ack | 0 : message created, 1 : message sent, 2 : message received, 3 : message read |
sent | true if the message was sent |
received | true if the message was received by the recipient |
read | true if the recipient of the message read it, and has read notifications enabled |
read_at | Set to a UTC+0 date/time of when the message was read by the recipient |