0

List a teams projects

by
Published Oct 17, 2025

Return a list of projects bound to a team.

Script sentry Verified

The script

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