This method allows you to check whether an account exists in the messenger using a specified phone number, nickname, or chat ID, depending on the identifier used in the messenger. It is especially useful for processing contact lists for filtering customers. Using this method helps avoid attempts to send messages to users who do not have messengers, improving analytics and reducing errors. If the contact is in the WAMM.chat database, the check passes; otherwise, an external request to the messenger is made.
When sending messages or files, this check is performed automatically; there is no need to call this method separately before sending.
Supported messengers
API method for checking messenger availability is available for: WhatsApp, MAX Personal, Telegram Personal, Telegram Bot.
Example request:
GET https://wamm.chat/api2/check_phone/{token}/?phone={phone} or
GET https://wamm.chat/api2/check_phone/{token}/{phone} Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | API token obtained in settings |
| phone | string | Yes | Phone number in international format (e.g., 79001234567). For Telegram you can specify a chat ID or username instead of a number, for MAX - a chat ID |
Success response
{"err":0,"result":"exists"} Possible values of the result parameter:
exists– messenger account existsnone– does not exist
Possible errors
| Error code | Description |
|---|---|
| token fail | Error in token |
| acc not authorized | Connection not authorized |
| fail execution | Check failed, retry |
Usage examples
curl -X GET "https://wamm.chat/api2/check_phone/YOUR_TOKEN/?phone=79001234567" function checkWhatsApp($token, $phone) {
// Prepare the request URL
$url = "https://wamm.chat/api2/check_phone/$token/?phone=$phone";
// Execute the request
$response = file_get_contents($url);
// Process the response
if ($response !== false) {
// Convert the response to an array
$json_response = json_decode($response, true);
// Check for errors
if (isset($json_response['err'])) {
if ($json_response['err'] == 0 && isset($json_response['result'])) {
echo "Check result: " . $json_response['result'];
return $json_response['result'] === 'exists';
} else {
echo "Error: " . $json_response['err'];
}
} else {
echo "Failed to process the server's response";
}
} else {
echo "Failed to make a request to the server";
}
return false;
}
// Use the function to check for WhatsApp presence
$token = "YOUR_TOKEN";
$phone = "79001234567";
$hasWhatsApp = checkWhatsApp($token, $phone);
if ($hasWhatsApp) {
echo "The number has WhatsApp";
} else {
echo "The number does not have WhatsApp or an error occurred";
}