Skip to content

GetChats#

Test Postman Apidog

The method is designed to get 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 apiUrl, idInstance and apiTokenInstance 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 User or group chat Id. The request must include only one field, either chatId or phoneNumber. Acceptable formats:
79001234567 - automatically converted to a number
79001234567@c.us - phone number
123456789012345@lid - lid- identifier
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 or group name
type string Contact type. Possible values:
user - contact belongs to a user
group - contact is a group chat

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"
    },
    {
        "archive": false,
        "id": "79001234567-1479621234@g.us",
        "ephemeralExpiration": 0,
        "ephemeralSettingTimestamp": 0,
        "name": "My Group",
        "type": "group"
    }
]

GetChats errors#

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

HTTP code Error identifier Description
200 The GetChats method returns an empty array [] Contact technical support.

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 apiUrl, idInstance and apiTokenInstance values are available in console, 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