0

Get restrictions by operation

by
Published Oct 17, 2025

Returns restrictions on a piece of content by operation. This method is similar to [Get restrictions](#api-content-id-restriction-get) except that the operations are properties of the return object, rather than items in a results array. **[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 by operation
9
 * Returns restrictions on a piece of content by operation. This method is
10
similar to [Get restrictions](#api-content-id-restriction-get) except that
11
the operations are properties of the return object, rather than items in
12
a results array.
13

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