0

Retrieve an organizations release

by
Published Oct 17, 2025

Return details on an individual release.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve an organizations release
4
 * Return details on an individual release.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	version: string,
9
	project_id?: string | undefined,
10
	health?: string | undefined,
11
	adoptionStages?: string | undefined,
12
	summaryStatsPeriod?:
13
		| '14d'
14
		| '1d'
15
		| '1h'
16
		| '24h'
17
		| '2d'
18
		| '30d'
19
		| '48h'
20
		| '7d'
21
		| '90d'
22
		| undefined,
23
	healthStatsPeriod?: '14d' | '1d' | '1h' | '24h' | '2d' | '30d' | '48h' | '7d' | '90d' | undefined,
24
	sort?: 'crash_free_sessions' | 'crash_free_users' | 'date' | 'sessions' | 'users' | undefined,
25
	status?: 'archived' | 'open' | undefined,
26
	query?: string | undefined
27
) {
28
	const url = new URL(
29
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/releases/${version}/`
30
	)
31
	for (const [k, v] of [
32
		['project_id', project_id],
33
		['health', health],
34
		['adoptionStages', adoptionStages],
35
		['summaryStatsPeriod', summaryStatsPeriod],
36
		['healthStatsPeriod', healthStatsPeriod],
37
		['sort', sort],
38
		['status', status],
39
		['query', query]
40
	]) {
41
		if (v !== undefined && v !== '') {
42
			url.searchParams.append(k, v)
43
		}
44
	}
45
	const response = await fetch(url, {
46
		method: 'GET',
47
		headers: {
48
			Authorization: 'Bearer ' + auth.token
49
		},
50
		body: undefined
51
	})
52
	if (!response.ok) {
53
		const text = await response.text()
54
		throw new Error(`${response.status} ${text}`)
55
	}
56
	return await response.json()
57
}
58