SetSettings#
The method is intended for setting the instance settings.
After an instance is created, all settings are disabled by default.
When this method is called, the instance is restarted.
The settings are applied within 5 minutes after the SetSettings method is called.
The method uses limits on the request rate per second.
Request#
To set the instance settings, you need to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Request parameters#
Parameters may be specified selectively. At least one parameter must be specified.
| Parameter | Type | Required | Description |
|---|---|---|---|
webhookUrl | string | No | URL for sending notifications. If you need to disable receiving notifications, specify an empty string. When receiving notifications with the HTTP API technology, the field must be empty. |
webhookUrlToken | string | No | Authorization header for sending notifications, if it is not required, specify an empty string. |
delaySendMessagesMilliseconds | integer | No | Message sending interval in milliseconds. Minimum value: 500 ms (0.5 seconds) Maximum value: 600000 ms (10 minutes). It is recommended to set an interval of no more than 300000 ms (5 minutes). |
markIncomingMessagesReaded | string | No | Mark incoming messages as read, possible values: yes, no. Ignored if markIncomingMessagesReadedOnReply is set to yes. |
markIncomingMessagesReadedOnReply | string | No | Mark incoming messages as read when a message is sent through the API, possible values: yes, no. If set to 'yes', the markIncomingMessagesReaded setting is ignored. |
outgoingWebhook | string | No | Receive notifications about the statuses of sent messages, possible values: yes, no |
outgoingMessageWebhook | string | No | Receive notifications about messages sent from the phone, the web version and the desktop version, possible values: yes, no |
outgoingAPIMessageWebhook | string | No | Receive notifications about messages sent through the API, possible values: yes, no. |
stateWebhook | string | No | Receive notifications about changes in the instance authorization state, possible values: yes, no |
incomingWebhook | string | No | Receive notifications about incoming messages and files, possible values: yes, no |
keepOnlineStatus | string | No | Keep the instance status "Online" permanently, possible values: yes, no |
editedMessageWebhook | string | No | Receive notifications when messages are edited by the correspondent, possible values: yes, no |
deletedMessageWebhook | string | No | Receive notifications when messages are deleted by the correspondent, possible values: yes, no |
General request body example#
{
"webhookUrl": "",
"webhookUrlToken": "",
"delaySendMessagesMilliseconds": 500,
"markIncomingMessagesReaded": "no",
"markIncomingMessagesReadedOnReply": "no",
"outgoingWebhook": "yes",
"outgoingMessageWebhook": "yes",
"outgoingAPIMessageWebhook": "yes",
"incomingWebhook": "yes",
"stateWebhook": "yes",
"keepOnlineStatus": "no",
"editedMessageWebhook": "yes",
"deletedMessageWebhook": "yes"
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
saveSettings | boolean | Flag that the settings are saved |
Response body example#
{
"saveSettings": true
}
Errors#
For the list of errors common to all methods, see the Common errors section
Code examples#
import requests
import json
url = "{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}"
payload = {
"webhookUrl": "https://mysite.ru",
"delaySendMessagesMilliseconds": 1000,
"markIncomingMessagesReaded": "no",
"outgoingWebhook": "yes"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)
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 console, 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