0

Update an organization members team role

by
Published Oct 17, 2025

The relevant organization member must already be a part of the team. Note that for organization admins, managers, and owners, they are automatically granted a minimum team role of `admin` on all teams they are part of. Read more about [team roles](https://docs.sentry.io/product/teams/roles/).

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update an organization members team role
4
 * The relevant organization member must already be a part of the team.
5

6
Note that for organization admins, managers, and owners, they are
7
automatically granted a minimum team role of `admin` on all teams they
8
are part of. Read more about [team roles](https://docs.sentry.io/product/teams/roles/).
9
 */
10
export async function main(
11
	auth: RT.Sentry,
12
	member_id: string,
13
	team_id_or_slug: string,
14
	body: Body
15
) {
16
	const url = new URL(
17
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/members/${member_id}/teams/${team_id_or_slug}/`
18
	)
19

20
	const response = await fetch(url, {
21
		method: 'PUT',
22
		headers: {
23
			'Content-Type': 'application/json',
24
			Authorization: 'Bearer ' + auth.token
25
		},
26
		body: JSON.stringify(body)
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34

35
/* eslint-disable */
36
/**
37
 * This file was automatically generated by json-schema-to-typescript.
38
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
39
 * and run json-schema-to-typescript to regenerate this file.
40
 */
41

42
export interface Body {
43
	/**
44
	 * The team-level role to switch to. Valid roles include:
45
	 *
46
	 * * `contributor` - Contributors can view and act on events, as well as view most other data within the team's projects.
47
	 * * `admin` - Admin privileges on the team. They can create and remove projects, and can manage the team's memberships.
48
	 */
49
	teamRole?: 'contributor' | 'admin'
50
	[k: string]: unknown
51
}
52