Loyalty Account Search API Returns Empty Response Despite Customer Being Enrolled

Hi team,

We’re currently using the Square Loyalty API to search for a customer’s loyalty account using their phone number, but we’re encountering an issue where the API response is empty even though the customer is enrolled in the loyalty program and visible from the POS. Searching from the customer id also didn’t work. There are other customers for this location that we do get proper responses.

POST → https://connect.squareup.com/v2/loyalty/accounts/search

{
  "query": {
    "mappings": [
      {
        "phone_number": "+19xxxxxxxxx"
      }
    ]
  },
  "limit": 1
}

Customer ID - T1WHM7P0WXCQGX1T5B2XVNQH4R
Location Id - BR1GQW7WBEVSP

The API response we receive is just: {}

However, from the POS, we can clearly see the customer is enrolled in the loyalty program. I’ve attached screenshots from the POS showing this.

Could you help us understand why the API isn’t returning the loyalty account data? Is there something we’re missing in the request, or any other issue.

Thanks in advance for your support

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Enroll a Buyer in a Loyalty Program (Walkthrough 2)
Loyalty API
Loyalty API Example Walkthrough 1

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Hey @Sithum2020! Do you mind sharing your application ID (not your access token)? I can take a look and see what I can find.

Hi Josh

sq0idp-TpHen_F96miOUr07zsUKTw

This is my application Id

That customer_id doesn’t have a phone number associated to it which is why your getting an empty response. :slight_smile:

But on the Square POS, there is a phone number displayed for this customer. Which is the same phone number that we use for the query mapping in the loyality search API.

That customer is this customer_id: E3R0Z4T5Q17VN628E1E7K2JPH8. The customer_id you provided T1WHM7P0WXCQGX1T5B2XVNQH4R shows this in the Dashboard:


:slight_smile:

Thanks for the clarification. However, I still have a concern regarding the Loyalty API behavior.

When querying using the customer_id, I receive the expected loyalty account details. For example:

Request →

{
    "query": {
        "customer_ids": ["E3R0Z4T5Q17VN628E1E7K2JPH8"]
    },
    "limit": 10
}

Response →

{
    "loyalty_accounts": [
        {
            "id": "91e58518-d6ea-4dd8-a23e-xxxxx",
            "program_id": "755b73d7-4212-4f85-b071-xxxxxx",
            "balance": 21,
            "lifetime_points": 251,
            "customer_id": "E3R0Z4T5Q17VN628E1E7K2JPH8",
            "enrolled_at": "2018-02-25T20:00:30Z",
            "created_at": "2018-02-25T20:00:30Z",
            "updated_at": "2025-04-24T17:56:42Z",
            "mapping": {
                "id": "f738f021-e961-4362-b625-20fd8ac07961",
                "created_at": "2018-02-25T20:00:30Z",
                "phone_number": "+1xxxxxxxxxx"
            },
            "expiring_point_deadlines": [...]
        }
    ]
}

However, when I query using the customer’s phone number instead of the customer_id, no loyalty account is returned — even though the customer record has a phone number associated with it.

I also noticed that the phone_number shown under the mapping section of the loyalty account is different from the phone number associated with the customer profile.

Could you please explain:

  • Why the loyalty account lookup by phone number doesn’t return any results ?
  • Why the mapping.phone_number differs from the customer’s phone number ?

Just a kind reminder — really appreciate it if you could share an explanation for this.

Looks like that customer has a different phone number than whats associated to the loyalty account which is why the empty response is being returned. :slight_smile:

According to this article,

Updating the customer’s phone number will update the loyalty number as well.

Can you explain how and why the loyalty number is not updated when the customers’s phone number was changed ?

So the customers profile was updated this way? Do you know when it was updated so the team can look into this? :slight_smile:

Since the merchant is unable to recall the exact date and time of the update, it’s difficult to determine when the change was made.

We are just trying to understand the reason for the discrepancy between the customer’s current phone number and the one displayed in the locality mapping.

Kind reminder on this. Appreciate if we can get some explanation.