0

Delete user group

by
Published Oct 17, 2025

Delete user group. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: User must be a site admin.

Script confluence
  • Submitted by hugo697 Bun
    Created 284 days ago
    1
    //native
    2
    type Confluence = {
    3
    	email: string
    4
    	apiToken: string
    5
    	domain: string
    6
    }
    7
    /**
    8
     * Delete user group
    9
     * Delete user group.
    10
    
    
    11
    **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
    12
    User must be a site admin.
    13
     */
    14
    export async function main(auth: Confluence, id: string | undefined) {
    15
    	const url = new URL(`https://${auth.domain}/wiki/rest/api/group/by-id`)
    16
    	for (const [k, v] of [['id', id]]) {
    17
    		if (v !== undefined && v !== '' && k !== undefined) {
    18
    			url.searchParams.append(k, v)
    19
    		}
    20
    	}
    21
    	const response = await fetch(url, {
    22
    		method: 'DELETE',
    23
    		headers: {
    24
    			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
    25
    		},
    26
    		body: undefined
    27
    	})
    28
    	if (!response.ok) {
    29
    		const text = await response.text()
    30
    		throw new Error(`${response.status} ${text}`)
    31
    	}
    32
    	return await response.text()
    33
    }
    34