0

Send invitation to an admin user

by
Published Apr 8, 2025

`This endpoint allows you to invite a member to manage the Admin account Features and their respective permissions are as below: - `my_plan`: - "all" - `api`: - "none" - `user_management`: - "all" - `app_management` | Not available in ENTv2: - "all" - `sub_organization_groups` - "create" - "edit_delete" - `create_sub_organizations` - "all" - `manage_sub_organizations` - "all" - `analytics` - "download_data" - "create_alerts" - "my_looks" - "explore_create" - `security` - "all" **Note**: - If `all_features_access: false` then only privileges are required otherwise if `true` then it's assumed that all permissions will be there for the invited admin user.

Script brevo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Brevo = {
3
  apiKey: string;
4
};
5
/**
6
 * Send invitation to an admin user
7
 * `This endpoint allows you to invite a member to manage the Admin account
8

9
Features and their respective permissions are as below:
10

11
- `my_plan`:
12
  - "all"
13
- `api`:
14
  - "none"
15
- `user_management`:
16
  - "all"
17
- `app_management` | Not available in ENTv2:
18
  - "all"
19
- `sub_organization_groups`
20
  - "create"
21
  - "edit_delete"
22
- `create_sub_organizations`
23
  - "all"
24
- `manage_sub_organizations`
25
  - "all"
26
- `analytics`
27
  - "download_data"
28
  - "create_alerts"
29
  - "my_looks"
30
  - "explore_create"
31
- `security`
32
  - "all"
33

34
**Note**:
35
- If `all_features_access: false` then only privileges are required otherwise if `true` then it's assumed that all permissions will be there for the invited admin user.
36
 */
37
export async function main(
38
  auth: Brevo,
39
  body: {
40
    email: string;
41
    all_features_access: false | true;
42
    groupIds?: string[];
43
    privileges: {
44
      feature?:
45
        | "my_plan"
46
        | "api"
47
        | "user_management"
48
        | "app_management"
49
        | "sub_organization_groups"
50
        | "create_sub_organizations"
51
        | "manage_sub_organizations"
52
        | "analytics"
53
        | "security";
54
      permissions?:
55
        | "all"
56
        | "none"
57
        | "create"
58
        | "edit_delete"
59
        | "download_data"
60
        | "create_alerts"[];
61
    }[];
62
  },
63
) {
64
  const url = new URL(
65
    `https://api.brevo.com/v3/corporate/user/invitation/send`,
66
  );
67

68
  const response = await fetch(url, {
69
    method: "POST",
70
    headers: {
71
      "Content-Type": "application/json",
72
      "api-key": auth.apiKey,
73
    },
74
    body: JSON.stringify(body),
75
  });
76
  if (!response.ok) {
77
    const text = await response.text();
78
    throw new Error(`${response.status} ${text}`);
79
  }
80
  return await response.json();
81
}
82