0

Update an external user

by
Published Oct 17, 2025

Update a user in an external provider that is currently linked to a Sentry user.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update an external user
4
 * Update a user in an external provider that is currently linked to a Sentry user.
5
 */
6
export async function main(auth: RT.Sentry, external_user_id: string, body: Body) {
7
	const url = new URL(
8
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/external-users/${external_user_id}/`
9
	)
10

11
	const response = await fetch(url, {
12
		method: 'PUT',
13
		headers: {
14
			'Content-Type': 'application/json',
15
			Authorization: 'Bearer ' + auth.token
16
		},
17
		body: JSON.stringify(body)
18
	})
19
	if (!response.ok) {
20
		const text = await response.text()
21
		throw new Error(`${response.status} ${text}`)
22
	}
23
	return await response.json()
24
}
25

26
/* eslint-disable */
27
/**
28
 * This file was automatically generated by json-schema-to-typescript.
29
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
30
 * and run json-schema-to-typescript to regenerate this file.
31
 */
32

33
/**
34
 * Allows parameters to be defined in snake case, but passed as camel case.
35
 *
36
 * Errors are output in camel case.
37
 */
38
export interface Body {
39
	/**
40
	 * The user ID in Sentry.
41
	 */
42
	user_id: number
43
	/**
44
	 * The associated name for the provider.
45
	 */
46
	external_name: string
47
	/**
48
	 * The provider of the external actor.
49
	 *
50
	 * * `github`
51
	 * * `github_enterprise`
52
	 * * `jira_server`
53
	 * * `slack`
54
	 * * `gitlab`
55
	 * * `msteams`
56
	 * * `custom_scm`
57
	 */
58
	provider:
59
		| 'github'
60
		| 'github_enterprise'
61
		| 'jira_server'
62
		| 'slack'
63
		| 'gitlab'
64
		| 'msteams'
65
		| 'custom_scm'
66
	/**
67
	 * The Integration ID.
68
	 */
69
	integration_id: number
70
	/**
71
	 * The external actor ID.
72
	 */
73
	id: number
74
	/**
75
	 * The associated user ID for provider.
76
	 */
77
	external_id?: string
78
	[k: string]: unknown
79
}
80