0

List a projects users

by
Published Oct 17, 2025

Return a list of users seen within this project.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List a projects users
4
 * Return a list of users seen within this project.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	project_id_or_slug: string,
9
	query?: string | undefined
10
) {
11
	const url = new URL(
12
		`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/users/`
13
	)
14
	for (const [k, v] of [['query', query]]) {
15
		if (v !== undefined && v !== '') {
16
			url.searchParams.append(k, v)
17
		}
18
	}
19
	const response = await fetch(url, {
20
		method: 'GET',
21
		headers: {
22
			Authorization: 'Bearer ' + auth.token
23
		},
24
		body: undefined
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.json()
31
}
32