0

Update space

by
Published Oct 17, 2025

Updates the name, description, or homepage of a space. - For security reasons, permissions cannot be updated via the API and must be changed via the user interface instead. - Currently you cannot set space labels when updating a space. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space.

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
 * Update space
9
 * Updates the name, description, or homepage of a space.
10

11
-   For security reasons, permissions cannot be updated via the API and
12
must be changed via the user interface instead.
13
-   Currently you cannot set space labels when updating a space.
14

15
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
16
'Admin' permission for the space.
17
 */
18
export async function main(
19
	auth: Confluence,
20
	spaceKey: string,
21
	body: {
22
		name?: string
23
		description?: { plain: { value?: string; representation?: string } }
24
		homepage?: {}
25
		type?: string
26
		status?: string
27
	}
28
) {
29
	const url = new URL(`https://${auth.domain}/wiki/rest/api/space/${spaceKey}`)
30

31
	const response = await fetch(url, {
32
		method: 'PUT',
33
		headers: {
34
			'Content-Type': 'application/json',
35
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
36
		},
37
		body: JSON.stringify(body)
38
	})
39
	if (!response.ok) {
40
		const text = await response.text()
41
		throw new Error(`${response.status} ${text}`)
42
	}
43
	return await response.json()
44
}
45