# Export

### Export collection

To export collection via API, get the **collection\_id** of the processed file from:

* [Upload a file](https://alphamoon.gitbook.io/documentation/~/changes/E5WHATIwrsF0u91xTwvD/api/upload-file) endpoint (Base64 or Binary)
* Get collections endpoint
* URL\
  **e.g.** <https://workspace.alphamoon.ai/supervision/**223742cc9bca43fd81b2d41b0018e4c7>\*\*

To export the collection, use the following endpoint:

## Export Collection

<mark style="color:blue;">`GET`</mark> `/api/v0.3/collections/{collection_id}/export`

#### Path Parameters

| Name                                            | Type   | Description                                                         |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------- |
| collection-id<mark style="color:red;">\*</mark> | String | The id of the collection for which you want to extract the results. |

#### Query Parameters

| Name   | Type   | Description                                         |
| ------ | ------ | --------------------------------------------------- |
| Scope  | String | Choose between: extraction, ocr\_words, ocr\_tables |
| Format | String | Choose between: json, csv, xlsx, pdf, txt           |

{% tabs %}
{% tab title="200: OK Successful Response" %}

```json
Download file
```

{% endtab %}

{% tab title="422: Unprocessable Entity Validation Error" %}

```json
{
  "detail": [
    {
      "loc": [
        "string",
        0
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

#### See the example:

{% tabs %}
{% tab title="API call" %}

```bash
curl -X 'GET' \
  'https://workspace.alphamoon.ai/api/v0.3/collections/c0da3bd0798e4549a1eb673887258dd3/export?scope=extraction&format=json' \
  -H 'accept: */*' \
  -H 'Authorization: Basic API_KEY_BASE64_ENCODED'
```

{% endtab %}

{% tab title="Server response" %}

```
Download file
```

{% endtab %}
{% endtabs %}

### Export multiple collections

To export collections via API, get the[ **collection\_ids**](#export-collection) as well as **process\_id** from one of the following sources:

* [Get process](https://alphamoon.gitbook.io/documentation/~/changes/E5WHATIwrsF0u91xTwvD/api/get-processes)[es](https://alphamoon.gitbook.io/documentation/~/changes/E5WHATIwrsF0u91xTwvD/api/get-processes) endpoint
* Create process endpoint
* URL\
  **e.g.** <https://workspace.alphamoon.ai/queue/**2080d36bf94c4147b2e543104342fc2f>\*\*

To export multiple collections, use the following endpoint:

## Export Collections

<mark style="color:green;">`POST`</mark> `/api/v0.3/collections/export`

#### Request Body

| Name                                            | Type   | Description                          |
| ----------------------------------------------- | ------ | ------------------------------------ |
| collectionIds<mark style="color:red;">\*</mark> | String | The ids of the collections           |
| processId<mark style="color:red;">\*</mark>     | String | The process id                       |
| scope                                           | String | Extraction / ocr\_words/ ocr\_tables |
| format                                          | String | json, csv, xlsx, pdf, or txt         |

{% tabs %}
{% tab title="202: Accepted Successful Response" %}

```json
{
  "exportId": "f729dc8333cb4ccc82d36502bf0651f4"
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity Validation Error" %}

```json
{
  "detail": [
    {
      "loc": [
        "string",
        0
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
This endpoint creates an export process with the returned **export\_id**. You can refer to its results using the further described endpoint - [Get export by id](#get-export-by-id).
{% endhint %}

#### See the example:

{% tabs %}
{% tab title="API call" %}

```bash
curl -X 'POST' \
  'https://workspace.alphamoon.ai/api/v0.3/collections/export' \
  -H 'accept: application/json' \
  -H 'Authorization: Basic API_KEY_BASE64_ENCODED' \
  -H 'Content-Type: application/json' \
  -d '{
  "collectionIds": [
    "86fc8d905d0e4cefb042e6cd707fb51f"
  ],
  "processId": "93580f176efb48cda64f25cba74d8ca4",
  "mode": "single",
  "scope": "extraction",
  "format": "json"
}'
```

{% endtab %}

{% tab title="Server response" %}

```json
{
  "exportId": "f729dc8333cb4ccc82d36502bf0651f4"
}
```

{% endtab %}
{% endtabs %}

### Get export by Id

To export collections via API, get the[ ](#export-collection)**export\_id** from the following source:

* [Export collections endpoint](#export-collections)

Next up, use the following endpoint:

## Get Export By Id

<mark style="color:blue;">`GET`</mark> `/api/v0.3/collections/exports/{export_id]`

#### Path Parameters

| Name                                         | Type   | Description |
| -------------------------------------------- | ------ | ----------- |
| export\_id<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK Successful Response" %}

```json
Download file
```

{% endtab %}

{% tab title="422: Unprocessable Entity Validation Error" %}

```json
{
  "detail": [
    {
      "loc": [
        "string",
        0
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

#### See the example:

{% tabs %}
{% tab title="API call" %}

```bash
curl -X 'GET' \
  'https://workspace.alphamoon.ai/api/v0.3/collections/exports/f729dc8333cb4ccc82d36502bf0651f4' \
  -H 'accept: application/json' \
  -H 'Authorization: Basic API_KEY_BASE64_ENCODED'
```

{% endtab %}

{% tab title="Server response" %}

```
Download file
```

{% endtab %}
{% endtabs %}

**See next:**
