0

Update permission for a user

by
Published Apr 8, 2025

`Feature` - A Feature represents a specific functionality like Email campaign, Deals, Calls, Automations, etc.

Script brevo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Brevo = {
3
  apiKey: string;
4
};
5
/**
6
 * Update permission for a user
7
 * `Feature` - A Feature represents a specific functionality like Email campaign, Deals, Calls, Automations, etc.
8
 */
9
export async function main(
10
  auth: Brevo,
11
  body: {
12
    email: string;
13
    all_features_access: false | true;
14
    privileges: {
15
      feature?:
16
        | "email_campaigns"
17
        | "sms_campaigns"
18
        | "contacts"
19
        | "templates"
20
        | "workflows"
21
        | "facebook_ads"
22
        | "landing_pages"
23
        | "transactional_emails"
24
        | "smtp_api"
25
        | "user_management"
26
        | "sales_platform"
27
        | "phone"
28
        | "conversations"
29
        | "senders_domains_dedicated_ips"
30
        | "push_notifications"
31
        | "companies";
32
      permissions?:
33
        | "create_edit_delete"
34
        | "send_schedule_suspend"
35
        | "view"
36
        | "import"
37
        | "export"
38
        | "list_and_attributes"
39
        | "forms"
40
        | "activate_deactivate"
41
        | "activate_deactivate_pause"
42
        | "settings"
43
        | "schedule_pause"
44
        | "all"
45
        | "logs"
46
        | "access"
47
        | "assign"
48
        | "configure"
49
        | "create_edit_deals"
50
        | "delete_deals"
51
        | "manage_others_deals_tasks"
52
        | "manage_owned_companies"
53
        | "manage_others_companies"
54
        | "reports"
55
        | "senders_management"
56
        | "domains_management"
57
        | "dedicated_ips_management"
58
        | "send"
59
        | "smtp"
60
        | "api_keys"
61
        | "authorized_ips"
62
        | "none"[];
63
    }[];
64
  },
65
) {
66
  const url = new URL(
67
    `https://api.brevo.com/v3/organization/user/update/permissions`,
68
  );
69

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