Skip to content

GetAccountSettings#

Test Postman

The method is intended for getting information about a Telegram messenger account.

The method uses limits on the request rate per second.

Request#

To get information about a Telegram messenger account, you need to execute a request at:

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

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

Response#

Response fields#

Field Type Description
avatar string Link to the avatar of the Telegram messenger account
With the notAuthorized, blocked or starting statuses it will be empty
phone string Number of the Telegram messenger account
With the notAuthorized, blocked or starting statuses it will be empty
stateInstance string Instance state. Takes the values:
notAuthorized - The instance is not authorized
To authorize the instance, refer to the Before you start section
authorized - The instance is authorized
blocked - The instance has been permanently blocked. Read more about the status in the article
suspended - The account has temporary restrictions (a partial ban on sending messages). The restriction type is given in the suspendedType 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 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 to move to authorized
pendingPassword - To complete authorization, you need to send the two-factor authentication (2fa) password using the SendAuthorizationPassword method
chatId string Personal chat identifier of the Telegram messenger
Can be used to send messages to yourself, or passed to other users to receive messages
With the notAuthorized, blocked or starting statuses it will be empty
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
username string Public profile name that starts with the @ character
historySyncProgress integer Percentage of chat history synchronization on the instance

Response body example#

{
    "avatar": "https://4100.api.green-api.com/download/4100/PzBLVNDU6b7cVKfnn9roTFd8icThySLvm2oL.jpg",
    "phone": "79876543210",
    "stateInstance": "authorized",
    "chatId": "10000000",
    "historySyncProgress": 100,
    "username": "@username"
}

Response body example with the suspended status#

{
    "avatar": "https://4100.api.green-api.com/download/4100/PzBLVNDU6b7cVKfnn9roTFd8icThySLvm2oL.jpg",
    "phone": "79876543210",
    "stateInstance": "suspended",
    "chatId": "10000000",
    "historySyncProgress": 100,
    "username": "@username",
    "suspendedType": "shadow",
    "suspendedUntil": 1755675927
}

Errors#

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

Code examples#

import requests

#The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed

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

payload = {}
headers = {}

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

print(response.text.encode('utf8'))
<?php
//The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
$url = "{{apiUrl}}/waInstance{{idInstance}}/getAccountSettings/{{apiTokenInstance}}";

$options = array(
    'http' => array(
        'header' => "Content-Type: application/json\r\n",
        'method' => 'GET'
    )
);

$context = stream_context_create($options);

$response = file_get_contents($url, false, $context);

echo $response;
?>
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getAccountSettings/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/getAccountSettings/")
    .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("/getAccountSettings/")
    .append({{apiTokenInstance}});

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

System.out.println(response);
Sub GetAccountSettings()
    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}}/getAccountSettings/{{apiTokenInstance}}"

    Set http = CreateObject("WinHttp.WinHttpRequest.5.1")

    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
program GetAccountSettings;

{$APPTYPE CONSOLE}

uses
System.SysUtils,
System.Classes, System.Net.HttpClient, System.Net.URLClient, System.Net.HttpClientComponent;

var
HttpClient: TNetHTTPClient;
RequestHeaders: TNetHeaders;
Response: IHTTPResponse;
EndpointURL, ID_INSTANCE, API_TOKEN_INSTANCE: string;

begin
ID_INSTANCE := '110100001';
API_TOKEN_INSTANCE := 'd75b3a66374942c5b3c019c698abc2067e151558acbd451234';

EndpointURL := 'https://api.green-api.com/waInstance' + ID_INSTANCE + '/getAccountSettings/' + API_TOKEN_INSTANCE;

HttpClient := TNetHTTPClient.Create(nil);
RequestHeaders := [
    TNetHeader.Create('Content-Type', 'application/json')
];

try
    Response := HTTPClient.Get(EndpointURL, nil, RequestHeaders);

    if Response.StatusCode = 200 then
    Writeln('[Response]: ' + Response.ContentAsString)
    else
    Writeln('[ERROR ' + IntToStr(Response.StatusCode) + ']:' + Response.StatusText + '' + Response.ContentAsString);

    readln;
except
    on E: Exception do
    Writeln(E.ClassName, ': ', E.Message);
end;

HttpClient.Free;

end.