0

Update sub-accounts plan

by
Published Apr 8, 2025

This endpoint will update multiple sub-accounts plan. On the Corporate solution new version v2, you can set an unlimited number of credits in your sub-organization. Please pass the value “-1" to set the consumable in unlimited mode.

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 sub-accounts plan
7
 * This endpoint will update multiple sub-accounts plan. On the Corporate solution new version v2, you can set an unlimited number of credits in your sub-organization. Please pass the value “-1" to set the consumable in unlimited mode.
8
 */
9
export async function main(
10
  auth: Brevo,
11
  body: {
12
    subAccountIds?: number[];
13
    credits?: {
14
      email?: number;
15
      sms?: number;
16
      wpSubscribers?: number;
17
      externalFeeds?: number;
18
      whatsapp?: number;
19
    };
20
    features?: { users?: number; landingPage?: number; salesUsers?: number };
21
  },
22
) {
23
  const url = new URL(`https://api.brevo.com/v3/corporate/subAccounts/plan`);
24

25
  const response = await fetch(url, {
26
    method: "PUT",
27
    headers: {
28
      "Content-Type": "application/json",
29
      "api-key": auth.apiKey,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.text();
38
}
39