0

Remove group from content restriction

by
Published Oct 17, 2025

Removes a group from a content restriction. That is, remove read or update permission for the group for a piece of content. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit 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
 * Remove group from content restriction
9
 * Removes a group from a content restriction. That is, remove read or update
10
permission for the group for a piece of content.
11

12
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
13
Permission to edit the content.
14
 */
15
export async function main(
16
	auth: Confluence,
17
	id: string,
18
	operationKey: 'read' | 'update',
19
	groupId: string
20
) {
21
	const url = new URL(
22
		`https://${auth.domain}/wiki/rest/api/content/${id}/restriction/byOperation/${operationKey}/byGroupId/${groupId}`
23
	)
24

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