0

Update a sender

by
Published Apr 8, 2025
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 a sender
7
 *
8
 */
9
export async function main(
10
  auth: Brevo,
11
  senderId: string,
12
  body: {
13
    name?: string;
14
    email?: string;
15
    ips?: { ip: string; domain: string; weight?: number }[];
16
  },
17
) {
18
  const url = new URL(`https://api.brevo.com/v3/senders/${senderId}`);
19

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