0

Bulk remove an organizations issues

by
Published Oct 17, 2025

Permanently remove the given issues. If IDs are provided, queries and filtering will be ignored. If any IDs are out of scope, the data won't be mutated but the endpoint will still produce a successful response. For example, if no issues were found matching the criteria, a HTTP 204 is returned.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Bulk remove an organizations issues
4
 * Permanently remove the given issues. If IDs are provided, queries and filtering will be ignored. If any IDs are out of scope, the data won't be mutated but the endpoint will still produce a successful response. For example, if no issues were found matching the criteria, a HTTP 204 is returned.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	environment?: string | undefined,
9
	project?: string | undefined,
10
	id?: string | undefined,
11
	query?: string | undefined,
12
	viewId?: string | undefined,
13
	sort?: 'date' | 'freq' | 'inbox' | 'new' | 'trends' | 'user' | undefined,
14
	limit?: string | undefined
15
) {
16
	const url = new URL(
17
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/issues/`
18
	)
19
	for (const [k, v] of [
20
		['environment', environment],
21
		['project', project],
22
		['id', id],
23
		['query', query],
24
		['viewId', viewId],
25
		['sort', sort],
26
		['limit', limit]
27
	]) {
28
		if (v !== undefined && v !== '') {
29
			url.searchParams.append(k, v)
30
		}
31
	}
32
	const response = await fetch(url, {
33
		method: 'DELETE',
34
		headers: {
35
			Authorization: 'Bearer ' + auth.token
36
		},
37
		body: undefined
38
	})
39
	if (!response.ok) {
40
		const text = await response.text()
41
		throw new Error(`${response.status} ${text}`)
42
	}
43
	return await response.text()
44
}
45