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.

After creating an instance, all settings are turned off by default.

Request#

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

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

For apiUrl, idInstance and apiTokenInstance 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.
delaySendMessagesMilliseconds integer No Message sending delay is in milliseconds. Minimum value is 500 msec.
Maximum value 86400000 msec
markIncomingMessagesReaded string No Mark incoming messages as read or not, possible variants: yes,no. Ignored if markIncomingMessagesReadedOnReply is 'yes'.
markIncomingMessagesReadedOnReply string No Mark incoming messages as read when posting a message to the chat via API, possible variants: yes,no. If it is 'yes', then the markIncomingMessagesReaded setting is ignored.
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 Get notifications about messages sent from the phone, possible variants: yes,no
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 Get notifications about the account authorization state change, possible variants: yes,no
incomingWebhook string No Get notifications about incoming messages and files, possible variants: yes,no
deviceWebhook string No Get notifications about the device (phone) and battery level, possible variants: yes,no
statusInstanceWebhook string No Deprecated
enableMessagesHistory string No Deprecated
keepOnlineStatus string No Sets the 'Online' status for your account
pollMessageWebhook string No Get notifications about the creation of a poll and voting in the poll, possible variants: yes, no
incomingBlockWebhook string No Temporarily not working. Get notifications about adding a chat to the list of blocked contacts, possible variants: yes, no
incomingCallWebhook string No Get notifications about incoming call statuses, possible variants: yes, no

Applying settings

To receive notifications regarding the statuses of sending/delivery/read receipts of messages sent from a mobile phone, it is necessary to enable the following settings:

  • outgoingMessageWebhook
  • outgoingWebhook

To receive notifications about the statuses of an incoming call, it is necessary to enable the following settings:

  • incomingCallWebhook
  • incomingWebhook

The pollMessageWebhook setting is activated only when the following parameters are enabled:

  • outgoingAPIMessageWebhook for messages sent via the API
  • outgoingMessageWebhook for messages sent from the phone
  • incomingWebhook for incoming messages

If your phone and linked devices are turned off, you need to enable the setting:

  • keepOnlineStatus to set the Online status for your account and send the message status delivered

General request body example#

{
    "webhookUrl": "https://mysite.com/webhook/green-api/",
    "webhookUrlToken": "",
    "delaySendMessagesMilliseconds": 5000,
    "markIncomingMessagesReaded": "no",
    "markIncomingMessagesReadedOnReply": "no",
    "outgoingWebhook": "yes",
    "outgoingMessageWebhook": "yes",
    "outgoingAPIMessageWebhook": "yes",
    "incomingWebhook": "yes",
    "deviceWebhook": "no",
    "stateWebhook": "yes",
    "keepOnlineStatus": "no",
    "pollMessageWebhook": "no",
    "incomingBlockWebhook": "yes", // The notification is temporarily out of work
    "incomingCallWebhook": "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\": \"yes\",\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 apiUrl, 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"":""yes"",""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