0

Change admin user permissions

Published Apr 8, 2025

This endpoint will allow you to change the permissions of Admin users of your Admin account

Script brevo Verified

The script

Submitted by hugo697 Bun
Verified 589 days ago
1
//native
2
type Brevo = {
3
  apiKey: string;
4
};
5
/**
6
 * Change admin user permissions
7
 * This endpoint will allow you to change the permissions of Admin users of your Admin account
8
 */
9
export async function main(
10
  auth: Brevo,
11
  email: string,
12
  body: {
13
    all_features_access: false | true;
14
    privileges: {
15
      feature?:
16
        | "user_management"
17
        | "api"
18
        | "my_plan"
19
        | "apps_management"
20
        | "analytics"
21
        | "sub_organization_groups"
22
        | "create_sub_organizations"
23
        | "manage_sub_organizations"
24
        | "security";
25
      permissions?:
26
        | "all"
27
        | "none"
28
        | "create"
29
        | "edit_delete"
30
        | "create_alerts"
31
        | "download_data"
32
        | "my_looks"
33
        | "explore_create"[];
34
    }[];
35
  },
36
) {
37
  const url = new URL(
38
    `https://api.brevo.com/v3/corporate/user/${email}/permissions`,
39
  );
40

41
  const response = await fetch(url, {
42
    method: "PUT",
43
    headers: {
44
      "Content-Type": "application/json",
45
      "api-key": auth.apiKey,
46
    },
47
    body: JSON.stringify(body),
48
  });
49
  if (!response.ok) {
50
    const text = await response.text();
51
    throw new Error(`${response.status} ${text}`);
52
  }
53
  return await response.text();
54
}
55