Message sending interval#
When messages or files are sent, all data is placed in the sending queue.
All messages are sent from the queue sequentially in the order they entered the queue, FIFO.
At the same time, an interval is set between sending messages from the queue.
The SetSettings method and the delaySendMessagesMilliseconds parameter are intended for changing the message sending interval.
The interval is counted from the moment the previous message was sent from the queue.
Accordingly, if more time has passed than the interval value, the message will be sent without a delay.
- The minimum message sending interval is 500 ms.
- The maximum sending interval is 10 minutes (600000 ms).
- It is recommended to set an interval of no more than 5 minutes (300000 ms).
You can view the current sending interval using the GetSettings method, the delaySendMessagesMilliseconds parameter.
Changing the message sending interval#
To change the message sending interval, you need to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Only one parameter, delaySendMessagesMilliseconds, needs to be specified in the request body.
Request body example for setting a sending interval of 5 sec#
{
"delaySendMessagesMilliseconds": 5000
}
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/SetSettings/{{apiTokenInstance}}"
payload = {
"delaySendMessagesMilliseconds": 5000
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data '{
"delaySendMessagesMilliseconds": 5000
}'
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);