Search for Balance-Changing Loyalty Events

Square Loyalty maintains a ledger of events that occur during the lifetime of a buyer's loyalty account, such as when a buyer earns points or redeems a reward. Each point balance change is recorded in the ledger.

The Loyalty API supports the following operation for working with loyalty events:

Note

Balance-changing activities also invoke the loyalty.account.updated and loyalty.event.created webhook events.

Link to section

LoyaltyEvent object

The following is an example LoyaltyEvent object:

{ "id": "bbd1ef00-92ac-3e5f-8887-cd3c6ba29313", "type": "ACCUMULATE_POINTS", "created_at": "2020-05-07T22:31:48Z", "accumulate_points": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "points": 12, "order_id": "cb9LSpDgOH3rITBaZ6eIBb9ee4F" }, "loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793", "location_id": "S8GWD5R9QB376", "source": "LOYALTY_API" }

Each event contains the ID of the associated loyalty account, the ID of the purchase location, and the event type with a corresponding metadata object:

  • An ACCUMULATE_POINTS event includes an accumulate_points object, as shown in the following excerpt:

    { ... "accumulate_points": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "points": 12, "order_id": "cb9LSpDgOH3rITBaZ6eIBb9ee4F" }, ... }

    This event is invoked when points earned from an accrual rule defined for the loyalty program are added to a loyalty account.

  • An ACCUMULATE_PROMOTION_POINTS event includes an accumulate_promotion_points object, as shown in the following excerpt:

    { ... "accumulate_promotion_points": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "loyalty_promotion_id": "93cc7415-ba40-42e6-80fc-dd8c798a39db", "points": 5, "order_id": "cb9LSpDgOH3rITBaZ6eIBb9ee4F" }, ... }

    This event is invoked when points earned from a loyalty promotion are added to a loyalty account. A purchase must first qualify for program points before it can qualify for promotion points. This event type is only supported for applications that use Orders API integration.

  • An ADJUST_POINTS event includes an adjust_points object, as shown in the following excerpts:

    Points added

    { ... "adjust_points": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "points": 5, "reason": "Lunch lottery" }, ... }

    Points removed

    { ... "adjust_points": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "points": -3, "reason": "Exchanged for item of lesser value" }, ... }
  • A CREATE_REWARD event includes a create_reward object, as shown in the following excerpt:

    { ... "create_reward": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "reward_id": "b5e384d9-f873-3f08-84b6-ba4d406d5d3b", "points": -15 }, ... }
  • A REDEEM_REWARD event includes a redeem_reward object, as shown in the following excerpt:

    { ... "redeem_reward": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "reward_id": "c307328e-0eae-3817-ad9f-e22187798007", "order_id": "YLCHbGktxbjyVDYw58mSVdfivaB" }, ... }
  • A DELETE_REWARD event includes a delete_reward object, as shown in the following excerpt:

    { ... "delete_reward": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "reward_id": "b5e384d9-f873-3f08-84b6-ba4d406d5d3b", "points": 15 }, ... }
  • An EXPIRE_POINTS event includes an expire_points object, as shown in the following excerpt:

    { ... "expire_points": { "loyalty_program_id": "8031c1b2-d749-4c76-9c40-ae5472ed2e04", "points": -5 }, ... }
  • An OTHER event is invoked when Square automatically adjusts the point balance after an order is refunded. This event is returned in SearchLoyaltyEvents results, as shown in the following excerpt:

Link to section

List or search for balance-changing events

Call SearchLoyaltyEvents endpoint to search for events that affect the point balance of loyalty accounts. Square processes any optional query filters included in the request according to a defined processing logic.

The following example request searches for ACCUMULATE_POINTS and CREATE_REWARD events for a specified loyalty account and date range. The example request also sets the limit field to specify a maximum page size of 10 results.

Search loyalty events

The following is an example response.

Results are sorted by the created_at timestamp in descending order. If no results are found, the response contains an empty object:

{}

You can use the SearchLoyaltyEvents endpoint to get status information for your buyer-facing loyalty status page. For example, the Activity section of the Seller Dashboard displays information from the ledger of events.

Link to section

How Square processes query filters

The SearchLoyaltyEvents endpoint supports several optional query filters. Square processes any query filters included in the request as follows:

  • Multiple filters in a request are evaluated using a logical AND.
  • Multiple values in an array field are evaluated using a logical OR. Both type_filter and location_filter allow you to provide an array of values.

For the following example request that includes all supported query filters except order_filter, Square processes the filters as follows:

  • Performs a logical AND of the following query filters:

    • date_time_filter
    • location_filter
    • loyalty_account_filter
    • type_filter
  • Performs a logical OR of the values in the following array fields:

    • location_ids in the location_filter
    • types in the type_filter

Search loyalty events

For the list of supported query filters, see LoyaltyEventFilter. For the list of valid loyalty events for the type_filter field, see LoyaltyEventType.

Link to section

See also