> For the complete documentation index, see [llms.txt](https://docs.imerit.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/assign_batches.md).

# assign\_batches

`imerit_ango.sdk.SDK.`

## assign\_batches(project\_id, asset\_ids, batches)

Assign a list of assets to one or more existing batches within your project.

### Parameters

* **project\_id:** string
  * The unique identifier for the project. You can find the project ID in [the user interface](/sdk/sdk-documentation.md#project-ids) or retrieve it using the [`list_projects`](/sdk/sdk-documentation/project-level-sdk-functions/list_projects.md) function.
* **asset\_ids:** List\[str]
  * List of asset IDs that will be assigned to the specified batches. Asset IDs can be obtained [from the UI](/sdk/sdk-documentation.md#task-and-asset-ids), or from [`get_assets`](/sdk/sdk-documentation/project-level-sdk-functions/get_assets.md) function.
  * Example: `['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']`
* **batches:** List\[str]
  * List of batch IDs to assign to the specified assets. Batch IDs can be obtained using the [`get_batches`](/sdk/sdk-documentation/project-level-sdk-functions/get_batches.md) function.
  * Example:
    * `['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']`

Returns:

* **output:** dict
  * A dictionary containing the result of the operation.
  * Including a `status` field indicating whether the request was successful and a `data` field containing the response payload with updated resources produced by the operation.

{% hint style="warning" %}
All specified batches must already exist in the project. If necessary, create batches first using the [create\_batch](/sdk/sdk-documentation/project-level-sdk-functions/create_batch.md) function.
{% endhint %}

{% hint style="warning" %}
The assets to assign must already exist in the project. To upload assets, use [upload\_files](/sdk/sdk-documentation/project-level-sdk-functions/upload_files.md) or [upload\_files\_cloud](/sdk/sdk-documentation/project-level-sdk-functions/upload_files_cloud.md) or any other appropriate upload function.
{% endhint %}

<details open>

<summary><strong>How to verify in Ango Hub?</strong></summary>

After successfully executing the `assign_batches` function, you can validate the changes directly in Ango Hub.

Navigate to: **Projects → \[Your Project] → Assets**

* Filter assets using their Asset ID or Batch column.
* Confirm that the selected assets are assigned to the correct batches.

{% hint style="info" %}
Changes made via the SDK are reflected in Ango Hub in near real-time. If updates are not immediately visible, please refresh the page.
{% endhint %}

</details>

### Example

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

asset_ids = ['<YOUR ASSET ID 1>', '<YOUR ASSET ID 2>', '<YOUR ASSET ID 3>']
batch_ids = ['<YOUR BATCH ID 1>', '<YOUR BATCH ID 2>']

ango_sdk.assign_batches(project_id=project_id, asset_ids=asset_ids, batches=batch_ids)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/assignBatches" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "assets": ["<YOUR ASSET ID 1>", "<YOUR ASSET ID 2>", "<YOUR ASSET ID 3>"],
    "batches": ["<YOUR BATCH ID 1>", "<YOUR BATCH ID 2>"],
    "projectId": "$PROJECT_ID"
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Sample Output</summary>

```json
{
    "status": "success",
    "data": {
        "assets": {
            "count": 3,
            "message": "Successfully assigned 2 batches to 3 assets: <YOUR BATCH ID 1>, <YOUR BATCH ID 2>"
        }
    }
}
```

</details>

{% hint style="info" %}
**See also**

[create\_batch](/sdk/sdk-documentation/project-level-sdk-functions/create_batch.md), [get\_batches](/sdk/sdk-documentation/project-level-sdk-functions/get_batches.md)
{% endhint %}
