0

CancelLoyaltyPromotion

by
Published Oct 17, 2025

Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the end date, cancel an `ACTIVE` promotion when an end date is not specified, or cancel a `SCHEDULED` promotion. Because updating a promotion is not supported, you can also use this endpoint to cancel a promotion before you create a new one. This endpoint sets the loyalty promotion to the `CANCELED` state

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * CancelLoyaltyPromotion
7
 * Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the
8
end date, cancel an `ACTIVE` promotion when an end date is not specified, or cancel a `SCHEDULED` promotion.
9
Because updating a promotion is not supported, you can also use this endpoint to cancel a promotion before
10
you create a new one.
11

12
This endpoint sets the loyalty promotion to the `CANCELED` state
13
 */
14
export async function main(
15
  auth: Square,
16
  promotion_id: string,
17
  program_id: string,
18
) {
19
  const url = new URL(
20
    `https://connect.squareup.com/v2/loyalty/programs/${program_id}/promotions/${promotion_id}/cancel`,
21
  );
22

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