Skip to content

ClearWebhooksQueue#

Beta version

The functionality is in beta. Features may change and may also work unstably.

The method is used to clear the incoming notifications queue.
The notification sending rate depends on the response rate of the GREEN-API webhook server requests or on the rate at which the notifications are received by the HTTP API methods.

After an account is blocked or changed, it is advisable to clear the queue on the instance, since the notifications remaining in the queue may be sent.

You can control the notifications in the queue by the GetWebhooksCount method or through the GREEN-API console.

The method uses the limits on the number of requests per second.

Request#

To clear the notifications queue, you have to execute a request at:

DELETE
{{apiUrl}}/waInstance{{idInstance}}/clearWebhooksQueue/{{apiTokenInstance}}

For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Response#

Response parameters#

Field Type Description
isCleared boolean The notifications queue clearing flag
reason string The description of the error:
"Too many requests" - the method is not ready to be executed (the method can be executed no more than once a minute)
leftTime integer The time in seconds left 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 the requests has not passed yet#

status code 200

{
    "isCleared": false,
    "reason": "Too many requests",
    "leftTime": 46
}

Successful execution of the method, but the system could not process the request#

status code 200

{
    "isCleared": false,
    "reason": "Error description"
}

ClearWebhooksQueue errors#

For a list of errors common to all methods, refer to the Common errors section

Request 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