Clear queue - cloro

Clear queued async tasks

cURL

curl --request DELETE \
  --url https://api.cloro.dev/v1/async/queue \
  --header 'Authorization: Bearer <token>'

Python

import requests

url = "https://api.cloro.dev/v1/async/queue"

headers = {"Authorization": "Bearer <token>"}

response = requests.delete(url, headers=headers)

print(response.text)

JavaScript

const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.cloro.dev/v1/async/queue', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cloro.dev/v1/async/queue",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Go

package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {

url := "https://api.cloro.dev/v1/async/queue"

req, _ := http.NewRequest("DELETE", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Unirest Example

HttpResponse<String> response = Unirest.delete("https://api.cloro.dev/v1/async/queue")
  .header("Authorization", "Bearer <token>")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://api.cloro.dev/v1/async/queue")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body

Response Codes

Example JSON Responses

Success Response

{
  "success": true,
  "cleared": 42
}

Error Response

{
  "error": {
    "code": "MISSING_API_KEY",
    "message": "Missing or invalid API key",
    "timestamp": "2025-01-15T12:00:00.000Z"
  }
}
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "API key rate limit exceeded",
    "timestamp": "2025-01-15T12:00:00.000Z"
  }
}
{
  "success": false,
  "error": "Maximum retries exceeded"
}

Description

Clears your organization’s pending async queue in a single call — useful when you’ve enqueued a large backlog by mistake or want to reset the queue instead of waiting for it to drain. Only queued tasks are affected:

Credits are only deducted once a task is processed, so clearing the queue has no effect on your credit balance and no refund is issued. The call is safe to repeat: an already-empty queue returns cleared: 0 rather than an error. To check how many tasks are queued before clearing, use the async status endpoint.

Authorizations

Authorization is required as a bearer token. One key grants access to every endpoint in this specification; per-key scopes are not available, so a client cannot request a narrower permission. Keys are created, rotated, and revoked in the dashboard.

Response

Returns the number of queued tasks that were removed.