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 https://api.greenapi.com/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}

For 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
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. The noAccount status 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

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"
}

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 = "https://api.greenapi.com/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 'https://api.green-api.com/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data '{
    "delaySendMessagesMilliseconds": 15000
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .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("https://api.greenapi.com")
    .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);