//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Create new user group
* Creates a new user group.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
User must be a site admin.
*/
export async function main(auth: Confluence, body: { name: string }) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/group`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago