# Image Export

You can generate an export (*.zip* format) containing several images.&#x20;

{% hint style="info" %}
This process is asynchronous and requires a webhook server to listen to export events.
{% endhint %}

![The export process](/files/yngu45ukmvI7iEP7jP5W)

## (1) Ask an export

{% openapi src="/files/nhoRfRux6jsJFcQGKWNt" path="/async/banners/export" method="post" %}
[api.yaml](https://3568284716-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHvY8mOYKzvcoxVpCu4FE%2Fuploads%2FqVg4vM3vT8x4kCEmcYh3%2Fapi.yaml?alt=media\&token=3c2d3254-6a4b-41e0-a6fa-55a031e7e0c0)
{% endopenapi %}

{% tabs %}
{% tab title="cURL" %}

```
# Do not forget to replace {YOUR-API-KEY}
curl -X POST -H "x-api-key:{YOUR-API-KEY}" -H "Content-Type: application/json"  \
-d '{
  "callback_url": "https://webhook.mycompany.com/export",
  "ids": ["{banner_id1}", "{banner_id2}", "{banner_id3}"]
}' \
https://api.abyssale.com/async/banners/export
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const axios = require('axios');

const payload = {
  "callback_url": "https://webhook.mycompany.com/export",
  "ids": ["{banner_id1}", "{banner_id2}", "{banner_id3}"]
}

// Replace {id} by your template ID
axios.post("https://api.abyssale.com/banner-builder/{id}/generate", payload, {
    headers: {"x-api-key": "{YOUR-API-KEY}", "Content-Type": "application/json", "timeout": 30000}
  }).then(response => {
    console.log(response.data)
})
```

{% endtab %}

{% tab title="Python" %}

```python
import json
import requests

export_payload = {
  "callback_url": "https://webhook.mycompany.com/export",
  "ids": ["{banner_id1}", "{banner_id2}", "{banner_id3}"]
}

# Do not forget to replace {YOUR-API-KEY} and {template_id}
r = requests.post("https://api.abyssale.com/banner-builder/{template_id}/generate",
  headers={"x-api-key": "YOUR-API-KEY", "Content-Type": "application/json"},
  data=json.dumps(export_payload),
  timeout=30
)
r.json()
```

{% endtab %}
{% endtabs %}

## (2) Receive the export request ID&#x20;

If the export request is accepted, the API call returns the **`export_id`**. It represents the ID of the asynchronous export and allows toto identify the asynchronous response.

#### The following errors can occur:

* **`400`**: A given parameter is invalid. Body response:

```
{
    "message": "body_validation_errors: {'media': {'ids': {0: ['Length must be 36.']}}}",
    "errors": {
        "media": {
            "ids": {
                "0": [
                    "Length must be 36."
                ]
            }
        }
    }
}
```

* **`404`**: One the given banner ID cannot be found.

## (3) NewExport event&#x20;

Once the export is generated on the Abyssale side, a `NewExport` event is sent (POST) to the `callback_url`

{% hint style="success" %}
If the initial request returns an export ID, the NewExport event will always be sent.
{% 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://developers.abyssale.com/rest-api/image-export.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.
