0

Update List

by
Published Apr 8, 2025

Update the name of a list with the given list ID.*Rate limits*:Burst: `10/s`Steady: `150/m` **Scopes:** `lists:write`

Script klaviyo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Klaviyo = {
3
  apiKey: string;
4
};
5
/**
6
 * Update List
7
 * Update the name of a list with the given list ID.*Rate limits*:Burst: `10/s`Steady: `150/m`
8

9
 */
10
export async function main(
11
  auth: Klaviyo,
12
  id: string,
13
  revision: string,
14
  body: { data: { type: "list"; id: string; attributes: { name: string } } },
15
) {
16
  const url = new URL(`https://a.klaviyo.com/api/lists/${id}`);
17

18
  const response = await fetch(url, {
19
    method: "PATCH",
20
    headers: {
21
      revision: revision,
22
      "Accept": "application/vnd.api+json",
23
      "Content-Type": "application/vnd.api+json",
24
      Authorization: "Klaviyo-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.json();
33
}
34