Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Read Confluence page restrictions with the REST API

GET /wiki/rest/api/content/{id}/restriction returns one entry per operation, read and update, each with a list of users and groups. An empty list means the page has no restriction for that operation. Changing restrictions is a separate set of calls that was not run.

Endpoints

MethodPathWhat it does
GET/wiki/rest/api/content/{id}/restrictionv1: returns the restrictions of a page.
GET/wiki/api/v2/pages/{id}/restriction-statev2: returns the restriction state of a page.

Examples

GET /wiki/rest/api/content/{pageId}/restriction

Reads the restrictions of an unrestricted page.

curl

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

Python (requests)

import os
import requests

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

Response: HTTP 200

{
 "results": [
  {
   "operation": "read",
   "restrictions": {
    "user": {
     "results": [],
     "size": 0
    },
    "group": {
     "results": [],
     "size": 0
    }
   }
  },
  {
   "operation": "update",
   "restrictions": {
    "user": {
     "results": [],
     "size": 0
    },
    "group": {
     "results": [],
     "size": 0
    }
   }
  }
 ],
 "start": 0,
 "limit": 25,
 "size": 2
}

Sent to Atlassian Cloud on .

A search result carries a restrictions key that is empty unless it is expanded.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'cql=space = SD AND type = page AND title ~ "Example"' \
  --data-urlencode 'limit=2' \
  'https://your-domain.atlassian.net/wiki/rest/api/content/search'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/wiki/rest/api/content/search',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'cql': 'space = SD AND type = page AND title ~ "Example"', 'limit': '2'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "results": [
  {
   "id": "33784019",
   "title": "Example page created with v1",
   "restrictions": {}
  }
 ]
}

Sent to Atlassian Cloud on .

GET /wiki/rest/api/user/current

The account id to use when a user must be added to a restriction.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/wiki/rest/api/user/current'

Python (requests)

import os
import requests

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

Response: HTTP 200

{
 "accountId": "<accountId>",
 "accountType": "atlassian",
 "displayName": "<display name>"
}

Sent to Atlassian Cloud on .

How it behaves

  • An unrestricted page returns two operations, read and update, each with empty user and group results and size 0 (conf-restrictions).
  • The response has a start of 0 and a limit of 25 for the users and groups (conf-restrictions).
  • A content object from search has "restrictions": {}, so the call above is needed for the detail (conf-cql-content-search).

Pitfalls

  • Empty user and group lists mean no page-level restriction was set. The call does not describe space permissions.
  • Reading restrictions needs permission to view the content, per the spec.

Questions and answers

How do I restrict a page?

The v1 spec has PUT and POST on the same path. They were not run.

Sources

  1. Get restrictions (Confluence REST API v1)
  2. Get page restriction state (Confluence REST API v2)
  3. The Confluence Cloud REST API v1 (Atlassian Developer)

Markdown version · All REST API pages