0

Resend / cancel admin user invitation

by
Published Apr 8, 2025

This endpoint will allow the user to: - Resend an admin user invitation - Cancel an admin user invitation

Script brevo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Brevo = {
3
  apiKey: string;
4
};
5
/**
6
 * Resend / cancel admin user invitation
7
 * This endpoint will allow the user to:
8
- Resend an admin user invitation
9
- Cancel an admin user invitation
10

11
 */
12
export async function main(
13
  auth: Brevo,
14
  action: "resend" | "cancel",
15
  email: string,
16
) {
17
  const url = new URL(
18
    `https://api.brevo.com/v3/corporate/user/invitation/${action}/${email}`,
19
  );
20

21
  const response = await fetch(url, {
22
    method: "PUT",
23
    headers: {
24
      "api-key": auth.apiKey,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34