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

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

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.

Only one API key can exist at a time for an instance.

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

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.

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

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

Use Remote API - Step by step

To download an export, the following are needed:

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

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

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

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.

Last updated