> For the complete documentation index, see [llms.txt](https://docs.coherent.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherent.global/spark-apis/impex-apis/export.md).

# Export

The export API packages all of the files necessary to create a service into a `ZIP` file. The `ZIP` file can then be used by the import API to deploy the Spark services to another tenant and/or environment.

## Prerequisites to export Spark services <a href="#api-request" id="api-request"></a>

* Only one job can be run at a time per tenant.
* All the referenced objects need to exist and be accessible with the provided authorization.
* Any referenced folders must contain a service.
* All referenced services must have a compiled [Neuron](/build-spark-services/neuron.md) WebAssembly module.
* The requested package size must not exceed the configured limit (default `200 MB`).

## Authorization

These APIs support authorization via:

* `Bearer {token}` accessible from [Authorization - Bearer token](/spark-apis/authorization-bearer-token.md) or systematically via [Client credentials](/identity-and-access-management/client-credentials.md).
  * The request headers should include a key for `Authorization` with the value `Bearer {token}`.
* API key created from [Authorization - API keys](/spark-apis/authorization-api-keys.md). It must contain [User groups](/identity-and-access-management/user-groups.md) that are also assigned to [Permissions - Features permissions](/spark-apis/authorization-api-keys/permissions-features-permissions.md) `Spark.Exports.json` or `Spark.AllEncompassingProxy.json`.
  * The request headers should include the keys `x-synthetic-key` and `x-tenant-name` with the values of the API key and tenant name respectively.

## `POST` export job <a href="#api-request" id="api-request"></a>

{% code overflow="wrap" %}

```shellscript
POST /{tenant}/api/v4/export
```

{% endcode %}

### Path parameters

| Key         | Value                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------- |
| `tenant` \* | Tenant is part of your sign-in URL and also available in the [Navigation menu](/navigation/navigation-menu.md#user-menu). |

### Request body <a href="#request-body" id="request-body"></a>

`Content-Type: application/json`

Spark includes the union of the `inputs` service identifiers in the exported package.

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `inputs.folders`     | Array of folder names.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `inputs.services`    | <p>Array of <code>CS.SPARK\_XCALL()</code> format of <code>{folder}/{service}</code> or <code>{folder}/{service}\[{version}]</code> or <code>service\_id</code>.</p><p>If a version is specified, follow the version convention to take the latest version with a starts with match. e.g. <code>3.2</code> will grab the latest semantic version that starts with <code>3.2</code>.<br>Example 1: <code>myfolder/myservice</code><br>Example 2: <code>myfolder/myservice\[1.4.3]</code><br>Example 3: <code>5edf95a1-96f3-4a53-b9a4-9ff382bd9936</code><br>Example 4: <code>\["myfolder/myservice1", "yourfolder/service2"]</code></p> |
| `inputs.version_ids` | Array of `version_id`s.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `file_filter`        | <p>Filter the requested files.</p><ul><li>The default value is <code>migrate</code> which will export all of the files relevant to the service.</li><li><code>onpremises</code> includes only the files that are needed for the <a data-mention href="/hybrid-runner/introduction-to-the-hybrid-runner.md">/pages/c1K85gVQxaAyBlgrHsDD</a>.</li></ul>                                                                                                                                                                                                                                                                                  |
| `source_system`      | <p>Tag API Call.</p><p>Example: <code>mycicd</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `correlation_id`     | <p>Tag API Call.</p><p>Example: <code>456</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `version_filter`     | <p>Filter service versions.</p><ul><li>The default value is <code>all</code> which will export all of the service versions for the identified folders and services.</li><li><code>latest</code> will only provide the latest service version for each service. If <code>latest</code> is used and there are references to a specific service version, the export will generate an error.</li></ul>                                                                                                                                                                                                                                     |
| `file_name`          | Name of the downloaded file. If not provided, Spark will use an appropriate name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

### Sample request and response

{% tabs %}
{% tab title="Sample request" %}

<details>

<summary></summary>

```shellscript
curl --location --globoff 'https://excel.myenvironment.coherent.global/mytenant/api/v4/export' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{Bearer Token}}' \
--data '{
    "inputs": {
        "services": ["myproduct/myservice"]
    },
    "source_system": "mycicd",
    "correlation_id": "456"
}'
```

</details>
{% endtab %}

{% tab title="Sample request body" %}

<details>

<summary></summary>

```json
{
    "inputs": {
        "services": ["myproduct/myservice"]
    },
    "source_system": "mycicd",
    "correlation_id": "456"
}'
```

</details>
{% endtab %}

{% tab title="Sample response" %}
Returns the response from [#get-export-status](#get-export-status "mention").

<details>

<summary></summary>

`HTTP 200 OK` `Content-Type: application/json`

```json
{
  "object": "export",
  "id": "9218acae-55a0-455c-b141-9a0b65a9f100",
  "response_timestamp": "2023-10-31T01:31:34.573Z",
  "status": "completed",
  "status_url": "https://excel.myenvironment.coherent.global/mytenant/v4/export/9218acae-55a0-455c-b141-9a0b65a9f100/status",
  "process_time": 456,
  "outputs": {
    "files": [
      {
        "file": "https://excel.myenvironment.coherent.global/9218acae-55a0-455c-b141-9a0b65a9f100.zip",
        "file_hash": "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
        "zip_process_time": 100
      }
    ],
    "services": [
      {
        "service_uri_source": "myproduct/myservice",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "zip_process_time": 50
      }
    ],
    "service_versions": [
      {
        "service_uri_source": "myproduct/myservice[1.0.0]",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "version_source": "1.0.0",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "version_id_source": "4b05a3ea-92fa-4168-8bcd-5f732a5adc5d"
      },
      {
        "service_uri_source": "myproduct/myservice[1.1.0]",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "version_source": "1.1.0",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "version_id_source": "e0901e15-b305-4d43-b037-3d39cf017260"
      }
    ]
  },
  "source_system": "mycicd",
  "correlation_id": "456"
}
```

</details>
{% endtab %}
{% endtabs %}

## `GET` export status and download link

{% code overflow="wrap" %}

```shellscript
GET /{tenant}/api/v4/export/{jobId}/status
```

{% endcode %}

### Path parameters

| Key         | Value                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------- |
| `tenant` \* | Tenant is part of your sign-in URL and also available in the [Navigation menu](/navigation/navigation-menu.md#user-menu). |
| `jobId` \*  | `id` from [#api-request-1](#api-request-1 "mention").                                                                     |

### Response <a href="#request-body" id="request-body"></a>

`Content-Type: application/json`

| Key                        | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `object`                   | `export`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `id`                       | `id` for the job.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `response_timestamp`       | Response timestamp.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `status`                   | <ul><li><code>created</code> Job registered on Spark.</li><li><code>in\_progress</code> Job in progress.</li><li><code>closed</code> Job completed successfully.</li><li><code>closed\_by\_timeout</code> Job was unable to complete within <code>15 min</code>.</li><li><code>failed</code> Job was not able to complete.</li></ul>                                                                                                                                                                           |
| `status_url`               | Link to the `GET` status API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `process_time`             | Time taken for the job.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `outputs.files`            | <p>Array of the output files:</p><ul><li><code>file</code> Link to the package. Filename of the exported object is <code>package.zip</code>. This can be overridden with the <code>file\_name</code> parameter.</li><li><code>file\_hash</code> <code>SHA-256</code> of the packaged file.</li></ul>                                                                                                                                                                                                           |
| `outputs.services`         | <p>Array of the exported services sorted by <code>folder</code>, <code>service</code>:</p><ul><li><code>service\_uri\_source</code> in <code>CS.SPARK\_XCALL()</code> format of <code>{folder}/{service}</code></li><li><code>folder\_source</code></li><li><code>service\_source</code></li><li><code>service\_id\_source</code></li></ul>                                                                                                                                                                    |
| `outputs.service_versions` | <p>Array of the exported service versions sorted by <code>folder\_source</code>, <code>service\_source</code>, <code>version\_source</code>:</p><ul><li><code>service\_uri\_source</code> in <code>CS.SPARK\_XCALL()</code> format of <code>{folder}/{service}\[{version}]</code></li><li><code>folder\_source</code></li><li><code>service\_source</code></li><li><code>version\_source</code> (semantic version)</li><li><code>service\_id\_source</code></li><li><code>version\_id\_source</code></li></ul> |
| `source_system`            | Value from [#api-request-1](#api-request-1 "mention").                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `correlation_id`           | Value from [#api-request-1](#api-request-1 "mention").                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

### Sample request and response

{% tabs %}
{% tab title="Sample request" %}

<details>

<summary></summary>

```shellscript
curl --location 'https://excel.myenvironment.coherent.global/mytenant/api/v4/export/9218acae-55a0-455c-b141-9a0b65a9f100/status' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{Bearer Token}}'
```

</details>
{% endtab %}

{% tab title="Sample response" %}

<details>

<summary></summary>

`HTTP 200 OK` `Content-Type: application/json`

```json
{
  "object": "export",
  "id": "9218acae-55a0-455c-b141-9a0b65a9f100",
  "response_timestamp": "2023-10-31T01:31:34.573Z",
  "status": "completed",
  "status_url": "https://excel.myenvironment.coherent.global/mytenant/v4/export/9218acae-55a0-455c-b141-9a0b65a9f100/status",
  "process_time": 456,
  "outputs": {
    "files": [
      {
        "file": "https://excel.myenvironment.coherent.global/9218acae-55a0-455c-b141-9a0b65a9f100.zip",
        "file_hash": "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
        "zip_process_time": 100
      }
    ],
    "services": [
      {
        "service_uri_source": "myproduct/myservice",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "zip_process_time": 50
      }
    ],
    "service_versions": [
      {
        "service_uri_source": "myproduct/myservice[1.0.0]",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "version_source": "1.0.0",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "version_id_source": "4b05a3ea-92fa-4168-8bcd-5f732a5adc5d"
      },
      {
        "service_uri_source": "myproduct/myservice[1.1.0]",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "version_source": "1.1.0",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "version_id_source": "e0901e15-b305-4d43-b037-3d39cf017260"
      }
    ]
  },
  "source_system": "mycicd",
  "correlation_id": "456"
}
```

</details>
{% endtab %}
{% endtabs %}

## `PATCH` export status to cancel job

{% code overflow="wrap" %}

```shellscript
PATCH /{tenant}/api/v4/export/{jobId}
```

{% endcode %}

### Path parameters

| Key         | Value                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------- |
| `tenant` \* | Tenant is part of your sign-in URL and also available in the [Navigation menu](/navigation/navigation-menu.md#user-menu). |
| `jobId` \*  | `id` from [#api-request-1](#api-request-1 "mention").                                                                     |

### Request body

`Content-Type: application/json`

<table><thead><tr><th>Request body</th><th>Description</th></tr></thead><tbody><tr><td><pre class="language-json"><code class="lang-json"><strong>{ "export_status": "canceled" }
</strong></code></pre></td><td>Include this line in the JSON body to cancel the export at any time.</td></tr></tbody></table>

### Sample request and response

{% tabs %}
{% tab title="Sample request" %}

<details>

<summary></summary>

```shellscript
curl --location --request PATCH 'https://excel.myenvironment.coherent.global/mytenant/api/v4/export/9218acae-55a0-455c-b141-9a0b65a9f100' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{Bearer Token}}' \
--data '{
    "export_status": "canceled"
}'
```

</details>
{% endtab %}

{% tab title="Sample response" %}

<details>

<summary></summary>

`HTTP 200 OK` `Content-Type: application/json`

```json
{
  "object": "export",
  "id": "9218acae-55a0-455c-b141-9a0b65a9f100",
  "response_timestamp": "2023-10-31T01:31:34.573Z",
  "status": "completed",
  "status_url": "https://excel.myenvironment.coherent.global/mytenant/v4/export/9218acae-55a0-455c-b141-9a0b65a9f100/status",
  "process_time": 456,
  "outputs": {
    "files": [
      {
        "file": "https://excel.myenvironment.coherent.global/9218acae-55a0-455c-b141-9a0b65a9f100.zip",
        "file_hash": "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
        "zip_process_time": 100
      }
    ],
    "services": [
      {
        "service_uri_source": "myproduct/myservice",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "zip_process_time": 50
      }
    ],
    "service_versions": [
      {
        "service_uri_source": "myproduct/myservice[1.0.0]",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "version_source": "1.0.0",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "version_id_source": "4b05a3ea-92fa-4168-8bcd-5f732a5adc5d"
      },
      {
        "service_uri_source": "myproduct/myservice[1.1.0]",
        "folder_source": "myproduct",
        "service_source": "myservice",
        "version_source": "1.1.0",
        "service_id_source": "ad04acec-6836-4e0c-9540-c54596509979",
        "version_id_source": "e0901e15-b305-4d43-b037-3d39cf017260"
      }
    ]
  },
  "source_system": "mycicd",
  "correlation_id": "456"
}
```

</details>
{% endtab %}
{% endtabs %}

## `GET` export jobs across the tenant

```shellscript
GET /{tenant}/api/v4/export/status
```

* If you are a `supervisor:pf` user, you will be able to see all exports run by users within your tenant.
* Otherwise, you will only see information about the batches that you initiated.

### Path parameters

| Key         | Value                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------- |
| `tenant` \* | Tenant is part of your sign-in URL and also available in the [Navigation menu](/navigation/navigation-menu.md#user-menu). |

### Sample request and response

{% tabs %}
{% tab title="Sample request" %}

<details>

<summary></summary>

```shellscript
curl --location 'https://excel.myenvironment.coherent.global/mytenant/api/v4/export/status' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{Bearer Token}}'
```

</details>
{% endtab %}

{% tab title="Sample response" %}

<details>

<summary></summary>

`HTTP 200 OK` `Content-Type: application/json`

```json
{
  "in_progress_exports": [
    {
      "object": "export",
      "id": "cb7c09d2-e958-46a9-b7fd-a118503b7f79",
      "data": {
        "export_status": "in_progress",
        "response_timestamp": "2025-08-14T09:46:21.464Z",
        "created_by": "myuser@mydomain.com",
        "created_timestamp": "2025-08-14T09:46:16.255Z",
        "updated_timestamp": "2025-08-14T09:46:16.395Z",
        "process_time": 0
      }
    }
  ],
  "recent_exports": [],
  "tenant": {
    "configuration": {
      "export_api_job_limit": 1
    },
    "status": {
      "export_api_jobs_in_progress": 1
    }
  }
}
```

</details>
{% endtab %}
{% endtabs %}
