GetStateInstance#
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 end time of the restrictions is in the suspendedUntil response field of GetAccountSettings 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 |
Response body example#
{
"stateInstance": "authorized"
}
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