# recentlyViewedContent() in CQL: syntax and examples

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

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

- `limit` (optional: yes): How many recently viewed items to take. Required.
- `offset` (optional: no): How many of the most recent items to skip first. Optional.

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

```
id in recentlyViewedContent(5, 5)
```

Items six to ten in your history. Page through the history with the offset. Run on Confluence Cloud on 2026-11-29.

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

```
id in recentlyViewedContent(20) AND lastmodified >= now("-1w") ORDER BY lastmodified DESC
```

Pages you looked at that have changed in the past week, so you can see what moved. Run on Confluence Cloud on 2026-11-29.

```
id NOT IN recentlyViewedContent(10) AND type = page AND space = SD
```

Pages in a space you have not opened lately. Run on Confluence Cloud on 2026-11-29.

## 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", while `recentlyViewedContent(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). `ancestor` and `content` run.

## Related

- [recentlyViewedSpaces()](https://goingstellar.ro/reference/cql/recentlyviewedspaces/)
- [favouriteSpaces()](https://goingstellar.ro/reference/cql/favouritespaces/)
- [currentUser()](https://goingstellar.ro/reference/cql/currentuser/)
- [now()](https://goingstellar.ro/reference/cql/now/)
- [ancestor](https://goingstellar.ro/reference/cql/ancestor-field/)

## Sources

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

