Bulk Move Pages Using the Confluence Cloud API 

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

Summary

Users can't move Confluence pages in bulk, so moving multiple pages between spaces at once can be difficult.

Problem Description

The standard UI method for reordering pages is not feasible with many pages. Moving pages that need to be reorganized in bulk makes manual adjustments impractical.

Pending feature requests:

Resolution

The steps provided below help move pages in bulk between spaces.

  1. Enable the Admin Key to ensure all pages are sourced and moved successfully.

  2. Obtain the home page ID of the target space and the page IDs of the pages to be moved.

  3. Use the Move Page Position API to bulk move pages.

    1. Construct the API call using the following format:
    2. `fetch('https://your-domain.atlassian.net/wiki/rest/api/content/PAGE_ID/move/POSITION/TARGET_ID', { headers: { 'Accept': 'application/json', 'Atl-Confluence-With-Admin-Key': true } })`
    3. Replace PAGE_ID with the ID of the pages you want to move and TARGET_ID with the home page ID of the new space.

  4. Execute the script to call the API for each page ID from step 2 to move all the pages.

How to Steps

1. Enable Admin Key

Enabling the Admin Key in advance ensures that all pages, including any restricted ones, are sourced when getting the pages and moved during the transfer.

While this step may be unnecessary without restricted pages, it remains a prudent precaution.

(warning) Please be aware that any pages not accessible by your user token will not be transferred to the new space and will remain orphaned.

How To Use Admin Key with API

  • After enabling the key with the Enable Admin Key API

  • Include the following header in each API call to utilize the admin key with your request:

'Atl-Confluence-With-Admin-Key': true

2. How to Retrieve the source PAGE_IDs and destination TARGET_ID

These steps will help you identify all the root pages' IDs within a space. You can do this for all spaces or just one space. (see troubleshooting steps to move child pages)

  1. Retrieve all space and home page IDs using the Get Spaces API

    1. The home page ID of the destination space will serve as a reference for the TARGET_ID.

  2. Fetch all root pages using the Get Pages in Space API

    1. Construct the API call using the following format to return only the pages at the top level of the space, excluding child pages.

    2. /wiki/api/v2/spaces/{spaceId}/pages?depth=root
  3. The ID from the response will be used as the source to move as the PAGE_ID.

3. Move Page API

Utilizing the Confluence API Move Page Position streamlines the process of moving pages.

  • Use append for POSITION

  • The TARGET_ID refers to the home page ID of the new space.

  • PAGE_ID is the ID of the pages you wish to move.

Example

const fetch = require('node-fetch');

fetch('https://your-domain.atlassian.net/wiki/rest/api/content/PAGE_ID/move/POSITION/TARGET_ID', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${Buffer.from(
      'email@example.com:<api_token>'
    ).toString('base64')}`,
    'Accept': 'application/json',
    'Atl-Confluence-With-Admin-Key': true
  }
})
  .then(response => {
    console.log(
      `Response: ${response.status} ${response.statusText}`
    );
    return response.text();
  })
  .then(text => console.log(text))
  .catch(err => console.error(err))


Troubleshooting

  • Capture the logs of the response to review if you hit any limitations (maximum number of child pages, page title already exists, etc)

  • Review these pages to move manually.

  • For the maximum number of child pages

    • You can use a format similar to the steps above, where the TARGET_ID is a copy of the root page in the new space. 

    • Obtain the child pages using the Get direct children of a page API.

    • Follow the rest of the steps above.


Last modified on May 1, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.