0

Get Create Categories Jobs

by
Published Apr 8, 2025

Get all catalog category bulk create jobs. Returns a maximum of 100 jobs per request.*Rate limits*:Burst: `350/s`Steady: `3500/m` **Scopes:** `catalogs: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 Create Categories Jobs
7
 * Get all catalog category bulk create jobs.
8

9
Returns a maximum of 100 jobs per request.*Rate limits*:Burst: `350/s`Steady: `3500/m`
10

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