0

RedeemLoyaltyReward

by
Published Oct 17, 2025

Redeems a loyalty reward. The endpoint sets the reward to the `REDEEMED` terminal state. If you are using your own order processing system (not using the Orders API), you call this endpoint after the buyer paid for the purchase. After the reward reaches the terminal state, it cannot be deleted. In other words, points used for the reward cannot be returned to the account.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * RedeemLoyaltyReward
7
 * Redeems a loyalty reward.
8

9
The endpoint sets the reward to the `REDEEMED` terminal state.
10

11
If you are using your own order processing system (not using the
12
Orders API), you call this endpoint after the buyer paid for the
13
purchase.
14

15
After the reward reaches the terminal state, it cannot be deleted.
16
In other words, points used for the reward cannot be returned
17
to the account.
18
 */
19
export async function main(
20
  auth: Square,
21
  reward_id: string,
22
  body: { idempotency_key: string; location_id: string },
23
) {
24
  const url = new URL(
25
    `https://connect.squareup.com/v2/loyalty/rewards/${reward_id}/redeem`,
26
  );
27

28
  const response = await fetch(url, {
29
    method: "POST",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: JSON.stringify(body),
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42