Blocks a new domain in order to avoid messages being sent to the same
1
//native
2
type Brevo = {
3
apiKey: string;
4
};
5
/**
6
* Add a new domain to the list of blocked domains
7
* Blocks a new domain in order to avoid messages being sent to the same
8
*/
9
export async function main(auth: Brevo, body: { domain: string }) {
10
const url = new URL(`https://api.brevo.com/v3/smtp/blockedDomains`);
11
12
const response = await fetch(url, {
13
method: "POST",
14
headers: {
15
"Content-Type": "application/json",
16
"api-key": auth.apiKey,
17
},
18
body: JSON.stringify(body),
19
});
20
if (!response.ok) {
21
const text = await response.text();
22
throw new Error(`${response.status} ${text}`);
23
}
24
return await response.text();
25
26