0

Get Webhook Topics

by
Published Apr 8, 2025

Get all webhook topics in a Klaviyo account.*Rate limits*:Burst: `1/s`Steady: `15/m` **Scopes:** `webhooks: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 Webhook Topics
7
 * Get all webhook topics in a Klaviyo account.*Rate limits*:Burst: `1/s`Steady: `15/m`
8

9
 */
10
export async function main(auth: Klaviyo, revision: string) {
11
  const url = new URL(`https://a.klaviyo.com/api/webhook-topics`);
12

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