0

List spike protection notifications

by
Published Oct 17, 2025

Returns all Spike Protection Notification Actions for an organization. Notification Actions notify a set of members when an action has been triggered through a notification service such as Slack or Sentry. For example, organization owners and managers can receive an email when a spike occurs. You can use either the `project` or `projectSlug` query parameter to filter for certain projects. Note that if both are present, `projectSlug` takes priority.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * List spike protection notifications
4
 * Returns all Spike Protection Notification Actions for an organization.
5

6
Notification Actions notify a set of members when an action has been triggered through a notification service such as Slack or Sentry.
7
For example, organization owners and managers can receive an email when a spike occurs.
8

9
You can use either the `project` or `projectSlug` query parameter to filter for certain projects. Note that if both are present, `projectSlug` takes priority.
10
 */
11
export async function main(
12
	auth: RT.Sentry,
13
	project?: string | undefined,
14
	project_id_or_slug?: string | undefined,
15
	triggerType?: string | undefined
16
) {
17
	const url = new URL(
18
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/notifications/actions/`
19
	)
20
	for (const [k, v] of [
21
		['project', project],
22
		['project_id_or_slug', project_id_or_slug],
23
		['triggerType', triggerType]
24
	]) {
25
		if (v !== undefined && v !== '') {
26
			url.searchParams.append(k, v)
27
		}
28
	}
29
	const response = await fetch(url, {
30
		method: 'GET',
31
		headers: {
32
			Authorization: 'Bearer ' + auth.token
33
		},
34
		body: undefined
35
	})
36
	if (!response.ok) {
37
		const text = await response.text()
38
		throw new Error(`${response.status} ${text}`)
39
	}
40
	return await response.json()
41
}
42