Skip to content

ReadChat#

The method is aimed for marking messages in a chat as read. Either all messages or a specified message in a chat can be marked as read.

Request#

To mark messages in a chat as read, you have to execute a request at:

POST {{APIUrl}}/waInstance{{idInstance}}/readChat/{{apiTokenInstance}}

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

Request parameters#

Parameter Type Mandatory Description
chatId string Yes Chat Id
idMessage string No ID of the incoming message to be marked as read. If not specified, then all unread messages in the chat will be marked as read.

Request body example#

Read mark of a single message in the chat:

{
    "chatId": "11001234567@c.us",
    "idMessage": "B275A7AA0D6EF89BB9245169BDF174E6"
}

Read mark of all messages in the chat:

{
    "chatId": "11001234567@c.us"
}

Response#

Response parameters#

Parameter Type Description
setRead boolean Messages read mark flag

Response body example#

{
    "setRead": true
}

ReadChatMessage errors#

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

Request examples#

import requests

url = "{{APIUrl}}/waInstance{{idInstance}}/readChat/{{apiTokenInstance}}"

payload = "{\r\n\t\"chatId\": \"11001234567@c.us\",\r\n\t\"idMessage\": \"B275A7AA0D6EF89BB9245169BDF174E6\"\r\n}\r\n"
headers = {
  'Content-Type': 'application/json'
}

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

print(response.text.encode('utf8'))
curl --location '{{APIUrl}}/waInstance{{idInstance}}/readChat/{{apiTokenInstance}}
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "79001234567@c.us",
    "idMessage": "B275A7AA0D6EF89BB9245169BDF174E6"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/readChat/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\"chatId\": \"11001234567@c.us\",\"idMessage\": \"BAE5F4886F6F2D05\"}";

var requestEntity = new HttpEntity<>(jsonBody, headers);

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/readChat/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"chatId\": \"11001234567@c.us\",\"idMessage\": \"BAE5F4886F6F2D05\"}")
    .asString();

System.out.println(response);
Sub ReadChat()
    Dim url As String
    Dim RequestBody 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}}/readChat/{{apiTokenInstance}}"

    ' chatId - chat in which messages will be read (@c.us for private chats, @g.us for group chats)
    RequestBody = "{""chatId"":""71234567890@c.us""}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    With http
        .Open "POST", url, False
        .setRequestHeader "Content-Type", "application/json"
        .send RequestBody
    End With

    response = http.responseText

    Debug.Print response

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

    Set http = Nothing
End Sub