0

Remove a space permission

by
Published Oct 17, 2025

Removes a space permission. Note that removing Read Space permission for a user or group will remove all the space permissions for that user or group. Note: Apps cannot access this REST resource - including when utilizing user impersonation. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space.

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 a space permission
9
 * Removes a space permission. Note that removing Read Space permission for a user or group will remove all
10
the space permissions for that user or group.
11

12
Note: Apps cannot access this REST resource - including when utilizing user impersonation.
13

14
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
15
'Admin' permission for the space.
16
 */
17
export async function main(auth: Confluence, spaceKey: string, id: string) {
18
	const url = new URL(`https://${auth.domain}/wiki/rest/api/space/${spaceKey}/permission/${id}`)
19

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