# Confluence v2 cursor pagination with Link and _links.next

URL: https://goingstellar.ro/reference/atlassian-rest-api/pagination-cursor-links/

Confluence v2 collections take limit and cursor. A response with more results carries the next page as a relative URL, both in the Link header with rel next and in _links.next in the body. Follow that URL as given, prefixed with the site host, and do not build cursors by hand.

## Endpoints

| Method | Path | What it does |
|---|---|---|
| GET | `/wiki/api/v2/spaces/{id}/pages` | Pages the pages of a space. |
| GET | `/wiki/api/v2/pages` | Pages all pages the caller can see. |

## Examples

### GET /wiki/api/v2/spaces/{spaceId}/pages

First page with limit 1: the next URL is in _links.next and in the Link header.

```bash
curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'limit=1' \
  'https://your-domain.atlassian.net/wiki/api/v2/spaces/{spaceId}/pages'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/wiki/api/v2/spaces/{spaceId}/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'limit': '1'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "results": [
  {
   "status": "current",
   "title": "Software Development",
   "id": "655541"
  }
 ],
 "_links": {
  "next": "/wiki/api/v2/spaces/655364/pages?limit=1&cursor=eyJpZCI6IjY1NTU0MSIsImNvbnRlbnRPcmRlciI6ImlkIiwiY29udGVudE9yZGVyVmFsdWUiOjY1NTU0MX0=",
  "base": "https://your-domain.atlassian.net/wiki"
 }
}
```

Response headers:

```
Link: </wiki/api/v2/spaces/655364/pages?limit=1&cursor=eyJpZCI6IjY1NTU0MSIsImNvbnRlbnRPcmRlciI6ImlkIiwiY29udGVudE9yZGVyVmFsdWUiOjY1NTU0MX0=>; rel="next", <https://your-domain.atlassian.net/wiki>; rel="base"
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /wiki/api/v2/spaces/{spaceId}/pages

Adding sort=id gave the same first page and the same cursor as the default.

```bash
curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'limit=1' \
  --data-urlencode 'sort=id' \
  'https://your-domain.atlassian.net/wiki/api/v2/spaces/{spaceId}/pages'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/wiki/api/v2/spaces/{spaceId}/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'limit': '1', 'sort': 'id'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "results": [
  {
   "title": "Software Development",
   "id": "655541"
  }
 ],
 "_links": {
  "next": "/wiki/api/v2/spaces/655364/pages?limit=1&cursor=eyJpZCI6IjY1NTU0MSIsImNvbnRlbnRPcmRlciI6ImlkIiwiY29udGVudE9yZGVyVmFsdWUiOjY1NTU0MX0="
 }
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET {_links.next}

Follows the value of _links.next from the previous response as the request path.

```bash
curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net{_links.next}'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net{_links.next}',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "results": [
  {
   "id": "655577",
   "status": "current",
   "title": "Template - Product requirements"
  }
 ],
 "_links": {
  "next": "/wiki/api/v2/spaces/655364/pages?cursor=eyJpZCI6IjY1NTU3NyIsImNvbnRlbnRPcmRlciI6ImlkIiwiY29udGVudE9yZGVyVmFsdWUiOjY1NTU3N30=&limit=1"
 }
}
```

Response headers:

```
Link: </wiki/api/v2/spaces/655364/pages?cursor=eyJpZCI6IjY1NTU3NyIsImNvbnRlbnRPcmRlciI6ImlkIiwiY29udGVudE9yZGVyVmFsdWUiOjY1NTU3N30=&limit=1>; rel="next", <https://your-domain.atlassian.net/wiki>; rel="base"
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /wiki/api/v2/pages

A small result needs no cursor: the Link header holds only the base entry.

```bash
curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'title=Example page' \
  --data-urlencode 'space-id={spaceId}' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/wiki/api/v2/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'title': 'Example page', 'space-id': '{spaceId}'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "results": [
  {
   "id": "33653083",
   "title": "Example page"
  }
 ],
 "_links": {
  "base": "https://your-domain.atlassian.net/wiki"
 }
}
```

Response headers:

```
Link: <https://your-domain.atlassian.net/wiki>; rel="base"
```

Sent to Atlassian Cloud on 29 Nov 2026.

## How it behaves

- The first page with limit=1 returned one page, _links.next as a path starting with /wiki/api/v2/spaces/{id}/pages and a cursor parameter.
- The Link header held the same relative URL with rel next, followed by the site base URL with rel base.
- The next URL repeats limit and puts cursor in the query string, and its parameter order differed between the first and second page.
- The follow-up call used the _links.next value as its path and answered 200 with the next page.
- A request with no further pages (by title) had a Link header with rel base only and no next entry in _links.

## Pitfalls

- The next URL is relative to the site root and already includes /wiki. Join it to the host, not to another path.
- Do not parse the cursor. It is opaque and the order of query parameters can change between pages.
- limit defaults to 25 with a maximum of 250 per the v2 pages reference, and some endpoints have different limits.

## Questions and answers

### Header or body for the next link?

Both carry it. The v2 guide says the relative URL in the Link header is also available under _links.next of the response.

### Is there a total count?

None of the v2 pages above includes one. Count by walking the pages.

## Related

- [startAt and maxResults](https://goingstellar.ro/reference/atlassian-rest-api/pagination-startat-maxresults/)
- [nextPageToken in Jira search](https://goingstellar.ro/reference/atlassian-rest-api/pagination-nextpagetoken/)
- [Get a page](https://goingstellar.ro/reference/atlassian-rest-api/get-page/)
- [Child pages](https://goingstellar.ro/reference/atlassian-rest-api/page-children/)
- [Find a page by title](https://goingstellar.ro/reference/atlassian-rest-api/find-page-by-title/)
- [Confluence REST API v1 vs v2](https://goingstellar.ro/reference/atlassian-rest-api/confluence-v1-vs-v2/)

## Sources

- [The Confluence Cloud REST API v2 (Atlassian Developer)](https://developer.atlassian.com/cloud/confluence/rest/v2/intro/)
- [Get pages (Confluence REST API v2)](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-get)

