1 | |
2 | |
3 | * Add a member to an organization |
4 | * Add or invite a member to an organization. |
5 | */ |
6 | export async function main(auth: RT.Sentry, body: Body) { |
7 | const url = new URL( |
8 | `https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/members/` |
9 | ) |
10 |
|
11 | const response = await fetch(url, { |
12 | method: 'POST', |
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 | |
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 | export interface Body { |
34 | |
35 | * The email address to send the invitation to. |
36 | */ |
37 | email: string |
38 | |
39 | * The organization-level role of the new member. Roles include: |
40 | * |
41 | * * `billing` - Can manage payment and compliance details. |
42 | * * `member` - Can view and act on events, as well as view most other data within the organization. |
43 | * * `manager` - Has full management access to all teams and projects. Can also manage |
44 | * the organization's membership. |
45 | * * `owner` - Has unrestricted access to the organization, its data, and its |
46 | * settings. Can add, modify, and delete projects and members, as well as |
47 | * make billing and plan changes. |
48 | * * `admin` - Can edit global integrations, manage projects, and add/remove teams. |
49 | * They automatically assume the Team Admin role for teams they join. |
50 | * Note: This role can no longer be assigned in Business and Enterprise plans. Use `TeamRoles` instead. |
51 | * |
52 | */ |
53 | orgRole?: 'billing' | 'member' | 'manager' | 'owner' | 'admin' |
54 | |
55 | * The team and team-roles assigned to the member. Team roles can be either: |
56 | * - `contributor` - Can view and act on issues. Depending on organization settings, they can also add team members. |
57 | * - `admin` - Has full management access to their team's membership and projects. |
58 | */ |
59 | teamRoles?: { |
60 | [k: string]: unknown |
61 | }[] |
62 | |
63 | * Whether or not to send an invite notification through email. Defaults to True. |
64 | */ |
65 | sendInvite?: boolean |
66 | |
67 | * Whether or not to re-invite a user who has already been invited to the organization. Defaults to True. |
68 | */ |
69 | reinvite?: boolean |
70 | [k: string]: unknown |
71 | } |
72 |
|