0

Set space theme

by
Published Oct 17, 2025

Sets the theme for a space. Note, if you want to reset the space theme to the default Confluence theme, use the 'Reset space theme' method instead of this method. **[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
 * Set space theme
9
 * Sets the theme for a space. Note, if you want to reset the space theme to
10
the default Confluence theme, use the 'Reset space theme' method instead
11
of this method.
12

13
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
14
'Admin' permission for the space.
15
 */
16
export async function main(auth: Confluence, spaceKey: string, body: { themeKey: string }) {
17
	const url = new URL(`https://${auth.domain}/wiki/rest/api/space/${spaceKey}/theme`)
18

19
	const response = await fetch(url, {
20
		method: 'PUT',
21
		headers: {
22
			'Content-Type': 'application/json',
23
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
24
		},
25
		body: JSON.stringify(body)
26
	})
27
	if (!response.ok) {
28
		const text = await response.text()
29
		throw new Error(`${response.status} ${text}`)
30
	}
31
	return await response.json()
32
}
33