Edits history of script submission #17230 for ' Detach a child org from Enterprise (mezmo)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Detach a child org from Enterprise
     * Detaches a child organization from the enterprise. The child organization is not deleted and can continue to work afterwards.
     */
    export async function main(auth: RT.Mezmo, accountId: string) {
    	const url = new URL(`https://api.mezmo.com/v1/enterprise/account/${accountId}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Token ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago