0

Remove modules

by
Published Oct 17, 2025

Remove all or a list of modules registered by the calling app. **[Permissions](#permissions) required:** Only Connect apps can make this request.

Script confluence Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Confluence = {
3
	email: string
4
	apiToken: string
5
	domain: string
6
}
7
/**
8
 * Remove modules
9
 * Remove all or a list of modules registered by the calling app.
10

11
**[Permissions](#permissions) required:** Only Connect apps can make this request.
12
 */
13
export async function main(auth: Confluence, moduleKey: string | undefined) {
14
	const url = new URL(`https://${auth.domain}/atlassian-connect/1/app/module/dynamic`)
15
	for (const [k, v] of [['moduleKey', moduleKey]]) {
16
		if (v !== undefined && v !== '' && k !== undefined) {
17
			url.searchParams.append(k, v)
18
		}
19
	}
20
	const response = await fetch(url, {
21
		method: 'DELETE',
22
		headers: {
23
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
24
		},
25
		body: undefined
26
	})
27
	if (!response.ok) {
28
		const text = await response.text()
29
		throw new Error(`${response.status} ${text}`)
30
	}
31
	return await response.text()
32
}
33