Going Stellar

Home/CQL reference

CQL field

space in CQL (Confluence): syntax and examples

The space field restricts results to content that lives in a given space, identified by its space key. Almost every real CQL query starts with it, because a site-wide search mixes team spaces with personal ones. It also has sub-fields that filter on the space's key, title, type and category.

Syntax

space = KEY
space in (KEY1, KEY2)
space.type = personal

Arguments

ArgumentWhat it does
KEYThe space key, such as SD. Case does not matter. Wrap it in double quotes when it starts with a digit or a tilde.
space.keySub-field that matches the key. Accepts =, !=, IN and NOT IN.
space.titleSub-field that matches the space name. Use ~ or !~.
space.typeSub-field for the kind of space, for example personal or global.
space.categorySub-field for the space category.

Works with

  • Operators: =, !=, IN, NOT IN. The field reference also lists ~ and !~ as unsupported, but both ran (see the pitfalls)
  • Functions: favouriteSpaces(), recentlyViewedSpaces()
  • Not with: >, >=, <, <=

Examples

space = SD AND type = page ORDER BY lastmodified DESC

Lists the pages of one space, most recently edited first. A good start for any clean-up or review of a team space.

Run on Confluence Cloud on .

space in ("3C", "4C")

Searches two spaces at once when their keys start with a digit, which is why the keys are quoted.

Run on Confluence Cloud on .

space.type = personal AND type = attachment

Finds files that sit in personal spaces, where nobody else is likely to look for them.

Run on Confluence Cloud on .

space.title ~ "Software" AND type = page

Picks spaces by a word in their name when you do not remember the key.

Run on Confluence Cloud on .

space != SD

Shows everything outside your main space, which is mostly personal-space content.

Run on Confluence Cloud on .

space.key in (SD, "3C") AND type = page

Combines a plain key and a quoted key in one list, using the key sub-field.

Run on Confluence Cloud on .

Pitfalls

  • A key that starts with a digit must be quoted. space = 3C fails with "Unrecognised clause at : C", while space = "3C" runs. Personal space keys start with a tilde and are long, so quote them too: space = ~abc fails with "Expecting a value for operator '=' after field 'space' but got '~'".
  • space compares keys, not names. space = "Software Development" runs and finds nothing. For the name use space.title ~ "Software". space.title = "Software" and space.key ~ "SD" do not work: the first gives "Could not parse cql", the second "Operator '~' is not supported for field 'space.key'".
  • The doc table says space ~ and space !~ are unsupported. space ~ "Software" and space !~ "Software" both run and match the space name (checked on Confluence Cloud, November 2026). The sub-field space.title ~ gives the same match, so prefer it in filters you keep.
  • A query on space = SD alone also returns the space itself as a result, next to its pages, comments and attachments. Add AND type != space or AND type = page when you only want content.

Questions and answers

How do I find the key of a space?

It is the short code in the space URL, for example /spaces/SD/overview. The key is also listed in space settings.

Can I search every space except one?

Yes. Use space != SD or space not in (SD, ENG).

Sources

  1. CQL fields (Atlassian Developer, Confluence Cloud)

Markdown version · All CQL pages