# favouriteSpaces() in CQL: syntax and examples (Confluence)

URL: https://goingstellar.ro/reference/cql/favouritespaces/

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 DESC
```

Pages from your starred spaces, newest edit first. A personal what's-new view. Run on Confluence Cloud on 2026-11-29.

```
space IN favouriteSpaces() AND lastmodified >= now("-1w") AND type = page
```

Pages changed this week in the spaces you follow. Run on Confluence Cloud on 2026-11-29.

```
space IN favouriteSpaces() AND title ~ "runbook"
```

Find a runbook, but only in the spaces you care about. Run on Confluence Cloud on 2026-11-29.

```
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 2026-11-29.

```
space NOT IN favouriteSpaces() AND type = page
```

Pages outside your starred spaces. Useful to spot activity you would otherwise miss. Run on Confluence Cloud on 2026-11-29.

## 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.

## Related

- [recentlyViewedSpaces()](https://goingstellar.ro/reference/cql/recentlyviewedspaces/)
- [currentUser()](https://goingstellar.ro/reference/cql/currentuser/)
- [recentlyViewedContent()](https://goingstellar.ro/reference/cql/recentlyviewedcontent/)
- [now()](https://goingstellar.ro/reference/cql/now/)
- [space](https://goingstellar.ro/reference/cql/space-field/)

## Sources

- [CQL functions (Atlassian Developer, Confluence Cloud)](https://developer.atlassian.com/cloud/confluence/cql-functions/)

