1 | |
2 | type Brevo = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Delete an attribute |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Brevo, |
11 | attributeCategory: |
12 | | "normal" |
13 | | "transactional" |
14 | | "category" |
15 | | "calculated" |
16 | | "global", |
17 | attributeName: string, |
18 | ) { |
19 | const url = new URL( |
20 | `https://api.brevo.com/v3/contacts/attributes/${attributeCategory}/${attributeName}`, |
21 | ); |
22 |
|
23 | const response = await fetch(url, { |
24 | method: "DELETE", |
25 | headers: { |
26 | "api-key": auth.apiKey, |
27 | }, |
28 | body: undefined, |
29 | }); |
30 | if (!response.ok) { |
31 | const text = await response.text(); |
32 | throw new Error(`${response.status} ${text}`); |
33 | } |
34 | return await response.text(); |
35 | } |
36 |
|