# Remote API (Cloud only)

It is possible to start an export and download the result remotely through a Remote API.

## Set up Remote API

First, set the Remote API to "enabled" on the Content Exporter admin page. Go to the Content Exporter section on the Confluence administration page and choose Remote API menu point, then enable Remote API

<figure><img src="/files/4DFuhrJAnrX9cHKC4VUb" alt=""><figcaption></figcaption></figure>

After clicking the button, the next page will show the user, in whose behalf the exports will be started.&#x20;

{% hint style="warning" %}
Currently, the user account for starting exports remotely cannot be changed from the logged in admin user (Current User). Make sure to generate the API Key with a user with proper permissions on the pages that are meant to be exported.&#x20;

Only one API key can exist at a time for an instance.
{% endhint %}

<figure><img src="/files/2glERWO4zLTCsKMY7RPH" alt=""><figcaption></figcaption></figure>

Click on the Generate API key button. On the next screen, click the Copy to copy the generated API key to the clipboard.&#x20;

<figure><img src="/files/OTu5EwGY9couaAzMyEAU" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
Make sure the API key is saved. For security reasons, it can only be copied at the time of generation. Once the Done button is clicked, the generated API key cannot be revealed anymore. If a new API key is needed, the Enable Remote API toggle should be switched off - thus the old API key will be lost - and on again.
{% endhint %}

Click the Done button. The Remote API screen shows the user to whom the API key belongs.

<figure><img src="/files/jIhBiJSpIeD95ydi2FCW" alt=""><figcaption></figcaption></figure>

If the API key needs to be revoked or another API key needs to be generated, set the Enable Remote API toggle to off.&#x20;

## Use Remote API - Step by step

### To download an export, the following are needed:

* the generated API key (see section Set up Remote API)
* URL of the running application \<APPLICATION\_URL>
  * for the US region: [https://content-exporter-new.addon.meta-inf.hu](https://content-exporter-new.addon.meta-inf.hu/)
  * for the EU region: [https://content-exporter-new.addon-eu.meta-inf.hu](https://content-exporter-new.addon-eu.meta-inf.hu/)&#x20;
* the ID of the (parent) page \<PAGE\_ID>

### POST Start Export

```
http://<APPLICATION_URL>/api/remoteExport/<PAGE_ID>/init
```

For the Start Export API add the **generated API** key as a header

Key: CEX-API-KEY\
Value: \<the generated API key>

The **parent page ID** should be added both in the URL and in the Request body's **rootContentId**

See an example for the Request body below

````json
```postman_json
{
  "pageSettings": {
    "size": "A4",
    "orientation": "PORTRAIT"
  },
  "margins": [
    {
      "top": 1,
      "bottom": 1,
      "right": 0.5,
      "left": 0.5
    }
  ],
  "unit": "IN",
  "tocLevel": 6,
  "tocTitle": "Table of Contents",
  "tocMode": "FLAT",
  "fontResize": true,
  "headingNumbering": false,
  "pageNumbersArea": {
    "numbersFrom": "COVER_PAGE",
    "numbersTo": "BACK_COVER_PAGE"
  },
  "rootContentId": 1234567,
  "outputFormat": "PDF_MERGE",
  "exportType": "ALL_CHILD",
  "frontCover": 123456789,
  "labels": null,
  "selectedContentIdList": []
}
```
````

As a best practice, we suggest starting a desired export from the UI for the first time while the console's Network tab is open and using the proper parameters from the init call's payload.

<figure><img src="/files/d3M86mU6xkR5rpiE23bQ" alt=""><figcaption></figcaption></figure>

It is also possible to download the Export Profile from the Export Profile admin page as a JSON file as a reference.

<figure><img src="/files/Kf3lWZXOG9UCzPsFcSrU" alt=""><figcaption></figcaption></figure>

The Start Export call should return a **hash**. **This hash is needed in the following steps.**

### GET Poll started export progress

```
http://<APPLICATION_URL>/api/remoteExport/poll?hash=<HASH>
```

For the Poll started export progress API add the **generated API** key as a header

Key: CEX-API-KEY\
Value: \<the generated API key>

An example response of the poll request looks like the following json.

````
```json
{
    "done": true,
    "progressData": {
        "phase": "CONVERTING_PAGES",
        "progressValue": 100
    }
}
```
````

Poll until the "progressValue" parameter reaches 100.

### GET Download export

```
http://<APPLICATION URL>/api/remoteExport/download?hash=<HASH>
```

For the Poll started export progress API add the **generated API** key as a header

Key: CEX-API-KEY\
Value: \<the generated API key>

Save the response to a file.

### OpenAPI descriptor

The full OpenAPI descriptor of the Remote API can be downloaded below.

{% file src="/files/ZteRJaZIKXmZ4tHkAIS4" %}


---

# 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.meta-inf.hu/content-exporter-confluence/user-guides/before-exporting/remote-api-cloud-only.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.
