# create\_batch

`imerit_ango.sdk.SDK.`

## create\_batch(project\_id, batch\_name)

Create a new batch within your project.

### Parameters

```python
create_batch(project_id: str, batch_name: 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.
* **batch\_name:** string
  * Name of the batch to be created.
  * Example: `'My Batch 1'`

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.

### Example

Create a batch:

{% 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)

ango_sdk.create_batch(project_id=project_id, batch_name="My Batch Name")
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/batches/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "batches": [
      {
        "name": "My Batch Name"
      }
    ]
  }'
```

{% endtab %}
{% endtabs %}

Prevent creating duplicate batches:

{% 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)

batch_name = "My Batch"

# Get available batch names from project
batch_response = ango_sdk.get_batches(project_id)

project_batch_name_list = []
for index in range(len(batch_response)):
    project_batch_name = batch_response[index]['name']
    project_batch_name_list.append(project_batch_name)

# Create batch if it is not available on the project
if batch_name not in project_batch_name_list:
    ango_sdk.create_batch(project_id=project_id, batch_name=batch_name)
```

{% endtab %}
{% endtabs %}

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

[assign\_batches](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/assign_batches), [get\_batches](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/get_batches)
{% endhint %}
