0

DeleteLoyaltyReward

by
Published Oct 17, 2025

Deletes a loyalty reward by doing the following: - Returns the loyalty points back to the loyalty account. - If an order ID was specified when the reward was created (see [CreateLoyaltyReward]($e/Loyalty/CreateLoyaltyReward)), it updates the order by removing the reward and related discounts. You cannot delete a reward that has reached the terminal state (REDEEMED).

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * DeleteLoyaltyReward
7
 * Deletes a loyalty reward by doing the following:
8

9
- Returns the loyalty points back to the loyalty account.
10
- If an order ID was specified when the reward was created
11
(see [CreateLoyaltyReward]($e/Loyalty/CreateLoyaltyReward)),
12
it updates the order by removing the reward and related
13
discounts.
14

15
You cannot delete a reward that has reached the terminal state (REDEEMED).
16
 */
17
export async function main(auth: Square, reward_id: string) {
18
  const url = new URL(
19
    `https://connect.squareup.com/v2/loyalty/rewards/${reward_id}`,
20
  );
21

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