0

List an organizations replays

by
Published Oct 17, 2025

Return a list of replays belonging to an organization.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List an organizations replays
4
 * Return a list of replays belonging to an organization.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	statsPeriod?: string | undefined,
9
	start?: string | undefined,
10
	end?: string | undefined,
11
	field?: string | undefined,
12
	project?: string | undefined,
13
	projectSlug?: string | undefined,
14
	environment?: string | undefined,
15
	sort?: string | undefined,
16
	sortBy?: string | undefined,
17
	orderBy?: string | undefined,
18
	query?: string | undefined,
19
	per_page?: string | undefined,
20
	cursor?: string | undefined
21
) {
22
	const url = new URL(
23
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/replays/`
24
	)
25
	for (const [k, v] of [
26
		['statsPeriod', statsPeriod],
27
		['start', start],
28
		['end', end],
29
		['field', field],
30
		['project', project],
31
		['projectSlug', projectSlug],
32
		['environment', environment],
33
		['sort', sort],
34
		['sortBy', sortBy],
35
		['orderBy', orderBy],
36
		['query', query],
37
		['per_page', per_page],
38
		['cursor', cursor]
39
	]) {
40
		if (v !== undefined && v !== '') {
41
			url.searchParams.append(k, v)
42
		}
43
	}
44
	const response = await fetch(url, {
45
		method: 'GET',
46
		headers: {
47
			Authorization: 'Bearer ' + auth.token
48
		},
49
		body: undefined
50
	})
51
	if (!response.ok) {
52
		const text = await response.text()
53
		throw new Error(`${response.status} ${text}`)
54
	}
55
	return await response.json()
56
}
57