Skip to content

Set Disappearing Chat#

The method is aimed for changing settings of disappearing messages in chats. The standard settings of the application are to be used: 0 (off), 86400 (24 hours), 604800 (7 days), 7776000 (90 days).

Request#

To set settings, you have to execute a request at:

POST https://api.greenapi.com/waInstance{{idInstance}}/setDisappearingChat/{{apiTokenInstance}}

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

Request parameters#

Parameter Type Mandatory Description
chatId string Yes Correspondent id
ephemeralExpiration integer No Messages lifetime in chats, takes on the values in seconds: 0, 86400, 604800, 7776000

Request body example#

{
    "chatId": "71234567890@c.us",
    "ephemeralExpiration": 0
}

Response#

Response parameters#

Parameter Type Description
chatId string yes
disappearingMessagesInChat boolean Chat state (disappearing or plain), takes on the values: true, false
ephemeralExpiration integer Messages lifetime in chats, takes on the values in seconds: 0, 86400, 604800, 7776000

Response body example#

{
    "chatId": "712345678910@c.us",
    "disappearingMessagesInChat": false,
    "ephemeralExpiration": 0
}

SetDisappearingChat errors#

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

Request examples#

import requests
import json

url = "https://api.greenapi.com/waInstance{{idInstance}}/setDisappearingChat/{{apiTokenInstance}}
"
payload = json.dumps({
  "chatId": "712345678910@c.us",
  "ephemeralExpiration": 0
})
headers = {
  'Content-Type': 'application/json'
}

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

print(response.text)
curl --location 'https://api.green-api.com/waInstance{{idInstance}}/setDisappearingChat/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "79851150769@c.us",
    "ephemeralExpiration": 0
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/setDisappearingChat/")
    .append({{apiTokenInstance}});

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

var jsonBody = "{\"chatId\": \"71234567890@c.us\",\"ephemeralExpiration\": 0}";

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("/setDisappearingChat/")
    .append({{apiTokenInstance}});

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

System.out.println(response);
Sub SetDisappearingChat()
    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 = "https://api.greenapi.com/waInstance{{idInstance}}/setDisappearingChat/{{apiTokenInstance}}"

    ' ChatId — ID of the chat in which you need to change the settings (@c.us for private chats, @g.us for group chats), ephemeralExpiration - Message lifetime in seconds, takes values: 0, 86400, 604800, 7776000
    RequestBody = "{""chatId"":""70123456789@c.us"", ""ephemeralExpiration"": ""0""}"

    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