Beta Release
This is pre-release documentation for an API in public beta and is subject to change.
Loyalty API

Manage Loyalty Programs Using the Loyalty API

After setting up a Square loyalty program, use the Loyalty API to create loyalty accounts for buyers and allow them to earn points and redeem rewards.

Create a loyalty account Permalink Get a link to this section

To enroll a buyer in a loyalty program, the program ID and a buyer's phone number are required. There can only be one loyalty account per phone number. You can obtain a buyer's phone number from your application flow. You can get a loyalty program ID by calling ListLoyaltyPrograms as shown:

curl -X GET \
  https://connect.squareupsandbox.com/v2/loyalty/programs \
  -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' 

To create a loyalty account, call CreateLoyaltyAccount as shown. In the request:

  • program_id identifies the loyalty program.

  • mappings identifies the buyer by phone number.

    curl -X POST \
      https://connect.squareupsandbox.com/v2/loyalty/accounts \
      -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
        "loyalty_account": {
            "mappings": [
                {
                    "type": "PHONE",
                    "value": "+14155551111"
                }
            ],
            "program_id": "{{LOYALTY_PROGRAM_ID}}"
        },
        "idempotency_key": "{{UNIQUE_KEY}}"
      }'
    

After receiving the request, Square:

  • Uses the phone number to determine whether a customer profile exists in the seller's Customer Directory (see Customers). If it does not exist, Square creates a customer profile.

  • Creates an account in the loyalty program and returns the following response:

    {
       "loyalty_account":{
          "id":"716cefbc-3d71-4d7c-bdc8-9c78fa8cabae",
          "mappings":[
             {
                "id":"6377d589-3f09-4f00-a0e8-56d7d60f1ca8",
                "type":"PHONE",
                "value":"+12065129251",
                "created_at":"2020-01-30T00:11:58Z"
             }
          ],
          "program_id":"ba293138-8fbd-425d-860b-18ab35d22dd8",
          "balance":0,
          "lifetime_points":0,
          "customer_id":"REK96J96AS5AN2Y8Z4H01QWYE8",
          "created_at":"2020-01-30T00:11:58Z",
          "updated_at":"2020-01-30T00:11:58Z"
       }
    }
    

    The response shows the associated customer profile ID (customer_id). Both balance and lifetime_points are 0 because the buyer has not yet accrued any loyalty points.

The phone number that you provide to create a loyalty account must use the E.164 format (for example, +14155551111). The country code of the phone number must correspond to a market where Square Loyalty is available. Otherwise, the CreateLoyaltyAccount endpoint returns an INVALID_PHONE_NUMBER error code. For information about market availability, see Square Loyalty International Availability.

Terms of service and text notifications Permalink Get a link to this section

After a loyalty account is created, Square can contact a buyer using the phone number provided and send text messages such as "you have a reward available". However, this requires the buyer to first agree to the terms of service.

  • When a buyer enrolls in a loyalty program at the Square Point of Sale, the buyer is shown the terms of service that must be accepted before Square can send any text messages.

  • When you create an account through the Loyalty API, unless and until a buyer makes a purchase through a Point of Sale, Square cannot show the terms of service and therefore the buyer cannot receive any text messages.

Access a loyalty account Permalink Get a link to this section

You can retrieve a buyer's loyalty account using an account ID, search for accounts by phone number or customer ID, or retrieve all loyalty accounts.

The following is an example SearchLoyaltyAccounts response:

{
  "loyalty_accounts": [
    {
      "id": "79b807d2-d786-46a9-933b-918028d7a8c5",
      "mappings": [
        {
          "id": "66aaab3f-da99-49ed-8b19-b87f851c844f",
          "type": "PHONE",
          "value": "+14155551234",
          "created_at": "2020-05-08T21:44:32Z"
        }
      ],
      "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd",
      "balance": 20,
      "lifetime_points": 50,
      "customer_id": "RPJBC4YA0MTGX8DHTXE9AP2AS4",
      "created_at": "2020-05-08T21:44:32Z",
      "updated_at": "2020-05-08T21:44:32Z"
    },
    {
      "id": "452ea896-f36e-4c5c-95d5-e5aa727b9b2c",
      "mappings": [
        {
          "id": "cbde1ec6-96df-40d4-8019-af9a4fa893ed",
          "type": "PHONE",
          "value": "+14255554670",
          "created_at": "2020-05-29T04:04:11Z"
        }
      ],
      "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd",
      "balance": -10,
      "lifetime_points": 10,
      "customer_id": "6E51KR0B3GVAKE0GP0HV69A1V0",
      "created_at": "2020-05-29T04:04:11Z",
      "updated_at": "2020-05-29T04:04:11Z"
    }
  ]
}

Your application should be able to handle loyalty accounts that have a negative point balance (balance is less than 0). This might occur if a seller makes a manual adjustment or as a result of a refund or exchange.

If no matches are found, the Loyalty API returns an empty response:

{}

Accumulate points Permalink Get a link to this section

Buyers accrue points for the purchases they make. After the buyer pays for the order, you call AccumulateLoyaltyPoints to add points to the buyer's account for the purchase.

  • If you are using the Orders API to process orders, you provide the order ID in the AccumulateLoyaltyPoints request. The endpoint reads the order data, determines the loyalty points using the purchase amount, and adds those points to the account. The endpoint uses the pretax purchase amount to compute the loyalty points.

    curl -X POST \
     https://connect.squareupsandbox.com/v2/loyalty/accounts/{{LOYALTY_ACCOUNT_ID}}/accumulate \
     -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '{
       "idempotency_key": "{{UNIQUE_KEY}}",
       "location_id": "{{LOCATION_ID}}",
       "accumulate_points": {
           "order_id": "{{ORDER_ID}}"
       }
    }'
    
  • If you are using your own order processing system, and not the Orders API, you must compute the loyalty points on the client side and specify those points in the AccumulateLoyaltyPoints request.

    curl -X POST \
     https://connect.squareupsandbox.com/v2/loyalty/accounts/{{LOYALTY_ACCOUNT_ID}}/accumulate \
     -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '{
       "idempotency_key": "{{UNIQUE_KEY}}",
       "location_id": "{{LOCATION_ID}}",
       "accumulate_points": {
           "points": {{POINTS_TO_ACCUMULATE}}
       }
    }'
    

Loyalty rewards Permalink Get a link to this section

A loyalty program can offer one or more rewards. These are also referred to as reward tiers. The higher the reward tier, the better the reward. This encourages buyers who accumulate more points to qualify for better rewards. For example:

  • Reward tier 1: If a buyer has 10 points in the account, the buyer qualifies for 10% off the entire purchase.

  • Reward tier 2: If a buyer has 15 points in the account, the buyer qualifies for 20% off the entire purchase.

While building the order, depending on the available point balance in the buyer's loyalty account, your application can offer the buyer the option to redeem points for a reward. For example, if the buyer has a balance of 12 points, you can offer the buyer the option to redeem reward tier 1. If the buyer has 17 points, you can offer the buyer the option to redeem reward tier 2.

If the buyer chooses to redeem the reward, you call CreateLoyaltyReward. In the request, you provide the:

  • Buyer's loyalty account ID from which to take the points.

  • Reward tier ID that the buyer chose.

  • Order ID, if your application uses the Orders API to manage orders.

    curl -X POST \
      https://connect.squareupsandbox.com/v2/loyalty/rewards \
      -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
        "reward": {
        "order_id": "{{ORDER_ID}}",
            "loyalty_account_id": "{{LOYALTY_ACCOUNT_ID}}",
            "reward_tier_id": "{{REWARD_TIER_ID}}"
        },
        "idempotency_key": "{{UNIQUE_KEY}}"
    }'
    

The endpoint:

  • Removes points from the buyer's account (as defined by the reward tier).

  • Returns a reward object of the LoyaltyReward. The object identifies the points taken from the buyer's account and the reward tier being redeemed.

    {
       "reward":{
          "id":"f8d1cf35-9b0b-3956-b654-82a01dee0d7c",
          "status":"ISSUED",
          "loyalty_account_id":"716cefbc-3d71-4d7c-bdc8-9c78fa8cabae",
          "reward_tier_id":"94946a88-154c-47b5-8cf4-5ead413ea42a",
          "points":10,
          "created_at":"2020-03-13T00:00:51Z",
          "updated_at":"2020-03-13T00:00:51Z"
       }
    }
    
  • If the CreateLoyaltyReward request included an order ID, the endpoint attaches the reward to the order, applies the corresponding discounts to qualifying line items, and adjusts the order amount accordingly. If order ID is not provided, it is your responsibility to apply the appropriate discount to the shopping cart.

Note

The Orders API allows you to add items and rewards to an order in any sequence. If you add a reward first, your application should verify that the item in the reward is also added to the order. For example, if the reward gives the buyer a free coffee, make sure the order includes coffee. If not, Square deletes the reward when the order is paid and returns the points to the buyer's loyalty account.

Reward state Permalink Get a link to this section

When CreateLoyaltyReward is called, initially the reward state is ISSUED. If the buyer chooses not to redeem the reward, you should call DeleteLoyaltyReward to delete the reward. The endpoint does the following:

  • Returns points to the buyer's account.

  • Sets the reward state to DELETED.

  • If an order ID was specified when creating the reward, the endpoint updates the order by removing the discount and updating the order amount accordingly.

If the buyer pays for the order, depending on whether an order ID was specified when creating the reward, the following happens:

  • The order ID was specified when creating the reward. Square sets the reward state to:

    • REDEEMED if the reward resulted in a discount on the order.

    • DELETED if the reward did not result in a discount on the order. In this case, the points are returned to the buyer's loyalty account. This happens asynchronously and changes might not be immediately visible if you fetch the reward using RetrieveLoyaltyReward.

  • The order ID was not specified when creating the reward. You must explicitly call RedeemLoyaltyReward to set the reward state to REDEEMED.

The reward state REDEEMED is a terminal state, after which no changes can be made (for example, you cannot delete the reward and return the points to the buyer's account).

If the reward does not get redeemed (the reward state remains ISSUED), it remains in a dangling state, where the points are simply locked (not available for the buyer to use for any other rewards). It is your responsibility to clean up any dangling rewards, for instance by deleting them on orders left open for too long.

Integration with the Customers API Permalink Get a link to this section

Every loyalty account has a customer profile associated with it in the seller's Customer Directory (see Customers). When a loyalty account is created for a buyer, only the buyer's phone number is required and the customer ID is optional. However, you should provide the customer ID when creating the loyalty account for a better experience.

If you do not provide a customer ID, Square uses the phone number to search for a customer profile. If a matching customer profile cannot be found, Square creates a new customer profile and associates it with the loyalty account. This can result in multiple customer profiles in the Customer Directory for a buyer. For example, if you previously created a customer profile for the buyer using an email address (and not a phone number), then that customer profile is not found using a phone number and another customer profile is created.

You can search for a loyalty account by customer ID. For more information, see Access a loyalty account.

Integration with the Orders API Permalink Get a link to this section

The Loyalty API is integrated with the Orders API and you should leverage this in your applications. Some of the benefits are:

  • A simplified point accrual flow. The following Loyalty API endpoints can easily compute the points to earn using information in orders created using the Orders API.

  • A simplified reward redemption flow. The Loyalty API provides the CreateLoyaltyReward endpoint to create a reward and turn the reward into appropriate discounts by automatically updating the order. The example walkthroughs shows how the integration works. For more information, see Loyalty Walkthrough 1 and Loyalty Walkthrough 2.

    The Orders API provides an added benefit when working with multiple discounts on an order. The pricing engine that Square provides can aggregate multiple discounts from various sources. Without the Orders API, you need to write code to accomplish this task.

  • Useful reports on the Seller Dashboard. The reports on the Seller Dashboard provide useful metrics about how the loyalty program is working:

    • Visits report. The Visits report uses the order data to show the number of first-time (and repeat) loyalty buyers and the average visits by loyalty (and non-loyalty) buyers for a given period.

    • Sales report. The Sales report shows sales amounts by loyalty (and non-loyalty) buyers and the average amount spent by loyalty (and non-loyalty) buyers.

      The Seller Dashboard also shows the Top Customers report.

You might choose not to use the Orders API for order processing. Depending on the loyalty program you choose, expect added development costs. However, the following loyalty programs are easier to implement without using the Orders API:

  • A loyalty program that offers visit-based accrual. Consider this points accrual rule: "earn one point for every visit, with a minimum purchase of $10." In this case, you can add points to the buyer's account with minimal code. You do not need itemized orders. For example, suppose a buyer pays $15 for an order. You can use the CalculateLoyaltyPoints endpoint to compute loyalty points and then call AccumulateLoyaltyPoints to add the points to the buyer's account.

  • A loyalty program that offers dollar-based accrual. Consider this point accrual rule: "earn one point for each dollar spent." You can use the CalculateLoyaltyPoints endpoint to compute loyalty points and then call AccumulateLoyaltyPoints to add the points to the loyalty account of the buyer. This does not require matching any order line items to compute the loyalty points.

Note that the loyalty points are calculated based on pretax amounts. If you use the Orders API, the amount of taxes you paid are known and the points are computed appropriately without the need of additional code.

Webhooks Permalink Get a link to this section

The Loyalty API supports the following webhooks:

Webhook Description
loyalty.account.created Published when a loyalty account is created for a buyer. A loyalty account can be created using any of the following methods and they all publish this event:
  • Using the Loyalty API CreateLoyaltyAccount endpoint.
  • The buyer might enroll in the program at the Square point of sale.
  • Manually on the Seller Dashboard.
  • The seller might use the Customer Directory merge feature to merge two customer accounts into one account. In this process, sellers might merge the two corresponding Square loyalty accounts by creating a new account and deleting existing accounts.
loyalty.account.updated Published for any updates to a buyer's existing loyalty account. For example:
  • If the seller updates the phone number associated with a loyalty account using the Seller Dashboard. For more information, see Square Loyalty FAQ.
  • Any change in the loyalty point balance, such as points added for visits, points expiration, or a manual adjustment to the point balance that a seller might perform.
  • The customer ID of the loyalty account changes. Perhaps the loyalty account moves to another customer.
loyalty.account.deleted Published when a loyalty account is deleted. The published event does not contain the customer_id that was associated with the (deleted) account. The following actions to delete the account can publish this event:
  • The seller uses the Seller Dashboard to delete an account.
  • The seller might use the Customer Directory merge feature to merge two customer accounts into one account. In this process, sellers might merge the two corresponding Square loyalty accounts by creating a new account and deleting existing accounts.
loyalty.program.updated Published when the loyalty program is updated from the Seller Dashboard.
loyalty.event.created Square loyalty maintains a ledger of events occurring in the lifetime of a loyalty account of a buyer. Square publishes this webhook for each loyalty event Square logs to the ledger. Loyalty events are immutable, which means they are never updated or deleted. For example, when a buyer redeems a reward and then returns it, a CREATE_REWARD event and a DELETE_REWARD event are published separately. Similarly, when a purchase that accrued points is refunded, the deduction of points publishes the ADJUST_POINTS event.

Requirements and limitations Permalink Get a link to this section

The following requirements and limitations apply when integrating the Square loyalty program in applications using the Loyalty API. For more information about the loyalty program, including pricing, see Square Loyalty.

Requirements Permalink Get a link to this section

  • In addition to setting up the loyalty program using the Square Seller Dashboard, the seller must be an active subscriber to a Square loyalty program. If a seller is not an active subscriber, the CreateLoyaltyAccount, AdjustLoyaltyPoints, and AccumulateLoyaltyPoints endpoints return BAD_REQUEST errors (other loyalty endpoints fail).

    A seller can verify the subscription status in the Seller Dashboard by choosing Business under Accounts & Settings. The ListLoyaltyPrograms also returns the subscription status.

    Loyalty Subscription Status

    If a seller is not an active subscriber, the Seller Dashboard shows a banner with an appropriate message.

Limitations Permalink Get a link to this section

  • Currently, there can be only one loyalty program in a seller account.

  • Loyalty programs can only be created and updated on the Loyalty tab of the Seller Dashboard.

  • While redeeming multiple rewards of different tiers on the same order is supported, redeeming multiple rewards of the same tier on the same order is not supported.

  • When redeeming multiple rewards on the same order, only one reward can apply to each line item. Consequently, redeeming multiple whole purchase rewards leads to the highest discount being picked and others being ignored.

Advanced usage Permalink Get a link to this section

This section explains the following Loyalty API concepts:

Deferred reward creation Permalink Get a link to this section

As explained in the Loyalty rewards section, after a reward is created, until it reaches its terminal state, Square reserves the loyalty points (the buyer cannot use the points to get a discount on any other purchases). The following actions set the reward to its terminal state:

  • A buyer can pay for the order and get the discount. In this case, the API removes the points permanently from the buyer's loyalty account and sets the reward to its terminal state of REDEEMED.

  • Your application might call DeleteLoyaltyReward to delete the reward. In this case, the API sets the reward to its terminal state of DELETED. The buyer can use the points to get discounts on other purchases.

Sometimes your application might want to show the buyer the effect of applying a reward on a purchase, for preview, without actually creating a reward (and avoid locking points). For example, consider the following eCommerce checkout flow:

  • Buyers can add items to the cart and apply available discounts to see the effect on purchase price. The buyers can keep the cart open for a long time without paying for it. Buyers might prefer to defer reward creations until they are truly ready to place an order.

  • Buyers can also walk away from the cart. Now you have permanently dangling reward objects.

In such scenarios, the application can use the CalculateOrder endpoint (the Orders API) to create a copy of an order with the specific rewards applied. The application can then show the buyer the effect of applying the discounts for preview. Later, when the buyer is ready to make a purchase, your application can call CreateLoyaltyReward to create a reward.

The following is an example CalculateOrder request:

curl -X POST \
  https://connect.squareupsandbox.com/v2/orders/calculate \
  -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"order": {
         {{ORDER}}
      },
      "proposed_rewards": [
        {
            "id": "{{RANDOM_STRING_FOR_REWARD_ID}}",
            "reward_tier_id": "{{REWARD_TIER_ID}}"
        }
    ]
}'

In the request:

  • You provide the order to which you want to apply a reward. The order can be an existing order or an order that is not yet created:

    • Existing order. If you know the order ID, you can call BatchRetrieveOrder to retrieve the order and pass the entire order object in the request body.

    • Order not yet created. Before creating an order using CreateOrder, you might want to pass the order information to CalculateOrder to preview the discount impact. You can pass the order information in the request body. For example, in the following CalculateOrder request, the body includes an order (without an order ID). In response, the endpoint returns a copy of the updated order after applying the specified reward tier:

      curl -X POST \
      https://connect.squareupsandbox.com/v2/orders/calculate \
      -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
         "order":{
            "location_id":"{{LOCATION_ID}}",
            "line_items":[
               {
                  "name":"ITEM-NAME",
                  "quantity":"1",
                  "base_price_money":{
                     "amount":1200,
                     "currency":"USD"
                  }
               }
            ]
         },
         "proposed_rewards":[
            {
               "id":"{{RANDOM_STRING_FOR_REWARD_ID}}",
               "reward_tier_id":"{{REWARD_TIER_ID}}"
            }
         ]
      }'
      
  • You specify the proposed_rewards you want to apply to the order:

    • reward_tier_id is the ID of the reward tier from the loyalty program.

    • id is the ID of the reward. Because you have not created a reward object, you specify any random string (as a reference ID identifying a reward).

    These proposed_rewards appear in the rewards[] section in the order returned in response.

The following is a skeleton of the updated order showing the discount information:

"order":{

      "line_items":[
         {
            ...
            "total_discount_money":{
               discount applied to the line item.
            },
            "total_money":{
               updated line item amount after discount
            },
            "applied_discounts":[
                ... 
            ]
         }
      ],
      "discounts":[
          array of discounts applied to the order.
      ],
      ...
      "total_discount_money":{
        ...
      },

      ...
      "rewards":[
         {
            "id": "...",
            "reward_tier_id": "..."
         },
         ...
      ]
   }
}

The highlights of the updated order are:

  • Each line item (in line_items[]) shows relevant updates. For example:

    • applied_discounts shows the discounts applied to the line item.

    • total_discount_money shows the total discount amount applied to the line item.

    • total_money shows the line item amount after the discount is applied.

  • discounts[] shows the list of discounts applied to the order.

  • rewards[] shows the list of rewards applied to the order, including the reward ID and reward tier ID.

Multiple redemption Permalink Get a link to this section

In a simple scenario, your application might choose to limit a buyer to redeem only one reward per order. The application flow is simple: show the rewards the buyer qualifies for (for example, a free coffee for 10 points and a free sandwich for 15 points) and have the buyer make the choice. After the buyer chooses the reward, adjust the point balance accordingly.

Your application can also allow buyers to redeem multiple rewards for a given order (for example, Square Point of Sale allows it). To offer a consistent experience, you might choose to implement multiple redemptions. As buyers explore redeeming one or more rewards (adding and removing rewards), your application needs to track the changes in the point balance. You have the following options:

  • If your application calls CreateLoyaltyReward (or DeleteLoyaltyReward) immediately each time a buyer adds (or removes) a reward, the loyalty account reflects the latest point balance. You can call RetrieveLoyaltyAccount to fetch the updated balance.

  • If your application uses the deferred reward creation approach as buyers add and remove rewards, the buyer's loyalty account does not accurately reflect the available point balance. Your application must keep track of the available point balance on the client side. You can use the following logic to track the available point balance on the client side:

    var availableBalance = getLoyaltyAccount().balance
    var allTiers = getLoyaltyProgram().reward_tiers
    var selectedTiers = []
    
    // Use this logic to determine which tiers are available to the buyer
    function getAvailableTiers() {
      var availableTiers = []
      for (tier : allTiers) {
        if (availableBalance >= tier.points) {
          availableTiers.push(tier)
        }
      }
      return availableTiers
    }
    
    // Use this logic when the buyer selects a tier
    function selectTier(rewardTier) {
      selectedTiers.push(rewardTier)
      availableBalance -= rewardTier.points
    }
    

When you apply multiple rewards, the Square pricing engine places rewards on the order in ways that maximize the reward value in the buyer's favor. As discounts are added to the order that the buyer placed, they can get rearranged as you add more rewards. For example, consider the following:

  • Suppose your cart has one tea and one coffee and the tea is more expensive than the coffee.

  • Suppose you have two rewards: one reward gives a free drink and another reward gives a free tea.

If you first apply the free drink reward, it discounts the tea because it is more expensive. Later, if you add the free tea reward, the discount previously added for the free drink reward is moved to discount the coffee, so that the free tea reward discount can be applied to the tea.

Loyalty events Permalink Get a link to this section

Square loyalty maintains a ledger of events that occur during the lifetime of a buyer's loyalty account. Each point balance change is recorded in the ledger. For example, each of the following activities causes an event to be added to the ledger:

  • A buyer earns points.

  • A buyer redeems a reward.

  • Loyalty points expire.

Square loyalty provides the SearchLoyaltyEvents endpoint to search the ledger for events. The Seller Dashboard uses the ledger to display information. You can also use this endpoint to query the ledger to show status information about your buyer-facing loyalty status page.

In the SearchLoyaltyEvents request, you specify query filters. The endpoint processes the filters as follows:

  • Uses a logical AND to evaluate multiple filters (for example, loyalty_account_filter and date_time_filter).

  • Uses a logical OR to evaluate repeated fields (for example, location_ids).

The following is an example SearchLoyaltyEvents request. The endpoint processes the specified filter as follows:

  • Performs a logical AND of these query filters: loyalty_account_filter, date_time_filter, type_filter, and location_filter.

  • Performs a logical OR for repeated field values: types and location_ids.

The endpoint returns all loyalty events for the loyalty account of the buyer ordered by created_at the timestamp in a descending order.

curl -X POST \
  https://connect.squareupsandbox.com/v2/loyalty/events/search \
  -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": {
        "filter": {
            "loyalty_account_filter": {
                "loyalty_account_id": "LOYALTY_ACCOUNT_ID"
            },
            "date_time_filter": {
                "created_at": {
                    "start_at": "2020-01-01T00:00:00Z",
                    "end_at": "2020-12-31T00:00:00Z"
                }
            },
            "type_filter": {
                "types": ["ACCUMULATE_POINTS", "CREATE_REWARD" ]
            },
            "location_filter": {
                "location_ids": ["M3AK819DA0XGR", "LB43CCRYUPJRZ"]
            }
        }
    },
    "limit": 30
}'