0

Get Bulk Import Profiles Job

by
Published Apr 8, 2025

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

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