0

Get restrictions

by
Published Oct 17, 2025

Returns the restrictions on a piece of content. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content.

Script confluence Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Confluence = {
3
	email: string
4
	apiToken: string
5
	domain: string
6
}
7
/**
8
 * Get restrictions
9
 * Returns the restrictions on a piece of content.
10

11
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
12
Permission to view the content.
13
 */
14
export async function main(
15
	auth: Confluence,
16
	id: string,
17
	expand: string | undefined,
18
	start: string | undefined,
19
	limit: string | undefined
20
) {
21
	const url = new URL(`https://${auth.domain}/wiki/rest/api/content/${id}/restriction`)
22
	for (const [k, v] of [
23
		['expand', expand],
24
		['start', start],
25
		['limit', limit]
26
	]) {
27
		if (v !== undefined && v !== '' && k !== undefined) {
28
			url.searchParams.append(k, v)
29
		}
30
	}
31
	const response = await fetch(url, {
32
		method: 'GET',
33
		headers: {
34
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
35
		},
36
		body: undefined
37
	})
38
	if (!response.ok) {
39
		const text = await response.text()
40
		throw new Error(`${response.status} ${text}`)
41
	}
42
	return await response.json()
43
}
44