0

Get List for Bulk Import Profiles Job

by
Published Apr 8, 2025

Get list for the bulk profile import job with the given ID.*Rate limits*:Burst: `10/s`Steady: `150/m` **Scopes:** `lists: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 for Bulk Import Profiles Job
7
 * Get list for the bulk profile import job with the given ID.*Rate limits*:Burst: `10/s`Steady: `150/m`
8

9
 */
10
export async function main(
11
  auth: Klaviyo,
12
  id: string,
13
  fields_list_: string | undefined,
14
  revision: string,
15
) {
16
  const url = new URL(
17
    `https://a.klaviyo.com/api/profile-bulk-import-jobs/${id}/lists`,
18
  );
19
  for (const [k, v] of [["fields[list]", fields_list_]]) {
20
    if (v !== undefined && v !== "" && k !== undefined) {
21
      url.searchParams.append(k, v);
22
    }
23
  }
24
  const response = await fetch(url, {
25
    method: "GET",
26
    headers: {
27
      revision: revision,
28
      "Accept": "application/vnd.api+json",
29
      Authorization: "Klaviyo-API-Key " + auth.apiKey,
30
    },
31
    body: undefined,
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39