Skip to content

GetStateInstance#

Test Postman

The method is intended for getting the instance state.

The method uses limits on the request rate per second.

Request#

To get the instance state, you need to execute a request at:

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

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Response#

Response fields#

Field Type Description
stateInstance string Instance state. Takes the values:
notAuthorized - The instance is not authorized. This status is also displayed while waiting for a code or password to be entered
authorized - The instance is authorized
blocked - The instance has been blocked. Read more about the suspended status in the article
suspended - The account has temporary restrictions (a partial ban on sending messages)
The restriction type is given in the suspendedType response field, the end time in the suspendedUntil field
Messages rejected because of the restrictions receive the suspended status in the Outgoing message status notification and in the journals
Read more about the suspended status in the article
starting - The instance is starting up (service mode)
The instance or the server is rebooting, or the instance is in maintenance mode
It may take up to 5 minutes for the instance state to change to authorized
pendingPassword - To complete authorization, you need to send the two-factor authentication (2fa) password using the SendAuthorizationPassword method
suspendedType string Restriction type. The field is present only when "stateInstance": "suspended". Takes the values:
real - The restrictions were imposed by Telegram (the account is frozen). They are lifted after Telegram unblocks the account
shadow - The restrictions were set by GREEN-API after Telegram rejected a message because of spam restrictions. They are lifted automatically when suspendedUntil expires (after 24 hours) or when the instance is rebooted with the Reboot method
suspendedUntil integer End time of the restrictions in UNIX format. The field is present only when "stateInstance": "suspended"
The value 0 means that Telegram did not report when the restrictions end

Response body example#

{
    "stateInstance": "authorized"
}

Response body example with the suspended status#

{
    "stateInstance": "suspended",
    "suspendedType": "shadow",
    "suspendedUntil": 1755675927
}

Errors#

For the list of errors common to all methods, see the Common errors section

HTTP code Error identifier Description
200 The instance has been in the starting state for a long time (more than 5 minutes) 1. Reboot the instance using the reboot method
2. Contact the technical support service

Code examples#

import requests

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

payload = {}
headers= {}

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

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getStateInstance/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/getStateInstance/")
    .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("/getStateInstance/")
    .append({{apiTokenInstance}});

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

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

    ' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
    url = "{{apiUrl}}/waInstance{{idInstance}}/getStateInstance/{{apiTokenInstance}}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    http.Open "GET", url, False
    http.Send

    response = http.responseText

    Debug.Print response

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

    Set http = Nothing
End Sub