0

Bulk remove a list of issues

by
Published Oct 17, 2025

Permanently remove the given issues. The list of issues to modify is given through the `id` query parameter. It is repeated for each issue that should be removed. Only queries by 'id' are accepted. If any IDs are out of scope this operation will succeed without any data mutation.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Bulk remove a list of issues
4
 * Permanently remove the given issues. The list of issues to modify is given through the `id` query parameter.  It is repeated for each issue that should be removed.
5

6
Only queries by 'id' are accepted.
7

8
If any IDs are out of scope this operation will succeed without any data mutation.
9
 */
10
export async function main(auth: RT.Sentry, project_id_or_slug: string, id?: string | undefined) {
11
	const url = new URL(
12
		`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/issues/`
13
	)
14
	for (const [k, v] of [['id', id]]) {
15
		if (v !== undefined && v !== '') {
16
			url.searchParams.append(k, v)
17
		}
18
	}
19
	const response = await fetch(url, {
20
		method: 'DELETE',
21
		headers: {
22
			Authorization: 'Bearer ' + auth.token
23
		},
24
		body: undefined
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.text()
31
}
32