# Submit async tasks in a batch

`POST https://api.answerline.dev/v1/async/task/batch`

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.

## Returns

- `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.
  - `summary.total` (integer, required): How many tasks the batch submission contained.
  - `summary.succeeded` (integer, required): How many tasks were created without error.
  - `summary.failed` (integer, required): How many tasks were not created.
- `results` (object[], required): Result for each task, listed by index in the same order as the input.

## Responses

- 200: The batch was processed. See the summary and each task's result to learn which tasks succeeded or failed.
- 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 do not fit in your queue. This status is also returned when the API cannot take the request right now (`SERVICE_OVERLOADED`, sent with `Retry-After` and without limit headers) and when one address presented too many unknown keys (`RATE_LIMIT_EXCEEDED`, with `Retry-After`)
- 500: Internal Server Error

## Request

curl:

```bash
curl -X POST "https://api.answerline.dev/v1/async/task/batch" \
  -H "Authorization: Bearer $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":"How is Northwind Traders reviewed by customers?","country":"US"}},{"taskType":"PERPLEXITY","priority":3,"idempotencyKey":"batch-perplexity-001","payload":{"prompt":"Recent announcements from Northwind Traders","country":"US"}}]'
```


## Example responses

200:

```json
{
  "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": 1,
        "createdAt": "2026-04-09T15:00:00.000Z",
        "latencyMs": null,
        "idempotencyKey": "batch-chatgpt-001"
      },
      "credits": {
        "creditsToCharge": 0.0015,
        "creditsCharged": null
      }
    }
  ]
}
```

