//native
/**
* Create Group
* Create an Okta group (OKTA_GROUP type). Provide a unique `name` and an optional `description`.
*/
export async function main(
auth: RT.Okta,
name: string,
description: string | undefined
) {
const url = new URL(`${auth.org_url}/api/v1/groups`)
const profile: { [key: string]: any } = { name }
if (description !== undefined && description !== "")
profile.description = description
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `SSWS ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ profile }),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 days ago