Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

List child pages with the Confluence REST API

GET /wiki/api/v2/pages/{id}/children returns the direct child pages with id, status, title, spaceId and childPosition. A child is created by giving parentId in v2 or ancestors in v1; both end up in the same list.

Endpoints

MethodPathWhat it does
GET/wiki/api/v2/pages/{id}/childrenLists direct child pages, with limit, cursor and sort.
POST/wiki/api/v2/pagesCreates a page; parentId puts it under a parent.

Examples

POST /wiki/api/v2/pages

Creates a child page by giving parentId.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "spaceId": "{spaceId}",
  "status": "current",
  "title": "Example child page",
  "parentId": "{pageId}",
  "body": {
    "representation": "storage",
    "value": "<p>Child.</p>"
  }
}' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/wiki/api/v2/pages',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'spaceId': '{spaceId}',
          'status': 'current',
          'title': 'Example child page',
          'parentId': '{pageId}',
          'body': {'representation': 'storage', 'value': '<p>Child.</p>'}},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "spaceId": "655364",
 "parentId": "33653083",
 "id": "33620331",
 "title": "Example child page"
}

Sent to Atlassian Cloud on .

POST /wiki/rest/api/content

Creates a second child with the v1 call and an ancestor.

curl

curl -X POST \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
  "type": "page",
  "title": "Example page created with v1",
  "space": {
    "key": "SD"
  },
  "ancestors": [
    {
      "id": "{pageId}"
    }
  ],
  "body": {
    "storage": {
      "value": "<p>v1</p>",
      "representation": "storage"
    }
  }
}' \
  'https://your-domain.atlassian.net/wiki/rest/api/content'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.post(
    'https://your-domain.atlassian.net/wiki/rest/api/content',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    json={'type': 'page',
          'title': 'Example page created with v1',
          'space': {'key': 'SD'},
          'ancestors': [{'id': '{pageId}'}],
          'body': {'storage': {'value': '<p>v1</p>', 'representation': 'storage'}}},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "id": "33784019",
 "title": "Example page created with v1",
 "ancestors": [
  {
   "id": "655541",
   "title": "Software Development"
  }
 ]
}

Sent to Atlassian Cloud on .

GET /wiki/api/v2/pages/{pageId}/children

Lists the children of the parent page.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/wiki/api/v2/pages/{pageId}/children'

Python (requests)

import os
import requests

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

Response: HTTP 200

{
 "results": [
  {
   "id": "33620331",
   "status": "current",
   "title": "Example child page",
   "spaceId": "655364",
   "childPosition": 639
  },
  {
   "id": "33784019",
   "status": "current",
   "title": "Example page created with v1",
   "spaceId": "655364",
   "childPosition": 1247
  }
 ],
 "_links": {
  "base": "https://your-domain.atlassian.net/wiki"
 }
}

Sent to Atlassian Cloud on .

How it behaves

  • The list holds the v2 child and the v1 child, in creation order, each with childPosition (conf-page-children).
  • Each entry has only id, status, title, spaceId and childPosition. No body and no version are included.
  • The v1 call takes the parent as ancestors[0].id; the v2 call takes it as parentId (conf-page-create-v1, conf-page-create-child).

Pitfalls

  • The list is for direct children only. The spec has separate descendants and direct-children paths for deeper trees.
  • Large trees need pagination. Follow the Link header or _links.next instead of building the cursor yourself.
  • The listing carries no body and no version, so a second call is needed to read a child page.

Questions and answers

How do I list all descendants?

The v2 spec has a descendants path. It was not run.

Sources

  1. Get child pages (Confluence REST API v2)
  2. The Confluence Cloud REST API v2 (Atlassian Developer)

Markdown version · All REST API pages