- [HTTP request](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#body.aspect)
- [CreateTaskRequest](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#CreateTaskRequest)
  - [JSON representation](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#CreateTaskRequest.SCHEMA_REPRESENTATION)
- [Try it!](https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#try-it)

Creates a batch of tasks and adds them to a queue.

All tasks must be for the same queue. A maximum of 100 tasks can be created in a single batch.

### HTTP request

`POST https://cloudtasks.googleapis.com/v2/{parent=projects/*/locations/*/queues/*}/tasks:batchCreate`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `parent`: - `cloudtasks.tasks.create` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "requests": [ { object (`https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#CreateTaskRequest`) } ], "requestId": string } ``` |

| Fields ||
|---|---|
| `requests[]` | ``object (`https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/batchCreate#CreateTaskRequest`)`` Required. The list of requests to create tasks. The queue specified in parent field of each CreateTaskRequest will be the same. This validation happens on the client side as well as in the handler. BatchCreateTasksRequest.parent will also be the same value as the individual CreateTaskRequest.parent . The maximum number of requests is 100. |
| `requestId` | `string` Optional. This field will be used to identify the long running operation, avoiding duplication when user retries. If not provided, then a UUID will be generated at server side. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/tasks/docs/reference/rest/Shared.Types/Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-platform`
- `https://www.googleapis.com/auth/cloud-tasks`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

## CreateTaskRequest

Request message for `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/create#google.cloud.tasks.v2.CloudTasks.CreateTask`.

| JSON representation |
|---|
| ``` { "parent": string, "task": { object (`https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task`) }, "responseView": enum (`https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#View`) } ``` |

| Fields ||
|---|---|
| `parent` | `string` Required. The queue name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` The queue must already exist. |
| `task` | ``object (`https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task`)`` Required. The task to add. Task names have the following format: `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. The user can optionally specify a task `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task.FIELDS.name`. If a name is not specified then the system will generate a random unique task id, which will be set in the task returned in the `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task.FIELDS.name`. If `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task.FIELDS.schedule_time` is not set or is in the past then Cloud Tasks will set it to the current time. Task De-duplication: Explicitly specifying a task ID enables task de-duplication. If a task's ID is identical to that of an existing task or a task that was deleted or executed recently then the call will fail with `google.rpc.Code.ALREADY_EXISTS`. The IDs of deleted tasks are not immediately available for reuse. It can take up to 24 hours (or 9 days if the task's queue was created using a queue.yaml or queue.xml) for the task ID to be released and made available again. Because there is an extra lookup cost to identify duplicate task names, these `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/create#google.cloud.tasks.v2.CloudTasks.CreateTask` calls have significantly increased latency. Using hashed strings for the task id or for the prefix of the task id is recommended. Choosing task ids that are sequential or have sequential prefixes, for example using a timestamp, causes an increase in latency and error rates in all task commands. The infrastructure relies on an approximately uniform distribution of task ids to store and serve tasks efficiently. |
| `responseView` | ``enum (`https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#View`)`` The responseView specifies which subset of the `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task` will be returned. By default responseView is `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#View.ENUM_VALUES.BASIC`; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#View.ENUM_VALUES.FULL` requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the `https://docs.cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#Task` resource. |