Skip to content

Storefront APIs

Languages
Servers
https://loyalty-admin.appstle.com

Storefront APIs

Customer-facing loyalty program APIs for storefront operations. These endpoints allow customers to manage their loyalty account, earn and redeem points, submit reviews, handle referrals, and track their rewards. All endpoints require customer authentication via JWT token.

Operations

Accept referral offer (POST)

Request

Accepts a referral offer when a new customer uses a referral link.

Referral flow overview:

  1. Existing customer (referrer) shares referral link
  2. New customer (referee) clicks link
  3. Link contains unique token
  4. New customer signs up or browses
  5. Call this endpoint with token and email
  6. System creates referral record
  7. May generate welcome discount for referee
  8. Referrer gets points when referee makes purchase

Request body:

  • token: Unique referral token from URL (required)
  • email: New customer's email address (required)

What this endpoint does:

  1. Validates referral token is valid
  2. Checks referral program is active
  3. Verifies referee hasn't used a referral before
  4. Creates referral record linking referee to referrer
  5. Generates welcome discount code (if configured)
  6. May award immediate points to referee
  7. Tracks referral for future reward distribution
  8. Returns discount code for referee to use

Referral rewards configuration: Different merchants configure different rewards:

  • Referee discount: Welcome discount for new customer
  • Referrer points: Points when referee makes purchase
  • Both rewards: Both parties get something
  • Tiered rewards: More for higher-value purchases

Token validation:

  • Token must exist in system
  • Token must belong to active customer
  • Customer must have referral program enabled
  • Token has no expiration (typically)
  • Each token is unique per customer

Duplicate prevention:

  • Email can only accept one referral
  • Cannot accept own referral
  • Cannot accept multiple referrals
  • First referral link used is the one that counts

Response includes:

  • id: Referral record ID
  • message: Success or error message
  • discountCode: Welcome discount for referee (if applicable)
  • status: SUCCESS or ERROR

Integration points:

Option 1: Signup page integration

// During signup process
const urlParams = new URLSearchParams(window.location.search);
const referralToken = urlParams.get('token');
if (referralToken) {
  // After customer enters email
  await acceptReferral(referralToken, customerEmail);
  // Show welcome discount to customer
}

Option 2: Landing page integration

// On referral landing page
const token = getReferralToken();
document.getElementById('claimButton').onclick = async () => {
  const email = document.getElementById('email').value;
  const response = await acceptReferral(token, email);
  showDiscountCode(response.discountCode);
};

Referral tracking states:

  • PENDING: Referral accepted, waiting for first purchase
  • COMPLETED: Referee made qualifying purchase, rewards distributed
  • EXPIRED: Referral expired before qualifying purchase

Best practices:

  1. Call this endpoint early in customer journey
  2. Store referral token in cookie/session if email not available yet
  3. Show welcome discount prominently after acceptance
  4. Explain referral benefits clearly
  5. Handle already-accepted gracefully
  6. Track conversion rate of referrals
  7. A/B test referral incentives

Common error scenarios:

  • Invalid token: Token doesn't exist or is malformed
  • Referral program inactive: Store disabled referrals
  • Already accepted: This email already used a referral
  • Self-referral: Customer trying to refer themselves
  • Token from excluded customer: Referrer is excluded from program

When rewards are distributed:

  • Referee: Welcome discount immediately on acceptance
  • Referrer: Points awarded when referee makes first purchase
  • Both: May get additional rewards for repeat purchases
Bodyapplication/jsonrequired
tokenstring
emailstring
curl -i -X POST \
  https://loyalty-admin.appstle.com/loyalty/cp/api/referral-rules/accept-offer \
  -H 'Content-Type: application/json' \
  -d '{
    "token": "string",
    "email": "string"
  }'

Responses

Referral offer accepted successfully

Bodyapplication/json
idinteger(int64)
messagestring
discountCodestring
statusstring
Enum"SUCCESS""FAILED"
Response
application/json
{ "id": 12345, "message": "Referral accepted successfully! Use code WELCOME20 for 20% off your first order.", "discountCode": "WELCOME20", "status": "SUCCESS" }

Get customer point transaction history

Request

Retrieves paginated list of point transactions for the authenticated customer, ordered by ID descending (most recent first). Each transaction includes details about points earned or spent, transaction type, status (PENDING, APPROVED, REJECTED), associated order information, and timestamps. Useful for displaying transaction history to customers.

Query
pageableobject(Pageable)required

Pagination parameters (page number, size, sort)

pageable.​pageinteger(int32)>= 0
pageable.​sizeinteger(int32)>= 1
pageable.​sortArray of strings
curl -i -X GET \
  'https://loyalty-admin.appstle.com/loyalty/cp/api/transaction-by-shop?page=0&size=1&sort=string'

Responses

Point transactions retrieved successfully with pagination headers (X-Total-Count, Link)

Bodyapplication/json
idinteger(int64)
shopstring
customerIdinteger(int64)required
pointsnumber(double)required
pointTypestringrequired
Enum"DEBIT""CREDIT"
notestring
statusstring
Enum"APPROVED""PENDING""REJECTED"
transactionRulestring
Enum"ADJUSTMENT""EARN_RULE""REDEEM_RULE""REFERRAL"
earnRuleIdinteger(int64)
earnRuleNamestring
redeemRuleRuleIdinteger(int64)
redeemRuleNamestring
autoApprovalDaysinteger(int32)
orderIdinteger(int64)
orderNamestring
createAtstring(date-time)
importedboolean
spentAmountnumber(double)
contractIdstring
orderFinancialStatusstring
orderFulfillmentStatusstring
orderLineItemIdinteger(int64)
rewardTypestring
Enum"STORE_CREDIT""DISCOUNT_CODE""POINTS"
displayNamestring
Response
application/json
[ { "id": 12345, "shop": "example-store.myshopify.com", "customerId": 67890, "points": 50, "pointType": "EARNED", "note": "Points earned for purchase", "status": "APPROVED", "transactionRule": "ORDER_PLACED", "createAt": "2025-01-15T10:30:00Z", "spentAmount": 99.99 } ]

Get logged-in customer ID

Request

Retrieves the customer ID of the currently authenticated user. This endpoint is useful for obtaining the customer ID after authentication to use in other API calls.

curl -i -X GET \
  https://loyalty-admin.appstle.com/loyalty/cp/api/logged-in-customer

Responses

Customer ID retrieved successfully

Bodyapplication/json
integer(int64)
Response
application/json
12345