The method allows you to obtain the current status of a previously sent message (delivered, read, sending, etc.). This is useful for tracking the delivery progress of important messages and analytics of interactions with your customers. The method can be used in integrations to update the statuses of sent notifications in your system.
Also there is a mechanism WebHook that allows you to receive messages and their statuses online in your system, without API requests.
Supported Messengers
The API method for getting message status is available for messengers: WhatsApp, MAX Personal, Telegram Personal, Telegram Bot.
Example request:
GET https://wamm.chat/api2/msg_state/{token}/?msg_id={msg_id} or GET https://wamm.chat/api2/msg_state/{token}/{msg_id} Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | API token obtained in settings |
| msg_id | integer | Yes | Message identifier obtained when sending |
Success Response
{
"err": 0,
"msg_data": {
"msg_id": "1234567",
"phone": "79001234567",
"state": "viewed"
}
} Response Field Description
| Field | Description |
|---|---|
| msg_id | Message identifier |
| phone | Recipient phone number |
| state | Message status (deleted, viewed, delivered, not sent, sent, failed, noAccount, notInGroup and others) |
Possible Errors
| Error Code | Description |
|---|---|
| token fail | Error in token |
| acc not authorized | Connection not authorized |
| msg_id fail | Error in message id |
| msg not be | Message not found |
Usage Examples
curl -X GET "https://wamm.chat/api2/msg_state/YOUR_TOKEN/?msg_id=1234567" function getMessageStatus($token, $msg_id) {
// Prepare the request URL
$url = "https://wamm.chat/api2/msg_state/$token/?msg_id=$msg_id";
// Execute the request
$response = file_get_contents($url);
// Process the response
if ($response !== false) {
// Decode the response into an array
$json_response = json_decode($response, true);
// Check for errors
if (isset($json_response['err'])) {
if ($json_response['err'] == 0 && isset($json_response['msg_data'])) {
$status = $json_response['msg_data']['state'];
echo "Message status: " . $status;
return $status;
} else {
echo "Error: " . $json_response['err'];
return null;
}
} else {
echo "Failed to process the server's response";
return null;
}
} else {
echo "Failed to make a request to the server";
return null;
}
}
// Use the function to get the message status
$token = "YOUR_TOKEN";
$msg_id = 1234567;
$status = getMessageStatus($token, $msg_id);
// Process the status
if ($status !== null) {
switch ($status) {
case 'sending':
echo "Message is being sent";
break;
case 'viewed':
echo "Message viewed";
break;
case 'received':
echo "Message received";
break;
case 'delivered':
echo "Message delivered";
break;
case 'not sent':
echo "Message not sent";
break;
case 'deleted':
echo "Message deleted";
break;
default:
echo "Message status: " . $status;
}
}