0

Remove member from the organization

by
Published Apr 8, 2025

Remove member from the organization. Only an admin of the organization can perform this action. If another admin is being removed, it will not be allows in case it is the only admin left in the organization.

Script neondb Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Neondb = {
3
	apiKey: string
4
}
5
/**
6
 * Remove member from the organization
7
 * Remove member from the organization.
8
Only an admin of the organization can perform this action.
9
If another admin is being removed, it will not be allows in case it is the only admin left in the organization.
10

11
 */
12
export async function main(auth: Neondb, org_id: string, member_id: string) {
13
	const url = new URL(
14
		`https://console.neon.tech/api/v2/organizations/${org_id}/members/${member_id}`
15
	)
16

17
	const response = await fetch(url, {
18
		method: 'DELETE',
19
		headers: {
20
			Authorization: 'Bearer ' + auth.apiKey
21
		},
22
		body: undefined
23
	})
24
	if (!response.ok) {
25
		const text = await response.text()
26
		throw new Error(`${response.status} ${text}`)
27
	}
28
	return await response.json()
29
}
30