0

Get group members

by
Published Oct 17, 2025

Returns the users that are members of a group. Use updated Get group API **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site ('Can use' global permission).

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 group members
9
 * Returns the users that are members of a group.
10

11
Use updated Get group API
12

13
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
14
Permission to access the Confluence site ('Can use' global permission).
15
 */
16
export async function main(
17
	auth: Confluence,
18
	groupId: string,
19
	start: string | undefined,
20
	limit: string | undefined,
21
	shouldReturnTotalSize: string | undefined,
22
	expand: string | undefined
23
) {
24
	const url = new URL(`https://${auth.domain}/wiki/rest/api/group/${groupId}/membersByGroupId`)
25
	for (const [k, v] of [
26
		['start', start],
27
		['limit', limit],
28
		['shouldReturnTotalSize', shouldReturnTotalSize],
29
		['expand', expand]
30
	]) {
31
		if (v !== undefined && v !== '' && k !== undefined) {
32
			url.searchParams.append(k, v)
33
		}
34
	}
35
	const response = await fetch(url, {
36
		method: 'GET',
37
		headers: {
38
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
39
		},
40
		body: undefined
41
	})
42
	if (!response.ok) {
43
		const text = await response.text()
44
		throw new Error(`${response.status} ${text}`)
45
	}
46
	return await response.json()
47
}
48