LoyaltyAccounts
Create and query Square Loyalty accounts.
Table Specific Information
Select
The connector uses the Square API to filter the results by the following columns and operators while the rest of the filter is executed client-side within the connector.
- Id supports the following operator: =.
- CreatedAt supports the following operators: =, >=, <=, >, <.
- CustomerId supports the following operator: =.
- MappingPhoneNumber supports the following operator: =.
- ProgramId supports the following operator: =.
Retrieve all loyalty accounts:
SELECT * FROM LoyaltyAccounts
Retrieve a specific loyalty account:
SELECT * FROM LoyaltyAccounts WHERE Id = 'loyalty_account_id_here'
Retrieve loyalty accounts by customer ID:
SELECT * FROM LoyaltyAccounts WHERE CustomerId = 'customer_id_here'
Retrieve loyalty accounts by phone number:
SELECT * FROM LoyaltyAccounts WHERE MappingPhoneNumber = '+14155551111'
Insert
To create a loyalty account, you must specify the ProgramId and IdempotencyKey columns. A phone number via the MappingPhoneNumber column is required to create a loyalty account.
INSERT INTO LoyaltyAccounts (ProgramId, MappingPhoneNumber, IdempotencyKey) VALUES ('PROGRAM_ID', '+14155551111', 'unique-idempotency-key')
Columns
| Name | Type | ReadOnly | Description |
| Id [KEY] | String | True |
The Square-assigned ID of the loyalty account. |
| ProgramId | String | False |
The Square-assigned ID of the loyalty program to which the account belongs. |
| CustomerId | String | False |
The Square-assigned ID of the customer that is associated with the account. |
| Balance | Integer | True |
The available point balance in the loyalty account. If points are scheduled to expire, they are listed in the expiring_point_deadlines field. May be negative from refunds or adjustments. |
| LifetimePoints | Integer | True |
The total points the account has accumulated over its lifetime, including redeemed points. |
| EnrolledAt | Datetime | False |
The timestamp when the buyer joined the loyalty program, in RFC 3339 format. Auto-populated after the first account action if not set during creation. |
| ExpiringPointDeadlines | String | True |
The schedule for when points expire in the loyalty account balance. Present only if the account has points scheduled to expire. |
| CreatedAt | Datetime | True |
The timestamp when the loyalty account was created, in RFC 3339 format. |
| UpdatedAt | Datetime | True |
The timestamp when the loyalty account was last updated, in RFC 3339 format. |
| MappingId | String | True |
The Square-assigned ID of the mapping between the loyalty account and the buyer. |
| MappingCreatedAt | Datetime | True |
The timestamp when the mapping was created, in RFC 3339 format. |
| MappingPhoneNumber | String | False |
The phone number of the buyer, in E.164 format (e.g. +14155551111). Required to create a loyalty account. |
Pseudocolumns
Pseudo column fields are used in the WHERE clause of SELECT statements (unless stated otherwise) and offer a more granular control over the tuples that are returned from the data source.
| Name | Type | Description |
| IdempotencyKey | String |
A unique string that identifies the request. Required for INSERT operations. Maximum 128 characters. |