# 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

```python
assign_batches(project_id: str, asset_ids: List[str], batches: List[str])
```

* **project\_id:** string
  * The unique identifier for the project. You can find the project ID in [the user interface](https://docs.imerit.net/sdk/sdk-documentation/..#project-ids) or retrieve it using the [`list_projects`](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/list_projects) function.
* **asset\_ids:** List\[str]
  * List of asset IDs to assign to batches. Asset IDs can be obtained [from the UI](https://docs.imerit.net/sdk/sdk-documentation/..#task-and-asset-ids), or from [`get_assets`](#get_assets-project_id-asset_id-external_id-page-limit).
  * Example: `['0000000aa0a00a0000aaaa0a', '0000000aa0a00a0000aaaa0b']`
* **batches:** List\[str]
  * List of batch IDs to which the assets will be assigned. Batch IDs can be obtained with the [`get_batches`](#get_batches-project_id) function.
  * Example:&#x20;
    * `['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" %}
Batches must already exist in the project. If needed, create them using the [create\_batch](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/create_batch) function.
{% endhint %}

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

### Verify in Ango Hub

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

Navigate to: **Projects → \[Your Project] → Assets** and filter assets using their Asset ID.

* 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 %}

### 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](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/create_batch), [get\_batches](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/get_batches)
{% endhint %}
