# 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. The API is designed not to proceed if a successful export cannot be completed.

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

* Only `1` job can be executed at once per tenant.
* All the referenced objects need to exist and accessible with the provided authorization.
* Any referenced folders most contain a service.
* All referenced services must have a compiled [Neuron](/build-spark-services/neuron.md) WebAssembly module.
* The requested package size does not exceed the configured limit (default to `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).\
  The [Authorization - API keys](/spark-apis/authorization-api-keys.md#api-key-groups) must contain [Manage users](/tenant-administration/manage-users.md#user-groups) 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>

Returns: Response from [#get-export-status](#get-export-status "mention").

{% code overflow="wrap" %}

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

{% endcode %}

### Path parameters

<table><thead><tr><th width="374">Key</th><th>Value</th></tr></thead><tbody><tr><td><code>tenant</code> *</td><td>Tenant is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL and also available in the  <a data-mention href="/pages/ylWjjoVBLOcB7JZks4Cp#user-menu">/pages/ylWjjoVBLOcB7JZks4Cp#user-menu</a>.</td></tr></tbody></table>

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

`Content-Type: application/json`

Note that the union of the `input` service identifiers will be included as part of the exported package.

| Key                  | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `inputs.folders`     | Array of folder names.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `inputs.services`    | <p>Array of <code>C.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="/pages/c1K85gVQxaAyBlgrHsDD">/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

```shell
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"
}'
```

### Response <a href="#request_data" id="request_data"></a>

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

Returns the response from [#get-export-status](#get-export-status "mention").

## `GET` export status

Returns: `status` response and link to download the ZIP file.

{% code overflow="wrap" %}

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

{% endcode %}

### Path parameters

<table><thead><tr><th width="374">Key</th><th>Value</th></tr></thead><tbody><tr><td><code>tenant</code> *</td><td>Tenant is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL and also available in the  <a data-mention href="/pages/ylWjjoVBLOcB7JZks4Cp#user-menu">/pages/ylWjjoVBLOcB7JZks4Cp#user-menu</a>.</td></tr><tr><td><code>jobId</code> *</td><td><code>id</code> from <a data-mention href="#api-request-1">#api-request-1</a>.</td></tr></tbody></table>

### 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</code> minutes.</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>C.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>C.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 response

`HTTP 200 OK` `Content-Type: application/json`&#x20;

```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"
}
```

## `PATCH` export

Change `export` job status. This can cancel an errant job.

Returns: Response from [#get-export-status](#get-export-status "mention").

{% code overflow="wrap" %}

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

{% endcode %}

### Path parameters

<table><thead><tr><th width="374">Key</th><th>Value</th></tr></thead><tbody><tr><td><code>environment</code> *</td><td>Environment is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL.</td></tr><tr><td><code>tenant</code> *</td><td>Tenant is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL and also available in the  <a data-mention href="/pages/ylWjjoVBLOcB7JZks4Cp#user-menu">/pages/ylWjjoVBLOcB7JZks4Cp#user-menu</a>.</td></tr><tr><td><code>jobId</code> *</td><td><code>id</code> from <a data-mention href="#api-request-1">#api-request-1</a>.</td></tr></tbody></table>

### Request

&#x20;`Content-Type: application/json`

```json
{"export_status":"cancelled"}
```

### Response

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

Returns the response from [#get-export-status](#get-export-status "mention").

## `GET` export status across the tenant

Get information about export jobs that are `in_progress_exports` or `recent_exports` within the past `1 h`.

Returns: Export jobs.

* 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 were initiated by yourself.

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

### Path parameters

<table><thead><tr><th width="374">Key</th><th>Value</th></tr></thead><tbody><tr><td><code>environment</code> *</td><td>Environment is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL.</td></tr><tr><td><code>tenant</code> *</td><td>Tenant is part of your <a data-mention href="/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark">/pages/-MboyUpg0GSvjBVkVMcw#log-in-to-spark</a> URL and also available in the  <a data-mention href="/pages/ylWjjoVBLOcB7JZks4Cp#user-menu">/pages/ylWjjoVBLOcB7JZks4Cp#user-menu</a>.</td></tr></tbody></table>

### Sample response

`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
        }
    }
}
```


---

# 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.coherent.global/spark-apis/impex-apis/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.
