CQL function
recentlyViewedSpaces() in CQL: syntax and examples
recentlyViewedSpaces() returns the keys of the spaces the logged-in user viewed recently. You use it on the space field to search the places you have actually been working in, without starring them. It takes one number, the limit.
Syntax
s
p
a
c
e
I
N
r
e
c
e
n
t
l
y
V
i
e
w
e
d
S
p
a
c
e
s
(
l
i
m
i
t
)
Arguments
| Argument | What it does | Optional |
|---|---|---|
limit | How many recently viewed spaces to take. Required. | yes |
Works with
- Fields: space.
- Operators: IN and NOT IN. = fails because the function returns a list.
- Functions: can sit in the same list as plain space keys.
- Not with: no argument, or a second argument.
Examples
space in recentlyViewedSpaces(10)Content from the ten spaces you opened most recently.
Run on Confluence Cloud on .
space IN recentlyViewedSpaces(3) AND title ~ "runbook"Look for a runbook only in the few spaces you were in lately.
Run on Confluence Cloud on .
space IN recentlyViewedSpaces(10) AND type = page AND lastmodified >= now("-1w")Pages changed this week in the spaces you visit, a lightweight daily check.
Run on Confluence Cloud on .
space IN (recentlyViewedSpaces(10), 'SD')Recent spaces plus one fixed space that must always be included.
Run on Confluence Cloud on .
space NOT IN recentlyViewedSpaces(10) AND type = pagePages in spaces you have not visited recently.
Run on Confluence Cloud on .
Pitfalls
- The documentation says the limit must not exceed 200, but
recentlyViewedSpaces(200)fails with "Recents CQL query page size exceeds limit". 199 runs (checked on Confluence Cloud, November 2026). - There is no default.
recentlyViewedSpaces()fails with "Could not parse cql", and so does a second argument as inrecentlyViewedSpaces(10, 5). Unlike recentlyViewedContent(), there is no offset. space = recentlyViewedSpaces(10)fails with "Unable to execute function 'recentlyViewedSpaces', expecting a function that returns a single value". Use IN.- A limit of 0 runs and matches nothing. The list depends on the person who runs the query, so shared saved searches behave differently for each user.