Skip to content

SetDisappearingChat#

Test Postman

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
{{apiUrl}}/waInstance{{idInstance}}/setDisappearingChat/{{apiTokenInstance}}

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

Request parameters#

Parameter Type Mandatory Description
chatId string Yes Correspondent id
ephemeralExpiration integer Yes 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

HTTP code Error identifier Description
400 Bad Request
Validation failed
Validation error
400 Validation failed.
Details: 'value' must have at least 2 keys
Validation failed. Details: 'value' must have at least 2 keys
400 Internal Server Error
Validation failed.
Details: 'ephemeralExpiration' must be one of [0, 86400, 604800, 7776000]
Incorrect data for field ephemeralExpiration, valid values: 0, 86400, 604800, 7776000
500 Internal Server Error
interface conversion: interface {} is bool, not string
Invalid data type for field chatId

Request examples#

import requests
import json

url = "{{apiUrl}}/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 '{{apiUrl}}/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({{apiUrl}})
    .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({{apiUrl}})
    .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 apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
    url = "{{apiUrl}}/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