Skip to content

SetSettings#

The method is aimed for setting account settings.

When this method is requested, the account is rebooted.

The settings are applied within 5 minutes after invoking the setSettings method.

Request#

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

POST {{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}

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

Request parameters#

Selective specification of parameters is allowed. At least one parameter must be specified.

Parameter Type Mandatory Description
webhookUrl string No URL for sending notifications. If it is required to disable getting notifications, then specify an empty string. When receiving notifications with HTTP API technology, the field must be empty. Description of how the field works.
webhookUrlToken string No Token to access your notification server, if not required, then specify an empty string. Description of how the field works.
sharedSession string No Deprecated
countryInstance string No Deprecated
outgoingWebhook string No Get notifications about outgoing messages sending/delivering/reading statuses, possible variants: yes,no. noAccount and failed statuses cannot be disabled, it is necessary to implement the processing of this notification
outgoingMessageWebhook string No Deprecated
outgoingAPIMessageWebhook string No Get notifications about messages sent from API, possible variants: yes,no. When sending a message to a non-existing WhatsApp account, the notification will not come.
stateWebhook string No Deprecated
incomingWebhook string No Get notifications about incoming messages and files, possible variants: yes,no
deviceWebhook string No Deprecated
statusInstanceWebhook string No Deprecated
enableMessagesHistory string No Deprecated
keepOnlineStatus string No Deprecated
pollMessageWebhook string No Deprecated
incomingBlockWebhook string No Deprecated
incomingCallWebhook string No Deprecated

General request body example#

{
    "webhookUrl": "https://mysite.com/webhook/greenwaba/",
    "webhookUrlToken": "",
    "outgoingWebhook": "yes",
    "outgoingAPIMessageWebhook": "yes",
    "incomingWebhook": "yes",
}

Response#

Response parameters#

Parameter Type Description
saveSettings boolean Flag that the settings are saved

Response body example#

{
    "saveSettings": true
}

SetSettings errors#

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

Request examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}"

payload = "{\r\n\t\"webhookUrl\": \"https://mysite.ru\",\r\n\t\"delaySendMessagesMilliseconds\": 1000,\r\n\t\"markIncomingMessagesReaded\": \"no\",\r\n\t\"outgoingWebhook\": \"yes\",\r\n\t\"stateWebhook\": \"no\",\r\n\t\"incomingWebhook\": \"yes\",\r\n\t\"deviceWebhook\": \"no\"\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}}/setSettings/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data '{
    "delaySendMessagesMilliseconds": 15000
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/setSettings/")
    .append({{apiTokenInstance}});

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

var jsonBody = "{\"delaySendMessagesMilliseconds\": 15000}";

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

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\"delaySendMessagesMilliseconds\": 15000}")
    .asString();

System.out.println(response);
Sub SetSettings()
    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}}/SetSettings/{{apiTokenInstance}}"

    ' parameters obtained by the GetSettings method that need to be changed
    RequestBody = "{""webhookUrl"":"""",""delaySendMessagesMilliseconds"":""1000"",""markIncomingMessagesReaded"":""yes"",""outgoingWebhook"":""yes"",""stateWebhook"":""no"",""incomingWebhook"":""yes"",""incomingBlockWebhook"":""yes""}"

    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