ClearWebhooksQueue#
The method is intended for clearing the incoming notification queue.
Each notification is stored in the queue for 24 hours.
The notification sending rate depends on the response speed to the requests of the GREEN-API webhook server or on the speed of reading messages using the HTTP API methods.
After a number is blocked or an account is changed, it is advisable to clear the queue on the instance, as the notifications remaining in the queue may be sent.
The method uses limits on the request rate per second.
Request#
To clear the message queue, you need to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/clearWebhooksQueue/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
isCleared | boolean | Flag that the notification queue is cleared |
reason | string | Error description |
leftTime | integer | Time remaining until the next queue clearing request is allowed (the field is present in the response only when isCleared: false ) |
Response body example#
Successful execution of the method#
{
"isCleared": true,
"reason": ""
}
Successful execution of the method, but the time between requests has not yet elapsed#
status code 200
{
"isCleared": false,
"reason": "Too many requests",
"leftTime": 46
}
Errors#
For the list of errors common to all methods, see the Common errors section
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/clearWebhooksQueue/{{apiTokenInstance}}"
payload = {}
headers= {}
response = requests.request("DELETE ", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
curl --location --request DELETE '{{apiUrl}}/waInstance{{idInstance}}/clearWebhooksQueue/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/clearWebhooksQueue/")
.append({{apiTokenInstance}});
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.GET, null, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/clearWebhooksQueue/")
.append({{apiTokenInstance}});
var response = Unirest.get(requestUrl.toString())
.header("Content-Type", "application/json")
.asString();
System.out.println(response);
Sub ClearWebhooksQueue()
Dim url 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}}/clearWebhooksQueue/{{apiTokenInstance}}"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", url, False
http.Send
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
' Range("A1").Value = response
Set http = Nothing
End Sub