Square: Search Loyalty Accounts
Square loyalty.searchLoyaltyAccounts: arguments, response, policy and SDK examples.
← Loyalty operations · Get started
Operation square.searchloyaltyaccounts
Provider route: POST /v2/loyalty/accounts/search. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/square with npm, or alter-sdk-square with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { SquareIntegration } from "@alter-ai/square";
async function execute(input: Parameters<SquareIntegration["loyalty"]["searchLoyaltyAccounts"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new SquareIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.loyalty.searchLoyaltyAccounts(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_square import SquareIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = SquareIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.loyalty.search_loyalty_accounts(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
body | Model | Required within parent | Expand Search Loyalty Accounts — request body — body |
Referenced models: Search Loyalty Accounts — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Search Loyalty Accounts — response body |
Referenced models: Search Loyalty Accounts — response body
Schemas
Section titled “Schemas”1 more schema is linked from the tables above, on the schema pages.
Search Loyalty Accounts — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A response that includes loyalty accounts that satisfy the search criteria. |
cursor | string | Optional | The pagination cursor to use in a subsequent request. If empty, this is the final response. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). |
errors | array | Optional | Any errors that occurred during the request. |
errors[] | Model | Each item | Expand Get Shift — response body — errors item |
loyalty_accounts | array | Optional | The loyalty accounts that met the search criteria, in order of creation date. |
loyalty_accounts[] | Model | Each item | Expand Create Loyalty Account — response body — loyalty account |
Referenced models: Get Shift — response body — errors item, Create Loyalty Account — response body — loyalty account
Search Loyalty Accounts — request body — body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A request to search for loyalty accounts. |
cursor | string | Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). |
limit | integer | Optional | The maximum number of results to include in the response. The default value is 30. Maximum: 200 Minimum: 1 |
query | Model | Optional | Expand Search Loyalty Accounts — request body — body query The search criteria for the request. |
Referenced models: Search Loyalty Accounts — request body — body query
Get Shift — response body — errors item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents an error encountered during a request to the Connect API. See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information. |
category | string | Required within parent | Indicates which high-level category of error has occurred during a request to the Connect API. The high-level category for the error. See [ErrorCategory](#type-errorcategory) for possible values Known values: API_ERROR, AUTHENTICATION_ERROR, INVALID_REQUEST_ERROR, RATE_LIMIT_ERROR, PAYMENT_METHOD_ERROR, REFUND_ERROR, MERCHANT_SUBSCRIPTION_ERROR, EXTERNAL_VENDOR_ERROR |
code | Model | Required within parent | Expand Get Shift — response body — errors item code The specific code of the error. See [ErrorCode](#type-errorcode) for possible values |
detail | string | Optional | A human-readable description of the error for debugging purposes. |
field | string | Optional | The name of the field provided in the original request (if any) that the error pertains to. |
Referenced models: Get Shift — response body — errors item code
Create Loyalty Account — response body — loyalty account
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Describes a loyalty account in a [loyalty program](entity:LoyaltyProgram). For more information, see [Create and Retrieve Loyalty Accounts](https://developer.squareup.com/docs/loyalty-api/loyalty-accounts). |
balance | JSON | Optional | |
balance (anyOf 1) | integer | Alternative | The available point balance in the loyalty account. If points are scheduled to expire, they are listed in the `expiring_point_deadlines` field. 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. Read only: true |
balance (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
created_at | string | Optional | The timestamp when the loyalty account was created, in RFC 3339 format. Read only: true |
customer_id | JSON | Optional | |
customer_id (anyOf 1) | string | Alternative | The Square-assigned ID of the [customer](entity:Customer) that is associated with the account. |
customer_id (anyOf 2) | null | Alternative | |
enrolled_at | JSON | Optional | |
enrolled_at (anyOf 1) | string | Alternative | The timestamp when the buyer joined the loyalty program, in RFC 3339 format. This field is used to display the **Enrolled On** or **Member Since** date in first-party Square products. If this field is not set in a `CreateLoyaltyAccount` request, Square populates it after the buyer's first action on their account (when `AccumulateLoyaltyPoints` or `CreateLoyaltyReward` is called). In first-party flows, Square populates the field when the buyer agrees to the terms of service on Square Point of Sale. If this field is set in a `CreateLoyaltyAccount` request, it is meant to be used when there is a loyalty migration from another system and into Square. In that case, the timestamp can reflect when the buyer originally enrolled in the previous system. It may represent a current or past date, but cannot be set in the future. Note: Setting this field in this scenario does not, by itself, impact the first-party enrollment flow on Square Point of Sale. |
enrolled_at (anyOf 2) | null | Alternative | |
expiring_point_deadlines | JSON | Optional | |
expiring_point_deadlines (anyOf 1) | array | Alternative | The schedule for when points expire in the loyalty account balance. This field is present only if the account has points that are scheduled to expire. The total number of points in this field equals the number of points in the `balance` field. |
expiring_point_deadlines (anyOf 1)[] | Model | Each item | Expand Create Loyalty Account — response body — loyalty account expiring point deadlines array item |
expiring_point_deadlines (anyOf 2) | null | Alternative | |
id | string | Optional | The Square-assigned ID of the loyalty account. Maximum length: 36 Read only: true |
lifetime_points | JSON | Optional | |
lifetime_points (anyOf 1) | integer | Alternative | The total points accrued during the lifetime of the account. Read only: true |
lifetime_points (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
mapping | JSON | Optional | |
mapping (anyOf 1) | Model | Alternative | Expand Create Loyalty Account — response body — loyalty account mapping created at, id, phone number The mapping that associates the loyalty account with a buyer. Currently, a loyalty account can only be mapped to a buyer by phone number. To create a loyalty account, you must specify the `mapping` field, with the buyer's phone number in the `phone_number` field. |
mapping (anyOf 2) | null | Alternative | |
program_id | string | Required within parent | The Square-assigned ID of the [loyalty program](entity:LoyaltyProgram) to which the account belongs. Maximum length: 36 Minimum length: 1 |
updated_at | string | Optional | The timestamp when the loyalty account was last updated, in RFC 3339 format. Read only: true |
Referenced models: Create Loyalty Account — response body — loyalty account mapping created at, id, phone number, Create Loyalty Account — response body — loyalty account expiring point deadlines array item
Search Loyalty Accounts — request body — body query
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | The search criteria for the loyalty accounts. |
customer_ids | JSON | Optional | |
customer_ids (anyOf 1) | array | Alternative | The set of customer IDs to use in the loyalty account search. This cannot be combined with `mappings`. Max: 30 customer IDs |
customer_ids (anyOf 1)[] | string | Each item | |
customer_ids (anyOf 2) | null | Alternative | |
mappings | JSON | Optional | |
mappings (anyOf 1) | array | Alternative | The set of mappings to use in the loyalty account search. This cannot be combined with `customer_ids`. Max: 30 mappings |
mappings (anyOf 1)[] | Model | Each item | Expand Create Loyalty Account — response body — loyalty account mapping created at, id, phone number |
mappings (anyOf 2) | null | Alternative |
Referenced models: Create Loyalty Account — response body — loyalty account mapping created at, id, phone number
Create Loyalty Account — response body — loyalty account mapping created at, id, phone number
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents the mapping that associates a loyalty account with a buyer. Currently, a loyalty account can only be mapped to a buyer by phone number. For more information, see [Loyalty Overview](https://developer.squareup.com/docs/loyalty/overview). |
created_at | string | Optional | The timestamp when the mapping was created, in RFC 3339 format. Read only: true |
id | string | Optional | The Square-assigned ID of the mapping. Maximum length: 36 Read only: true |
phone_number | JSON | Optional | |
phone_number (anyOf 1) | string | Alternative | The phone number of the buyer, in E.164 format. For example, "+14155551111". |
phone_number (anyOf 2) | null | Alternative |
Create Loyalty Account — response body — loyalty account expiring point deadlines array item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a set of points for a loyalty account that are scheduled to expire on a specific date. |
expires_at | string | Required within parent | The timestamp of when the points are scheduled to expire, in RFC 3339 format. Minimum length: 1 |
points | JSON | Required within parent | |
points (anyOf 1) | integer | Alternative | The number of points scheduled to expire at the `expires_at` timestamp. |
points (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: square.searchloyaltyaccounts. Catalog operation: SearchLoyaltyAccounts. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.
Required provider scopes: ["LOYALTY_READ"]
Pinned headers: {"Square-Version": "2026-11-18"}