0

Create new user group

by
Published Oct 17, 2025

Creates a new user group. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: User must be a site admin.

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
 * Create new user group
9
 * Creates a new user group.
10

11
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
12
User must be a site admin.
13
 */
14
export async function main(auth: Confluence, body: { name: string }) {
15
	const url = new URL(`https://${auth.domain}/wiki/rest/api/group`)
16

17
	const response = await fetch(url, {
18
		method: 'POST',
19
		headers: {
20
			'Content-Type': 'application/json',
21
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
22
		},
23
		body: JSON.stringify(body)
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31