Skip to content

CheckWhatsapp#

The method checks WhatsApp account availability on a phone number.

Request#

To check WhatsApp account availability, you have to execute request at:

POST {{APIUrl}}/waInstance{{idInstance}}/checkWhatsapp/{{apiTokenInstance}}

For APIUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
phoneNumber integer Yes Recipient's phone number in international format: 11 or 12 digits; Example: 11001234567 or 380123456789

Request body example#

{
    "phoneNumber": 11001234567
}

Response#

Response parameters#

Parameter Type Description
existsWhatsapp boolean Flag of WhatsApp availability on a phone number

Response body example#

{
    "existsWhatsapp": true
}

CheckWhatsapp errors#

For a list of errors common to all methods, refer to Common errors section

HTTP code Error Id Description
400 bad phone number, valid 11 or 12 digits Invalid phone number format, must be 11 or 12 digits
400 check phone number timeout limit exceeded The timeout for a response to check a phone number has been exceeded
400 instance is starting or not authorized The instance is starting or is not authorized

Request examples#

import requests
import json

url = "{{APIUrl}}/waInstance{{idInstance}}/checkWhatsapp/{{apiTokenInstance}}"

payload = json.dumps({ "phoneNumber": 441234567890 })
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
curl --location '{{APIUrl}}/waInstance{{idInstance}}/checkWhatsapp/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data '{
    "phoneNumber": 441234567890
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/checkWhatsapp/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\"phoneNumber\": 441234567890}";

var requestEntity = new HttpEntity<>(jsonBody, headers);

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/checkWhatsapp/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"phoneNumber\": 441234567890}")
    .asString();

System.out.println(response);
Sub CheckWhatsapp()
    Dim url As String
    Dim RequestBody As String
    Dim http As Object
    Dim response As String

    ' The idInstance and apiTokenInstance values are available in your account, double brackets must be removed
    url = "{{APIUrl}}/waInstance{{idInstance}}/CheckWhatsapp/{{apiTokenInstance}}"

    ' chatId - is the number to check whatsapp
    RequestBody = "{""phoneNumber"":""71234567890""}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    With http
        .Open "POST", url, False
        .setRequestHeader "Content-Type", "application/json"
        .Send RequestBody
    End With

    response = http.responseText

    Debug.Print response

    ' Outputting the answer to the desired cell
    Range("A1").Value = response

    Set http = Nothing
End Sub