Skip to content

GetChats#

The method is aimed for getting a list of chats of the current account in chronological order.

Request#

To get a list of chats of the current account, you have to execute a request at:

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

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

Request parameters#

Parameter Type Mandatory Description
count integer No The number of chats sorted by chat activity time. This information is updated no more than once every minute

Response#

Response parameters#

Parameter Type Description
archive boolean The flag indicates whether the chat is archived or not
id string Chat Id
79001234567 - automatically converted to a number
79001234567@c.us - phone number
ephemeralExpiration integer Messages lifetime in chats, takes on the values in seconds: 0, 86400, 604800, 7776000
ephemeralSettingTimestamp integer Event occurrence time in UNIX format
name string Contact name
type string Contact type. Possible values:
user - contact belongs to a user

Response body example#

[
    {
        "archive": false,
        "id": "79876543210@c.us",
        "ephemeralExpiration": 86400,
        "ephemeralSettingTimestamp": 1777870423,
        "name": "John Doe",
        "type": "user"
    },
    {
        "archive": false,
        "id": "79001234567@c.us",
        "ephemeralExpiration": 0,
        "ephemeralSettingTimestamp": 0,
        "name": "Jane Doe",
        "type": "user"
    }
]

GetChats errors#

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

HTTP code Error description Possible solutions
200 The GetChats method returns an empty array [] Contact the support service.

Request examples#

import requests

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

payload = {}
headers= {}

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

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

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

System.out.println(response);
Sub GetChats()
    Dim url 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}}/getChats/{{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