0

Get List IDs for Tag

by
Published Apr 8, 2025

Returns the IDs of all lists associated with the given tag.*Rate limits*:Burst: `3/s`Steady: `60/m` **Scopes:** `lists:read` `tags:read`

Script klaviyo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Klaviyo = {
3
  apiKey: string;
4
};
5
/**
6
 * Get List IDs for Tag
7
 * Returns the IDs of all lists associated with the given tag.*Rate limits*:Burst: `3/s`Steady: `60/m`
8

9
 */
10
export async function main(auth: Klaviyo, id: string, revision: string) {
11
  const url = new URL(
12
    `https://a.klaviyo.com/api/tags/${id}/relationships/lists`,
13
  );
14

15
  const response = await fetch(url, {
16
    method: "GET",
17
    headers: {
18
      revision: revision,
19
      "Accept": "application/vnd.api+json",
20
      Authorization: "Klaviyo-API-Key " + auth.apiKey,
21
    },
22
    body: undefined,
23
  });
24
  if (!response.ok) {
25
    const text = await response.text();
26
    throw new Error(`${response.status} ${text}`);
27
  }
28
  return await response.json();
29
}
30