0

List an organizations paginated teams

by
Published Oct 17, 2025

Returns a paginated list of teams bound to a organization with a SCIM Groups GET Request. Note that the members field will only contain up to 10,000 members.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List an organizations paginated teams
4
 * Returns a paginated list of teams bound to a organization with a SCIM Groups GET Request.
5

6
Note that the members field will only contain up to 10,000 members.
7
 */
8
export async function main(
9
	auth: RT.Sentry,
10
	startIndex?: string | undefined,
11
	count?: string | undefined,
12
	filter?: string | undefined,
13
	excludedAttributes?: string | undefined
14
) {
15
	const url = new URL(
16
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/scim/v2/Groups`
17
	)
18
	for (const [k, v] of [
19
		['startIndex', startIndex],
20
		['count', count],
21
		['filter', filter],
22
		['excludedAttributes', excludedAttributes]
23
	]) {
24
		if (v !== undefined && v !== '') {
25
			url.searchParams.append(k, v)
26
		}
27
	}
28
	const response = await fetch(url, {
29
		method: 'GET',
30
		headers: {
31
			Authorization: 'Bearer ' + auth.token
32
		},
33
		body: undefined
34
	})
35
	if (!response.ok) {
36
		const text = await response.text()
37
		throw new Error(`${response.status} ${text}`)
38
	}
39
	return await response.json()
40
}
41