0

Enable/disable sub-account application(s)

by
Published Apr 8, 2025

API endpoints for the Corporate owner to enable/disable applications on the sub-account

Script brevo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Brevo = {
3
  apiKey: string;
4
};
5
/**
6
 * Enable/disable sub-account application(s)
7
 * API endpoints for the Corporate owner to enable/disable applications on the sub-account
8
 */
9
export async function main(
10
  auth: Brevo,
11
  id: string,
12
  body: {
13
    inbox?: false | true;
14
    whatsapp?: false | true;
15
    automation?: false | true;
16
    "email-campaigns"?: false | true;
17
    "sms-campaigns"?: false | true;
18
    "landing-pages"?: false | true;
19
    "transactional-emails"?: false | true;
20
    "transactional-sms"?: false | true;
21
    "facebook-ads"?: false | true;
22
    "web-push"?: false | true;
23
    meetings?: false | true;
24
    conversations?: false | true;
25
    crm?: false | true;
26
  },
27
) {
28
  const url = new URL(
29
    `https://api.brevo.com/v3/corporate/subAccount/${id}/applications/toggle`,
30
  );
31

32
  const response = await fetch(url, {
33
    method: "PUT",
34
    headers: {
35
      "Content-Type": "application/json",
36
      "api-key": auth.apiKey,
37
    },
38
    body: JSON.stringify(body),
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.text();
45
}
46