0

Bulk Unsuppress Profiles

by
Published Apr 8, 2025

Manually unsuppress profiles by email address or specify a segment/list ID to unsuppress all current members of a segment/list.

Script klaviyo Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Klaviyo = {
3
  apiKey: string;
4
};
5
/**
6
 * Bulk Unsuppress Profiles
7
 * Manually unsuppress profiles by email address or specify a segment/list ID to unsuppress all current members of a segment/list.
8
 */
9
export async function main(
10
  auth: Klaviyo,
11
  revision: string,
12
  body: {
13
    data: {
14
      type: "profile-suppression-bulk-delete-job";
15
      attributes: {
16
        profiles?: {
17
          data: { type: "profile"; attributes: { email: string } }[];
18
        };
19
      };
20
      relationships?: {
21
        list?: { data?: { type: "list"; id: string } };
22
        segment?: { data?: { type: "segment"; id: string } };
23
      };
24
    };
25
  },
26
) {
27
  const url = new URL(
28
    `https://a.klaviyo.com/api/profile-suppression-bulk-delete-jobs`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "POST",
33
    headers: {
34
      revision: revision,
35
      "Accept": "application/vnd.api+json",
36
      "Content-Type": "application/vnd.api+json",
37
      Authorization: "Klaviyo-API-Key " + auth.apiKey,
38
    },
39
    body: JSON.stringify(body),
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47