# create\_attachment

`imerit_ango.sdk.SDK.`

## create\_attachment(project\_id, attachments)

Add attachments to assets in 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.
* **attachments:** List\[dict]
  * List of attachments to attach to existing assets. Attachments are dictionaries containing information about the asset the attachment will be attached to, the type of attachment, and the content of the attachment.

<details>

<summary>Sample JSON</summary>

```json
[
  {
    "externalId": "sample_image_1.png",
    "attachments": [
      {
        "type": "IMAGE",
        "value": "https://sample-attachment-image.jpg"
      },
      {
        "type": "TEXT",
        "value": "Some sample text."
      }
    ]
  },
  {
    "externalId": "sample_image_2.png",
    "attachments": [
      {
        "type": "VIDEO",
        "value": "https://sample-attachment-video.jpg"
      }
    ]
  }
]
```

</details>

{% hint style="info" %}
Attachments can have one of the types "IMAGE", "TEXT", or "VIDEO".

For IMAGE and VIDEO, you will need to provide a link to the resource. JPG, PNG, and MP4 are supported.

For text, you will need to provide the text that will be attached.
{% endhint %}

{% hint style="info" %}
For image and video attachments, you may provide links to assets in private buckets, provided that you've connected them to Ango Hub. More information on how to do so can be found on the [Attachments](/core-concepts/attachments.md#uploading-attachments-from-private-buckets) page.
{% endhint %}

{% hint style="warning" %}
In AWS S3, if your attachment URL does not contain region information, your attachments may not be visible. When using S3, please ensure the region information is contained in the URL right after the bucket name, like so:

```json
https://bucket-name.s3.eu-central-1.amazonaws.com/filename.JPG?storageId=111bb111389ff80015f2b914
```

{% endhint %}

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_attachment` function, you can validate the changes directly in Ango Hub.

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

* Filter the relevant tasks as needed.
* Open a task and check the Attachment section from the right sidebar.
* Confirm that the attachments have been created and displayed correctly.

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

attachments = [
    {
        "externalId": "sample_image_1.png",
        "attachments": [
            {
                "type": "IMAGE",
                "value": "https://sample-attachment-image.jpg"
            },
            {
                "type": "TEXT",
                "value": "Some sample text."
            }
        ]
    },
    {
        "externalId": "sample_image_2.png",
        "attachments": [
            {
                "type": "VIDEO",
                "value": "https://sample-attachment-video.jpg"
            }
        ]
    }
]

ango_sdk.create_attachment(project_id=project_id, attachments=attachments)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/attachments" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "attachments": [
      {
        "attachments": [
          { "type": "IMAGE", "value": "https://sample-attachment-image.jpg" },
          { "type": "TEXT", "value": "Some sample text." }
        ],
        "externalId": "sample_image_1.png"
      },
      {
        "attachments": [
          { "type": "VIDEO", "value": "https://sample-attachment-video.jpg" }
        ],
        "externalId": "sample_image_2.png"
      }
    ],
    "project": "$PROJECT_ID"
  }'
```

{% endtab %}
{% endtabs %}

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

[Attachments](/core-concepts/attachments.md)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/create_attachment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
