How to delete the current version of a  page from a Confluence using the REST API

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Using the REST API might be helpful to automate some operations on Confluence.

A Confluence user or the administrator may need to delete a page in Confluence without using the GUI or using the database for it , but going through the User Interface (UI) could be rather impractical depending on the situation (for example the page is not accessible via browser).

This document provides a step-by-step procedure on how to use the Confluence REST API to delete the current version of a page, provided you have the pageid.

The suggested solution is provided as a set of bash commands using curl to run the REST API call. You may use this as an example to create an automation tool in your preferred coding language.

Solution

The suggested solution will permanently delete the current version of the page.

It is recommended you test this in a lower environment to understand the consequences of it before applying your solution in a production environment.

Also, is very recommended that you have a backup of your system.

  1. Set up environment variables as suggested below.

    1 2 3 4 USER_NAME=<username> ### You must be either a Space Administrator or a Confluence Administrator since we will purge the trash USER_PASSWORD=<user password> CONFLUENCE_BASEURL=<Confluence Base URL> ### FQDN and context path without the trailing slash CONTENT_ID=<page ID>
  2. Send the page to the Space Trash.

    The DELETE operation will change the page status from CURRENT to TRASHED. The expected HTTP status for this request is 204. This operation can be reverted from the UI by accessing the Space Trash.

    1 curl -u ${USER_NAME}:${USER_PASSWORD} -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE ${CONFLUENCE_BASEURL}'/rest/api/content/'${CONTENT_ID}'?status=current'
  3. Purge the page from the trash.

    This is the operation that will delete the page metadata from the Confluence database and the actual file(s) from the file system. The expected HTTP status for this request is 204. This operation cannot be reverted.

    1 curl -v -u ${USER_NAME}:${USER_PASSWORD} -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE ${CONFLUENCE_BASEURL}'/rest/api/content/'${CONTENT_ID}'?status=trashed' >/dev/null

With the steps above we provided an example of how to completely delete the current version of a page.

With this, you may be able to create a script in your preferred coding language to delete a set of pages.

See Also

Updated on March 24, 2025

Still need help?

The Atlassian Community is here for you.