---
title: "Adds a collection of tasks to the specified job."
method: POST
path: "/jobs/{jobId}/addtaskcollection"
tags: ["Tasks"]
---

# Adds a collection of tasks to the specified job.

`POST /jobs/{jobId}/addtaskcollection`

Note that each task must have a unique ID. The Batch service may not return the results for each task in the same order the tasks were submitted in this request. If the server times out or the connection is closed during the request, the request may have been partially or fully processed, or not at all. In such cases, the user should re-issue the request. Note that it is up to the user to correctly handle failures when re-issuing a request. For example, you should use the same task IDs during a retry so that if the prior operation succeeded, the retry will not create extra tasks unexpectedly. If the response contains any tasks which failed to add, a client can retry the request. In a retry, it is most efficient to resubmit only tasks that failed to add, and to omit tasks that were successfully added on the first attempt. The maximum lifetime of a task from addition to completion is 7 days. If a task has not completed within 7 days of being added it will be terminated by the Batch service and left in whatever state it was in at that time.

## Path parameters

- `jobId` string, required

## Query parameters

- `timeout` integer
- `api-version` string, required

## Headers

- `client-request-id` string, uuid
- `return-client-request-id` boolean
- `ocp-date` string, date-time-rfc1123

## Response `200`

A response containing the results of the add task collection operation.

- TaskAddCollectionResult
  - `value` TaskAddResult[]
    - `status` 'success' | 'clienterror' | 'servererror', required
    - `taskId` string, required
    - `eTag` string — You can use this to detect whether the task has changed between requests. In particular, you can be pass the ETag with an Update Task request to specify that your changes should take effect only if nobody else has modified the job in the meantime.
    - `lastModified` string, date-time
    - `location` string
    - `error` BatchError
      - `code` string
      - `message` ErrorMessage
        - `lang` string
        - `value` string
      - `values` BatchErrorDetail[]
        - `key` string
        - `value` string

## Other responses

- `default` — Unexpected error

---

[API](https://skmtc.net/azure/apis/batch-batch.md) · [All operations](https://skmtc.net/azure/apis/batch-batch/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/azure/batch-batch/revisions/dff38446805d/schema)
