# create\_asset\_builder\_template

`imerit_ango.sdk.SDK.`&#x20;

## create\_asset\_builder\_template(project\_id, template)

Create templates to be used while uploading data via the [asset builder](https://docs.imerit.net/data/importing-assets/asset-builder).

### Parameters

```python
create_asset_builder_template(project_id: str, template: AssetBuilderTemplate)
```

* **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.
* **template:** AssetBuilderTemplate

  An object defining the structure of the template, excluding the `_id` field. Includes:

  * **name:** string
    * Unique name for this template.
  * **template:** string
    * Template HTML that will be filled in while uploading via [asset builder.](https://docs.imerit.net/data/importing-assets/asset-builder)
  * **external\_id\_column:** string
    * The column name from the input tabular data to be used as the [asset's externalId.](https://docs.imerit.net/core-concepts/assets#external-id) In each row, the value in the cell corresponding to this column will be used as the externalId for that row.
  * **data\_config:** Dict\[str, DataConfigItem]&#x20;

    Dictionary mapping column names to their configuration. Each `DataConfigItem` contains:

    * **type**: string - The data type for this column. Must be one of:&#x20;
      * <kbd>"text"</kbd>, <kbd>"link"</kbd>, <kbd>"image"</kbd>, <kbd>"audio"</kbd>, <kbd>"video"</kbd>, <kbd>"iframe"</kbd>, <kbd>"pdf"</kbd>
    * **storage**: string, *Optional, default None* - Storage configuration for this column. Only necessary when the type is one of: video, image, audio, or pdf.
    * **include\_in\_export**: string, *Optional, default False* - Whether to include this column in exports
  * **description:** string, *Optional, default ""*
    * A description of what the template does or what it is.
  * **batch\_column:** string, *Optional, default ""*
    * Batch column name from the input tabular data to be used as the [batch name](https://docs.imerit.net/core-concepts/batches) for that asset. In each row, the value in the cell corresponding to this column will be used as the batch name for that row.
  * **pre\_label\_config:** PreLabelConfig

    Dictionary containing pre-labeling configuration. Each item contains:

    * **cla**: PreLabelCla - Classification configuration with fields:
      * **schemaId**: string - Schema identifier
      * **title**: string - Display title
      * **multiple**: bool - Whether multiple selections are allowed
    * **value**: string - Column that will be used as the source of pre-label data

### Returns

* 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.

### Examples

#### Basic Template (minimal required fields)

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem

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

ango_sdk = SDK(api_key)

template = AssetBuilderTemplate(
    name="Simple Image Template",
    template="<img src='{{image_url}}' alt='Sample image' />",
    external_id_column="image_id",
    data_config={"image_id": DataConfigItem(type="text",),
                 "image_url": DataConfigItem(type="image", storage="<YOUR_STORAGE_INTEGRATION_ID>")}
)

sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
template_id = sdk_response["data"]["_id"]
```

<details>

<summary>Sample CSV File</summary>

```
image_id,image_url
IMG_001,https://picsum.photos/200/300
IMG_002,https://picsum.photos/200/300
```

</details>

#### Comprehensive Template (all optional fields)

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem

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

ango_sdk = SDK(api_key)

# HTML template with placeholders
html_template = """
<div class="video-container">
    <video src='{{video_url}}' controls></video>
    <p>{{description}}</p>
    <a href='{{reference_link}}'>Reference</a>
    <div id="cla-portal-{{classification_schema_id}}">Content classification</div>
    <div id="cla-portal-{{quality_schema_id}}">Quality assessment</div>
</div>
"""

# Data configuration
data_config = {
    "video_id": DataConfigItem(type="text", include_in_export=True),
    "video_url": DataConfigItem(type="video", storage="<YOUR_STORAGE_ID>"),
    "description": DataConfigItem(type="text", include_in_export=True),
    "reference_link": DataConfigItem(type="link")
}

# Pre-label configuration
pre_label_config = {
    "classification_schema_id": {
        "cla": {
            "schemaId": "schema_123",
            "title": "Content Type",
            "multiple": False
        },
        "value": "content_type_column"
    },
    "quality_schema_id": {
        "cla": {
            "schemaId": "schema_456",
            "title": "Quality Issues",
            "multiple": True
        },
        "value": "quality_column"
    }
}

template = AssetBuilderTemplate(
    name="Video Classification Template",
    description="Template for video content classification with descriptions and quality assessment",
    template=html_template,
    external_id_column="video_id",
    data_config=data_config,
    pre_label_config=pre_label_config
)

sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
```

<details>

<summary>Sample CSV File</summary>

```
video_id,video_url,description,reference_link
VID_001,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ,Product demonstration showing key features and user interface walkthrough,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ
VID_002,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ,Basic tutorial covering getting started steps for new users,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ
```

</details>

#### Template with Batch Processing

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem

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

ango_sdk = SDK(api_key)

html_template = """
<div>
    <img src='{{image_url}}' alt='{{image_title}}' />
    <p>{{image_description}}</p>
    <iframe title='{{metadata_url}}' sandbox="" referrerpolicy="no-referrer" src='{{metadata_url}}' width="100%" height="200"></iframe>
    <div id="cla-portal-{{category_schema_id}}">Image Category</div>
    <div id="cla-portal-{{sentiment_schema_id}}">Sentiment Analysis</div>
</div>
"""

data_config = {"image_id": DataConfigItem(type="text", include_in_export=True),
               "image_url": DataConfigItem(type="image", storage="<YOUR_STORAGE_INTEGRATION_ID>"),
               "image_title": DataConfigItem(type="text"),
               "image_description": DataConfigItem(type="text", include_in_export=True),
               "metadata_url": DataConfigItem(type="iframe"),
               "batch_group": DataConfigItem(type="text")}

pre_label_config = {
    "category_schema_id": {
        "cla": {
            "schemaId": "cat_202",
            "title": "Image Category",
            "multiple": False,
        },
        "value": "category_column"
    },
    "sentiment_schema_id": {
        "cla": {
            "schemaId": "sent_303",
            "title": "Sentiment",
            "multiple": False,
        },
        "value": "sentiment_column"
    }
}

template = AssetBuilderTemplate(
    name="Batch Image Processing Template",
    template=html_template,
    external_id_column="image_id",
    data_config=data_config,
    description="Template for batch processing of images with categorization and sentiment analysis",
    batch_column="batch_group",
    pre_label_config=pre_label_config
)

sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
```

<details>

<summary>Sample CSV File</summary>

```
image_id,image_url,image_title,image_description,metadata_url,batch_group
IMG_001,https://picsum.photos/200/300,Sample Product Photo,High-quality product image for e-commerce catalog,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ,batch_alpha
IMG_002,https://picsum.photos/200/300,Nature Landscape,Beautiful mountain landscape during golden hour,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ,batch_alpha
IMG_003,https://picsum.photos/200/300,Urban Architecture,Modern city building with glass facades,https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=RDdQw4w9WgXcQ,batch_beta
```

</details>

#### Usage with [upload\_files\_with\_asset\_builder](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/upload_files_with_asset_builder)

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.asset_builder_template import AssetBuilderTemplate, DataConfigItem

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

ango_sdk = SDK(api_key)

# Step 1: Create a simple template
template = AssetBuilderTemplate(
    name="Basic Image Template",
    template="<img src='{{image_url}}'/>",
    external_id_column="id",
    data_config={"id": DataConfigItem(type="text"),
                 "image_url": DataConfigItem(type="image", storage="Public")}
)

sdk_response = ango_sdk.create_asset_builder_template(project_id=project_id, template=template)
template_id = sdk_response["data"]["_id"]

# Step 2: Use the template_id to upload files
ango_sdk.upload_files_with_asset_builder(
    project_id=project_id,
    template_id=template_id,
    input_file_path="data.csv"
)
```

<details>

<summary>Sample CSV File</summary>

```
id,image_url
IMG_001,https://picsum.photos/200/300
IMG_002,https://picsum.photos/300/400
IMG_003,https://picsum.photos/250/350
```

</details>

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

[get\_asset\_builder\_templates](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/get_asset_builder_templates), [upload\_files\_with\_asset\_builder](https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/upload_files_with_asset_builder), [Asset Builder](https://docs.imerit.net/data/importing-assets/asset-builder)
{% endhint %}
