cloro WebsiteAPI Get an API key
API Reference › Utilities › Create batch tasks

Create batch tasks

Queue many asynchronous extraction jobs with one call, up to 500 at a time, and get back an independent result for every job in the batch.

POST https://api.cloro.cloud/v1/async/task/batch

Overview

When you need to launch a large number of async tasks, sending them one at a time adds network round-trips and slows down high-volume pipelines. The batch endpoint collapses that work into a single request: pass an array of task objects and cloro processes each one on its own.

Each entry in the array uses the same shape as a standalone async task, so a batch can freely mix providers and prompts. The key characteristics to keep in mind:

To submit a single job instead, use the Create async task endpoint.

Request body

The body is a JSON array containing 1 to 500 task objects. Each object supports the following fields.

FieldTypeDescription
taskTypeenum (string), requiredTarget AI provider for the task. One of AIMODE, GOOGLE, GOOGLE_NEWS, GEMINI, CHATGPT, COPILOT, PERPLEXITY, GROK.
payloadobject, requiredProvider-specific request data. Must contain at least a prompt (or query for Google Search), plus optional fields such as country.
priorityinteger, optionalScheduling weight from 1 to 10; higher values run sooner. Defaults to 1.
idempotencyKeystring, optionalCaller-supplied key that must be unique across your account. Reusing a key prevents a duplicate task from being created.
webhookobject, optionalDelivery target for completion notifications; contains a url that cloro calls when the task finishes.

Authentication uses a bearer token supplied in the Authorization header as Bearer <token>.

Constraints

FieldTypeDescription
Minimum tasksintegerAt least 1 task object per request.
Maximum tasksintegerNo more than 500 task objects per request.
Queue capacityruleAll-or-nothing. The batch is refused if accepting it would push you past the 100,000-task queue ceiling.
Body shaperuleA non-array or empty body returns 422 Unprocessable Entity before any task is inspected.

Per-task error codes

When an individual task fails validation, its result carries one of these codes in the error object.

FieldTypeDescription
VALIDATION_ERRORcodeThe task did not pass schema validation; details lists the offending fields.
RESOURCE_ALREADY_EXISTScodeThe idempotencyKey was already seen, either in an earlier request or elsewhere in this same batch.
INSUFFICIENT_CREDITScodeYour remaining credit balance cannot cover this task. Credits are accounted for per task.

Response fields

FieldTypeDescription
successbooleanTrue whenever the batch itself was processed; individual tasks may still have failed.
summaryobjectRoll-up counts: total, succeeded, and failed.
resultsobject[]One entry per submitted task, in input order. Each has index, a success flag, and either a task plus credits object or an error object.

Response example

{
  "success": true,
  "summary": {
    "total": 3,
    "succeeded": 2,
    "failed": 1
  },
  "results": [
    {
      "success": true,
      "index": 0,
      "task": {
        "id": "b27a21e1-7c39-4aa2-a347-23e828c426f9",
        "taskType": "CHATGPT",
        "status": "QUEUED",
        "priority": 5,
        "createdAt": "2026-04-09T15:00:00.000Z",
        "idempotencyKey": "batch-chatgpt-001"
      },
      "credits": {
        "creditsToCharge": 10,
        "creditsCharged": null
      }
    },
    {
      "success": true,
      "index": 1,
      "task": {
        "id": "c38b32f2-8d40-5bb3-b458-34f939d537e0",
        "taskType": "PERPLEXITY",
        "status": "QUEUED",
        "priority": 3,
        "createdAt": "2026-04-09T15:00:00.000Z",
        "idempotencyKey": "batch-perplexity-001"
      },
      "credits": {
        "creditsToCharge": 5,
        "creditsCharged": null
      }
    },
    {
      "success": false,
      "index": 2,
      "error": {
        "code": "INSUFFICIENT_CREDITS",
        "message": "Not enough credits remaining",
        "timestamp": "2026-04-09T15:00:00.000Z"
      }
    }
  ]
}

Request example

curl -X POST "https://api.cloro.cloud/v1/async/task/batch" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "taskType": "CHATGPT",
      "priority": 5,
      "idempotencyKey": "batch-chatgpt-001",
      "webhook": { "url": "https://your-app.com/webhook-handler" },
      "payload": { "prompt": "What do you know about Acme Corp?", "country": "US" }
    },
    {
      "taskType": "PERPLEXITY",
      "priority": 3,
      "idempotencyKey": "batch-perplexity-001",
      "payload": { "prompt": "Latest news about Acme Corp", "country": "US" }
    }
  ]'

Notes