0

Update an external feed

by
Published Apr 8, 2025

This endpoint will update an external feed.

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 an external feed
7
 * This endpoint will update an external feed.
8
 */
9
export async function main(
10
  auth: Brevo,
11
  uuid: string,
12
  body: {
13
    name?: string;
14
    url?: string;
15
    authType?: "basic" | "token" | "noAuth";
16
    username?: string;
17
    password?: string;
18
    token?: string;
19
    headers?: { name?: string; value?: string }[];
20
    maxRetries?: number;
21
    cache?: false | true;
22
  },
23
) {
24
  const url = new URL(`https://api.brevo.com/v3/feeds/${uuid}`);
25

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