0

Delete restrictions

by
Published Oct 17, 2025

Removes all restrictions (read and update) on a piece of content. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content.

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 restrictions
    9
     * Removes all restrictions (read and update) on a piece of content.
    10
    
    
    11
    **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
    12
    Permission to edit the content.
    13
     */
    14
    export async function main(auth: Confluence, id: string, expand: string | undefined) {
    15
    	const url = new URL(`https://${auth.domain}/wiki/rest/api/content/${id}/restriction`)
    16
    	for (const [k, v] of [['expand', expand]]) {
    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.json()
    33
    }
    34