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 https://api.greenapi.com/waInstance{{idInstance}}/readChat/{{apiTokenInstance}}
For 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 = "https://api.greenapi.com/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 'https://api.green-api.com/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);