Use includeArchivedSpaces parameter in CQL

By default the archived Confluence space won’t be listed the search results in the Confluence UI. This also applies to CQL. If you want to include the archived space in your CQL query result, then you need to add includeArchivedSpaces=true in your CQL query.

For example, I want to find out all Confluence spaces (including archived ones) that are in the category Cloud. The CQL query is like this:

space.category=cloud and type=space

To run it via the Confluence REST API, remember to append the includeArchivedSpaces=trues to the URL.

Here is a nodejs sample:

* Confluence CQL sample
* Find all spaces (including archived ones) that are in Cloud category
const request = require('request')
const options = {
headers: { "Content-Type": "application/json" },
auth: {
user: process.env.USERNAME,
password: process.env.PASSWORD
function runCQL (confluenceURL, cql) {
options.url = confluenceURL + '/rest/api/search?cql=' + cql
request.get (options, function(err, res, body) {
if (err) {
} else {
const category = 'cloud'
const cql = 'space.category="' + category + '" and type=space' + '&includeArchivedSpaces=true'
runCQL(process.env.CONFLUENCE, cql)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s