Skip to content

ClearWebhooksQueue#

Beta version

The functionality is in beta mode. Features are subject to change and may also work unstably. There may be additional charges for functionality in the future.

Test Postman Apidog
s The method is designed to clear the incoming notification queue. The notification is stored in the queue for 24 hours and will be sent after configuring webhookUrl on the authorized instance. The speed of sending messages depends on the response speed to requests GREEN-API webhook server or on the speed of reading messages by the HTTP API methods.

The method can be executed on the instance no more than once per minute. If the method is requested earlier, you will receive a description of the reason reason: "Too many requests", and the remaining time until the successful execution of the leftTime method in seconds.

After blocking a number or changing an account, it is advisable to clear the queue on the instance. Since it is possible to send notifications that remain in the queue, you can control messages in the queue using the GetWebhooksCount method or through the GREEN-API personal account.

Request#

To clear the message queue, you need to execute a request to the address:

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

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

Response#

Response parameters#

Parameter Type Description
isCleared boolean Messages queue clearing flag
reason string Error description:
"Too many requests" - the method is not ready to execute (method execution is available no more than once per minute)
leftTime int The remaining time before the next request to clear the queue is allowed to be executed (the field is present in the response only if isCleared: false )

Response body example#

Successful execution of the method#

status code 200

{
    "isCleared": true,
    "reason": ""
}

The method executed successfully, but the time between requests has not yet expired.#

status code 200

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

The method executed successfully, but the system was unable to process the request.#

status code 200

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

Errors ClearWebhooksQueue#

For a list of errors common to all methods, refer to 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