How to delete spaces in bulk using Confluence Command Line Interface (CLI)

This article presents step by step instructions on how to delete spaces in bulk using the Confluence CLI app.


For this task, use the runFromSpaceList  along with removeSpace actions as explained. Use the removeSpace action to delete spaces from Confluence. 

Option 1: 

  1. Execute the following command if you have the space keys list . In the below example, clispace1, clispace2, clispace3 are the space key. 

    --action runFromSpaceList --input "--action removeSpace --space clispace1" --input "--action removeSpace --space clispace2" --input "--action removeSpace --space clispace3"


Option 2: 

If you are not aware of the space keys, then follow the below steps. 

  1. Create a CSV file with the space keys that need to be removed. Run the following command using the getSpaceList action. 

    --action getSpaceList --file "spacelist.csv"
  2. Run the following CLI action along with the runFromCsv action to delete spaces. Ensure that the spacelist.csv file has only space keys with the column name 'space'.

    --action runFromCsv --file "spacelist.csv" --common "--action removeSpace" --continue

    Sample CSV file:

    The parameters used in the above actions are:

    • --space: Space key.

    • --removeSpace: Remove a space by key.
    • --input: Line of input used in place of file data for run actions. One or more input parameters are used as lines instead of using the file parameter. In some cases requiring a file parameter, it may be necessary to use a special value of + to indicate to use the input parameters instead.
    • --Common: Common parameter string added to all run actions.
    • --continue: Continue processing even after errors are encountered for run actions. Also used for some action to ignore certain errors like not found errors on remove actions.
    • --file: Path to file based content.

  • Test the action in a test environment before implementing in production.