CQL function
recentlyViewedContent() in CQL: syntax and examples
recentlyViewedContent() returns the IDs of content the logged-in user viewed recently. Combined with id IN, it turns your browsing history into a filter you can add words, types and dates to. It takes a limit and an optional offset.
Syntax
id IN recentlyViewedContent(limit)
id IN recentlyViewedContent(limit, offset)
Arguments
| Argument | What it does | Optional |
|---|---|---|
limit | How many recently viewed items to take. Required. | yes |
offset | How many of the most recent items to skip first. Optional. | no |
Works with
- Fields: id, content and ancestor ran. parent is listed in the documentation but failed.
- Operators: IN and NOT IN. = and != fail.
- Not with: no argument at all. The size limit applies to limit plus offset.
Examples
id in recentlyViewedContent(10)The last ten items you opened. Useful when you remember reading a page but not its title.
Run on Confluence Cloud on .
id in recentlyViewedContent(5, 5)Items six to ten in your history. Page through the history with the offset.
Run on Confluence Cloud on .
id in recentlyViewedContent(20) AND title ~ "runbook"Find the runbook you read last week by searching only your recent history.
Run on Confluence Cloud on .
id in recentlyViewedContent(20) AND lastmodified >= now("-1w") ORDER BY lastmodified DESCPages you looked at that have changed in the past week, so you can see what moved.
Run on Confluence Cloud on .
id NOT IN recentlyViewedContent(10) AND type = page AND space = SDPages in a space you have not opened lately.
Run on Confluence Cloud on .
Pitfalls
- Without an argument it fails:
id in recentlyViewedContent()gives "Could not parse cql". A non-number gives "Invalid size limit : a". - The total of limit and offset is capped at 200.
recentlyViewedContent(100, 101)fails with "Recents CQL query page size exceeds limit", whilerecentlyViewedContent(200)runs. - An offset past the end of the history is not an error. It just matches nothing, when the history is shorter than the offset, as with
recentlyViewedContent(10, 20)on a short history. - The documentation lists parent as a supported field, but
parent in recentlyViewedContent(10)fails with HTTP 500 "IllegalArgumentException executing cql" (checked on Confluence Cloud, November 2026).ancestorandcontentrun.