0

Get Delete Categories Job

by
Published Apr 8, 2025

Get a catalog category bulk delete job with the given job ID.*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 Delete Categories Job
7
 * Get a catalog category bulk delete job with the given job ID.*Rate limits*:Burst: `350/s`Steady: `3500/m`
8

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