0

Retrieve a monitor for a project

by
Published Oct 17, 2025

Retrieves details for a monitor.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieve a monitor for a project
4
 * Retrieves details for a monitor.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	project_id_or_slug: string,
9
	monitor_id_or_slug: string
10
) {
11
	const url = new URL(
12
		`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/monitors/${monitor_id_or_slug}/`
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