0

Delete Coupon Code

by
Published Apr 8, 2025

Deletes a coupon code specified by the given identifier synchronously. If a profile has been assigned to the coupon code, an exception will be raised*Rate limits*:Burst: `350/s`Steady: `3500/m` **Scopes:** `coupon-codes:write`

Script klaviyo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Klaviyo = {
3
  apiKey: string;
4
};
5
/**
6
 * Delete Coupon Code
7
 * Deletes a coupon code specified by the given identifier synchronously. If a profile has been assigned to the
8
coupon code, an exception will be raised*Rate limits*:Burst: `350/s`Steady: `3500/m`
9

10
 */
11
export async function main(auth: Klaviyo, id: string, revision: string) {
12
  const url = new URL(`https://a.klaviyo.com/api/coupon-codes/${id}`);
13

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