# Create a batch operation

`POST https://api.cademi.com.br/api/v3/operations/batches`

Operation ID: `operations.batches.create` · API v3

Creates an asynchronous batch operation. All items in the batch are processed with the same operation `type`, which also determines the structure of each item's `payload`.

The operation is accepted with a `Location` header pointing to it and processed asynchronously. Poll the retrieve operation to track its progress.

In addition to `operations.manage`, the credential must have the permission required by the selected operation type. Repeating the request with the same `Idempotency-Key` returns the same operation instead of creating a new one.

The request is rejected with `operation_type_unknown` for an unsupported type, `duplicate_item_key` when item keys are not unique, `too_many_items` when the batch exceeds the maximum number of items for the type, and `operation_backlog_exceeded` when the account has too many unfinished operations.

Required permissions: `operations.manage`.

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `items` | array of object | yes |  |
| `type` | string | yes | Operation type code. Must be one of the supported operation types. |

## Responses

### 202

Returns the accepted operation, which is processed asynchronously.

Body: `data`: Operation.

Fields of Operation:

| Field | Type | Required | Description |
|---|---|---|---|
| `attempt` | object or null | yes |  |
| `cancellation_requested` | boolean | yes |  |
| `created_at` | string (date-time) | yes |  |
| `error` | object or null | yes |  |
| `expires_at` | string (date-time) | yes |  |
| `finished_at` | string or null (date-time) | yes |  |
| `id` | string | yes | Public ID, with the op_ prefix. |
| `items_url` | string | yes |  |
| `object` | string, one of `operation` | yes |  |
| `progress` | object | yes |  |
| `result_url` | string or null | yes |  |
| `started_at` | string or null (date-time) | yes |  |
| `status` | string, one of `queued`, `running`, `succeeded`, `partially_succeeded`, `failed`, `canceled` | yes |  |
| `type` | string | yes | Type of the operation, from a fixed set of values. |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 422

The operation type is not supported, an item is invalid or duplicated, the batch exceeds the item limit, or the account has too many unfinished operations.

Body: Error.

Full schema: https://cademi.dev/openapi/v3.json
