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

Send customer referral email

Request

Sends a referral invitation email to a friend on behalf of the authenticated customer.

How referrals work:

  1. Customer sends referral email to friend
  2. Friend receives email with unique referral link
  3. Friend clicks link and creates account/makes purchase
  4. Both customer (referrer) and friend (referee) may receive rewards
  5. Rewards based on referral rule configuration

Request body:

  • email: Friend's email address (required, must be valid)
  • Can include additional fields like name, message (check your configuration)

Email content:

  • Contains customer's unique referral link
  • Describes referral rewards (e.g., "You get $10 off, they get $10 off")
  • Uses your configured email template
  • Branded with your store logo and colors
  • Includes call-to-action button

Rate limiting:

  • Default limit: 500 emails per shop per day
  • Prevents spam and abuse
  • 429 error if limit exceeded
  • Limit resets daily
  • Contact support to adjust limits if needed

Activity logging:

  • Each send is logged for analytics
  • Track referral email performance
  • Monitor for fraudulent activity
  • View in admin dashboard

Referral tracking:

  • Unique referral link embedded in email
  • Tracks when friend clicks link
  • Attributes purchase to referrer
  • Shows in customer's referral history

Authentication: Requires customer JWT token. The authenticated customer is the referrer.

Validation:

  • Email address format validation
  • Duplicate email checking (optional)
  • Customer must be enrolled in loyalty program
  • Referral program must be active
  • Customer not excluded from program

Best practices:

  1. Allow customers to preview email before sending
  2. Show referral incentives clearly
  3. Provide email template customization
  4. Track success rate and optimize messaging
  5. Consider social sharing alternatives
  6. Display referral link prominently for manual sharing
  7. Limit sends per customer to prevent spam

Example UI flow:

1. Customer enters friend's email
2. Optional: Add personal message
3. Preview email content
4. Click "Send Invitation"
5. Call this endpoint
6. Show success message
7. Update referral count display
8. Add to "Sent Invitations" list

Error scenarios:

  • Invalid email format: 400 error
  • Rate limit exceeded: 429 error (show retry time)
  • Customer not enrolled: 400 error
  • Referral program inactive: 400 error
  • Email service failure: 500 error (retry)

Success response: Returns 200 with no body. Email sent successfully.

Alternative sharing methods: Instead of email, customers can also:

  • Copy referral link directly (GET referral URL first)
  • Share on social media
  • Use QR code
  • Share via SMS (if configured)
Bodyapplication/jsonrequired
emailstring
curl -i -X POST \
  https://loyalty-admin.appstle.com/loyalty/cp/api/send-customer-referral-url \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "string"
  }'

Responses

Referral email sent successfully

Response
No content

Redeem customer loyalty points

Request

Allows the authenticated customer to redeem their loyalty points for rewards.

Redemption flow:

  1. Customer selects a reward from available options
  2. Frontend calls this endpoint with redeemRuleId
  3. System validates customer has sufficient points
  4. Points are deducted from available balance
  5. Discount code is created in Shopify
  6. Reward record is created with status "UNUSED"
  7. Transaction is logged
  8. Updated loyalty info is returned
  9. Customer receives discount code to use at checkout

Request body fields:

  • redeemRuleId: ID of reward to redeem (required) Get available options from GET /loyalty/cp/api/customer-loyalty
  • points: Override default points (optional) If not provided, uses the redemption rule's default point value
  • variantId: Required for product-specific rewards (optional) Shopify variant ID for "free product" type rewards

Authentication: Requires customer JWT token. The authenticated customer is the one redeeming points. Cannot redeem points on behalf of another customer.

Validation checks:

  • Customer is authenticated
  • Customer has sufficient availablePoints
  • Redemption rule exists and is active
  • For product rewards, variantId is provided
  • Customer is enrolled in loyalty program
  • Customer status is ACTIVE (not excluded)

What happens to points:

  • Deducted from availablePoints immediately
  • Added to lifetime spending total
  • Transaction created with type "REDEEMED"
  • Cannot be undone (points deduction is final)

Discount code generation:

  • For discounts: Creates Shopify discount code
  • Code is unique per customer
  • Has expiry date if configured
  • Minimum purchase amount if configured
  • Product/collection restrictions if configured

Store credit rewards:

  • Adds value to storeCreditBalance instead of creating discount code
  • Can be used as payment method at checkout
  • Managed separately from Shopify discount codes

Error scenarios:

  • Insufficient points: availablePoints < required points
  • Invalid rule: redeemRuleId doesn't exist or is inactive
  • Missing variantId: Required for product rewards
  • Customer not enrolled: Must enroll first
  • Customer excluded: EXCLUDED or EXCLUDED_BY_CUSTOMER status
  • System error: Shopify API failure, discount code creation failure

Best practices:

  1. Check availablePoints before showing redemption options
  2. Display point cost clearly to customer
  3. Show expected reward (discount %, amount, etc.)
  4. Handle errors gracefully with clear messages
  5. After success, show discount code prominently
  6. Provide copy-to-clipboard functionality for code
  7. Explain when/how to use the discount code

Example response handling:

// After successful redemption
const response = await redeemPoints(ruleId);
// Find the newly created reward
const newReward = response.rewards.find(r => r.status === 'UNUSED');
// Display to customer
showDiscountCode(newReward.discountCode, newReward.expiryDate);

Common UI flow:

  1. Display available redemption options with point costs
  2. Customer clicks "Redeem"
  3. Show confirmation dialog with point cost
  4. Call this endpoint
  5. On success: Show discount code in modal/banner
  6. Update points display with new balance
  7. Add code to "My Rewards" list
Bodyapplication/json
customerIdinteger or null(int64)

Shopify customer ID (numeric). Identifies which customer is redeeming points. Provide either customerId OR customerEmail, not both. Example: 67890

Example: 67890
customerEmailstring or null

Customer's email address. Alternative to customerId for identifying the customer. Provide either customerId OR customerEmail, not both. Must be a valid email address that exists in your Shopify store. Example: customer@example.com

Example: "customer@example.com"
redeemRuleIdinteger(int64)required

ID of the redemption rule to use. Determines what reward the customer receives. Use GET /api/external/point-redeem-rules to get available redemption options. Must be an active redemption rule configured in your loyalty program. Example: 5

Example: 5
pointsnumber or null(double)

Number of points to redeem. Must be positive. If not provided, uses the default points value from the redemption rule. Customer must have at least this many available points. Example: 100.0

Example: 100
variantIdinteger or null(int64)

Shopify product variant ID. Required when redeeming for product-specific rewards (free product). Not required for discount codes or store credit rewards. Must be a valid variant ID from your Shopify catalog. Example: 12345678

Example: 12345678
curl -i -X POST \
  https://loyalty-admin.appstle.com/loyalty/cp/api/redeem-points \
  -H 'Content-Type: application/json' \
  -d '{
    "customerId": 67890,
    "redeemRuleId": 5,
    "points": 100,
    "variantId": 12345678
  }'

Responses

Points redeemed successfully, returns updated customer loyalty information with new reward

Bodyapplication/json
availablePointsnumber(double)
pendingPointsnumber(double)
creditedPointsnumber(double)
spentAmountnumber(double)
storeCreditBalancenumber(double)
achievableTierIdinteger(int64)
currentVipTierstring
vipTierExpiredAtstring(date-time)
createAtstring(date-time)
rewardedForFacebookboolean
rewardedForPinterestboolean
rewardedForTwitterboolean
rewardedForInstagramboolean
rewardedForYoutubeboolean
rewardedForTiktokboolean
rewardedForNewsLetterboolean
rewardedForSmsboolean
referredCompletedinteger(int64)
referralLinkstring
customerStatusstring
Enum"ACTIVE""INACTIVE""EXCLUDED""EXCLUDED_BY_CUSTOMER"
dobstring(date)
rewardsArray of objects(CustomerReward)
rewardedForCreatingAccountboolean
rewardedForSharingOnFacebookboolean
rewardedForSharingOnXboolean
Response
application/json
{ "availablePoints": 150, "pendingPoints": 25, "creditedPoints": 500, "rewards": [ {} ], "currentVipTier": "Gold" }

Enroll customer in loyalty program

Request

Enrolls the authenticated customer in the loyalty program and optionally assigns them to a specific VIP tier. This endpoint activates all loyalty features for the customer, allowing them to earn and redeem points. If a VIP tier is specified, the customer is automatically placed in that tier upon enrollment. Creates necessary customer records and triggers any welcome rewards configured in the system.

Bodyapplication/jsonrequired
vipTierstring
curl -i -X POST \
  https://loyalty-admin.appstle.com/loyalty/cp/api/enroll-customer \
  -H 'Content-Type: application/json' \
  -d '{
    "vipTier": "string"
  }'

Responses

Customer enrolled successfully

Bodyapplication/json
string
Response
application/json
"Customer added successfully."