0

Delete content version

by
Published Oct 17, 2025

Delete a historical version. This does not delete the changes made to the content in that version, rather the changes for the deleted version are rolled up into the next version. Note, you cannot delete the current version. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.

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
 * Delete content version
9
 * Delete a historical version. This does not delete the changes made to the
10
content in that version, rather the changes for the deleted version are
11
rolled up into the next version. Note, you cannot delete the current version.
12

13
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
14
Permission to update the content.
15
 */
16
export async function main(auth: Confluence, id: string, versionNumber: string) {
17
	const url = new URL(`https://${auth.domain}/wiki/rest/api/content/${id}/version/${versionNumber}`)
18

19
	const response = await fetch(url, {
20
		method: 'DELETE',
21
		headers: {
22
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
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