---
title: "Submit async tasks in a batch"
method: POST
path: "/v1/async/task/batch"
---

# Submit async tasks in a batch

`POST /v1/async/task/batch`

## Request

- Base URL: `https://api.answerline.dev`
- URL: `https://api.answerline.dev/v1/async/task/batch`
- Auth: HTTP bearer

Create as many as 500 async tasks in a single request. Tasks are validated one by one, so an invalid task does not stop the others from being accepted. The response lists a result for each task.

## Request body

- BatchTaskRequest[]: Tasks to create, one object each.
  - `taskType` 'AIMODE' | 'GOOGLE' | 'GOOGLE_NEWS' | 'GEMINI' | 'CHATGPT' | 'COPILOT' | 'PERPLEXITY' | 'GROK', required: AI provider that should handle this task.
  - `payload` object, required: Request body specific to the provider. Needs at least `prompt` (`query` for Google Search).
  - `priority` integer: Priority of the task, from 1 to 10; tasks with higher numbers run first. Default: 1.
  - `idempotencyKey` string: Distinct string that stops the same task from being created twice. No two tasks in your account may share it.
  - `webhook` object: Settings for the webhook that reports a finished task.
    - `url` string, uri, required: Endpoint that gets the webhook POST request once the task finishes.

## Response `200`

The batch was processed. See the summary and each task's result to learn which tasks succeeded or failed.

- BatchTaskResponse
  - `success` boolean, required: Set to true for every batch that was processed successfully; individual tasks inside it can still have failed.
  - `summary` object, required: Totals across the whole batch.
    - `total` integer, required: How many tasks the batch submission contained.
    - `succeeded` integer, required: How many tasks were created without error.
    - `failed` integer, required: Tasks rejected during validation or failed during processing.
  - `results` union[], required: Result for each task, listed by index in the same order as the input.
    - union
      - BatchTaskSuccessResult
        - `success` true, required: Signals that the task was created.
        - `index` integer, required: Index of this task within the submitted request array, starting at 0.
        - `task` object, required: Summary fields that every async task response includes.
          - `id` string, uuid, required: Identifier unique to the task.
          - `taskType` 'AIMODE' | 'GOOGLE' | 'GOOGLE_NEWS' | 'GEMINI' | 'CHATGPT' | 'COPILOT' | 'PERPLEXITY' | 'GROK', required: AI provider that handles this task.
          - `status` 'QUEUED', required: Status a task starts with when it is created.
          - `priority` integer, required: Priority of the task, from 1 to 10; tasks with higher numbers run first. Default: 1.
          - `createdAt` string, date-time, required: Creation time of the task.
          - `latencyMs` integer, nullable: Time spent processing, in milliseconds, measured from the first pickup until the final outcome. The initial wait in the queue is not counted, but for a retried task it spans all attempts plus the backoff in between. Null for tasks in `QUEUED` or `PROCESSING` state, and for tasks that failed before processing began.
          - `idempotencyKey` string, nullable: Idempotency key supplied with the request, if any.
        - `credits` AsyncTaskCredits, required: Charge details for one async task, in USD.
          - `creditsToCharge` number, required: USD amount held back from the balance for this task.
          - `creditsCharged` number, nullable, required: USD amount charged for the task (0 when a free request covered it); null while it has not finished.
      - BatchTaskFailureResult
        - `success` false, required: Signals that the task did not succeed.
        - `index` integer, required: Index of this task within the submitted request array, starting at 0.
        - `error` object, required
          - `code` 'VALIDATION_ERROR' | 'RESOURCE_ALREADY_EXISTS' | 'INSUFFICIENT_CREDITS', required: Code naming why the request failed.
          - `message` string, required: Error description meant for people to read.
          - `details` object: Extra information about the error, for example which fields failed validation.
          - `timestamp` string, date-time, required: Time at which the error happened.

## Other responses

- `401`: Unauthorized - authentication failed
- `422`: Validation Error - the body of the request is empty or not a proper array
- `429`: Queue Limit Exceeded - no task in the batch is accepted, because together they would take your organization beyond its queue capacity. This status is also returned when the API key's rate limit is hit and when the API sheds load (`SERVICE_OVERLOADED`, sent with `Retry-After` and without limit headers)
- `500`: Internal Server Error

---

[API](https://skmtc.dev/answerline/apis/answerline-api.md) · [All operations](https://skmtc.dev/answerline/apis/answerline-api/llms.txt) · [OpenAPI document](https://skmtc.dev/answerline/apis/answerline-api/revisions/a9dc35794662?raw)
