Skip to content

CallsState#

Temporary limitations

The Ultra plan, for unlimited calls, can only be connected for new instances. For questions about connecting to the plan and additional conditions, please write to the GREEN-API technical support or to the chat on the website.
At the moment only individual calls are available.

The method is used to get the current call state.

This is the same state that arrives in the callsRtc connection in a message of type state. The method is needed when you have to find out the state outside the connection — for example, to check whether a call is in progress before connecting to callsRtc.

Request#

To get the call state, you have to execute a request at:

GET
{{apiUrl}}/waInstance{{idInstance}}/callsState/{{apiTokenInstance}}

The request is executed without parameters.

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

Response#

Response parameters#

Parameter Type Description
state string Call state. Takes the values:
idle — no call
inc-call — an incoming call has arrived
out-call — an outgoing call is being dialed
on-call — the conversation is in progress
info object Call and other party data: id, wid, name. Returned in the inc-call, out-call and on-call states. The fields are described in the info object section
reason string Reason for ending the call. Returned only in the idle state and only if the server has specified it. The list of values is given in the Reasons for ending a call section

Response body example#

No call:

{
    "state": "idle"
}

Errors#

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

Request examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/callsState/{{apiTokenInstance}}"

payload = {}
headers = {}

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

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/callsState/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/callsState/")
    .append({{apiTokenInstance}});

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.GET, null, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/callsState/")
    .append({{apiTokenInstance}});

var response = Unirest.get(requestUrl.toString())
    .header("Content-Type", "application/json")
    .asString();

System.out.println(response);