0

Get content restriction status for group

by
Published Oct 17, 2025

Returns whether the specified content restriction applies to a group.

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 content restriction status for group
9
 * Returns whether the specified content restriction applies to a group.
10
 */
11
export async function main(
12
	auth: Confluence,
13
	id: string,
14
	operationKey: 'read' | 'update',
15
	groupId: string
16
) {
17
	const url = new URL(
18
		`https://${auth.domain}/wiki/rest/api/content/${id}/restriction/byOperation/${operationKey}/byGroupId/${groupId}`
19
	)
20

21
	const response = await fetch(url, {
22
		method: 'GET',
23
		headers: {
24
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.text()
33
}
34