0

Upsert spam sender

by
Published Oct 17, 2025

Assigns a spam list status for a new sender, or updates the spam list status for an existing sender. You can assign senders to a `list` status: `whitelist` (never considered spam) or `blacklist` (always considered spam). Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.admin.spam.write|org.permission.spam.update|

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Upsert spam sender
7
 * Assigns a spam list status for a new sender, or updates the spam list status for an existing sender.
8

9
You can assign senders to a `list` status: `whitelist` (never considered spam) or `blacklist` (always considered spam).
10

11
Any one of the following roles is required for this endpoint:
12

13
|Legacy Role|Equivalent Permission Set Role|
14
|-----|--------|
15
|org.admin.spam.write|org.permission.spam.update|
16
 */
17
export async function main(auth: Kustomer) {
18
  const url = new URL(`https://api.kustomerapp.com/v1/spam/senders`);
19

20
  const response = await fetch(url, {
21
    method: "PUT",
22
    headers: {
23
      "Content-Type": "application/json",
24
      Authorization: "Bearer " + auth.apiKey,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34