> 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/create_batch.md).

# create\_batch

`imerit_ango.sdk.SDK.`

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

Create a new batch 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.
* **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.

<details open>

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

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

Navigate to: **Projects → \[Your Project] → Settings → Batches**

* Confirm that the newly created batch appears in the batch list.

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

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
batches = ango_sdk.get_batches(project_id)

project_batch_name_list = []
for batch in batches:
    project_batch_name = batch['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](/sdk/sdk-documentation/project-level-sdk-functions/assign_batches.md), [get\_batches](/sdk/sdk-documentation/project-level-sdk-functions/get_batches.md)
{% endhint %}
