0

Retrieve a replay instance

by
Published Oct 17, 2025

Return details on an individual replay.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve a replay instance
4
 * Return details on an individual replay.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	replay_id: string,
9
	statsPeriod?: string | undefined,
10
	start?: string | undefined,
11
	end?: string | undefined,
12
	field?: string | undefined,
13
	project?: string | undefined,
14
	projectSlug?: string | undefined,
15
	environment?: string | undefined,
16
	sort?: string | undefined,
17
	sortBy?: string | undefined,
18
	orderBy?: string | undefined,
19
	query?: string | undefined,
20
	per_page?: string | undefined,
21
	cursor?: string | undefined
22
) {
23
	const url = new URL(
24
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/replays/${replay_id}/`
25
	)
26
	for (const [k, v] of [
27
		['statsPeriod', statsPeriod],
28
		['start', start],
29
		['end', end],
30
		['field', field],
31
		['project', project],
32
		['projectSlug', projectSlug],
33
		['environment', environment],
34
		['sort', sort],
35
		['sortBy', sortBy],
36
		['orderBy', orderBy],
37
		['query', query],
38
		['per_page', per_page],
39
		['cursor', cursor]
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