CQL function
favouriteSpaces() in CQL: syntax and examples (Confluence)
favouriteSpaces() returns the keys of the spaces the logged-in user has starred. You use it on the space field to narrow a search to the places you work in. The result is a list, so it goes with IN or NOT IN.
Syntax
space IN favouriteSpaces()
space IN (favouriteSpaces(), 'KEY1', 'KEY2')
Works with
- Fields: space.
- Operators: IN and NOT IN. = and != fail because the function returns a list.
- Functions: can sit in the same list as plain space keys.
- Not with: arguments. The function takes none.
Examples
space IN favouriteSpaces() AND type = page ORDER BY lastmodified DESCPages from your starred spaces, newest edit first. A personal what's-new view.
Run on Confluence Cloud on .
space IN favouriteSpaces() AND lastmodified >= now("-1w") AND type = pagePages changed this week in the spaces you follow.
Run on Confluence Cloud on .
space IN favouriteSpaces() AND title ~ "runbook"Find a runbook, but only in the spaces you care about.
Run on Confluence Cloud on .
space IN (favouriteSpaces(), 'SD')Your starred spaces plus one more by key, for example a space you search often but never starred.
Run on Confluence Cloud on .
space NOT IN favouriteSpaces() AND type = pagePages outside your starred spaces. Useful to spot activity you would otherwise miss.
Run on Confluence Cloud on .
Pitfalls
- = and != fail:
space = favouriteSpaces()gives "Unable to execute function 'favouriteSpaces', expecting a function that returns a single value". Use IN or NOT IN. - The American spelling is not accepted as a function name.
space IN favoriteSpaces()fails with "Could not parse cql" (checked on Confluence Cloud, November 2026), even though the favourite field accepts both spellings. - It takes no argument.
favouriteSpaces(5)fails with "Could not parse cql". Cut the list down with other conditions instead. - The function reads the favourites of the person who runs the query, so a saved query returns different pages for different people.