0

Update sub-account plan

by
Published Apr 8, 2025

This endpoint will update the sub-account 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-account plan
7
 * This endpoint will update the sub-account 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
  id: string,
12
  body: {
13
    credits?: {
14
      email?: number;
15
      sms?: number;
16
      wpSubscribers?: number;
17
      externalFeeds?: number;
18
      whatsapp?: number;
19
    };
20
    features?: {
21
      users?: number;
22
      landingPage?: number;
23
      inbox?: number;
24
      salesUsers?: number;
25
    };
26
  },
27
) {
28
  const url = new URL(
29
    `https://api.brevo.com/v3/corporate/subAccount/${id}/plan`,
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