Edits history of script submission #17927 for ' Remove a user from the account (phrase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Phrase = {
    	token: string
    	baseUrl: string
    }
    /**
     * Remove a user from the account
     * Remove a user from the account. The user will be removed from the account but not deleted from Phrase. Access token scope must include team.manage.
     */
    export async function main(auth: Phrase, account_id: string, id: string) {
    	const url = new URL(`${auth.baseUrl}/accounts/${account_id}/members/${id}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'ApiToken ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago