Redemptions & Discount Codes
Redeem customer loyalty points
Changed onAllows the authenticated customer to redeem their loyalty points for rewards.
Redemption flow:
- Customer selects a reward from available options
- Frontend calls this endpoint with redeemRuleId
- System validates customer has sufficient points
- Points are deducted from available balance
- Discount code is created in Shopify
- Reward record is created with status "UNUSED"
- Transaction is logged
- Updated loyalty info is returned
- 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 is lower than the 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:
- Check availablePoints before showing redemption options
- Display point cost clearly to customer
- Show expected reward (discount %, amount, etc.)
- Handle errors gracefully with clear messages
- After success, show discount code prominently
- Provide copy-to-clipboard functionality for code
- 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:
- Display available redemption options with point costs
- Customer clicks "Redeem"
- Show confirmation dialog with point cost
- Call this endpoint
- On success: Show discount code in modal/banner
- Update points display with new balance
- Add code to "My Rewards" list
post/loyalty/cp/api/redeem-points
Request
- Base URLhttps://your-store.myshopify.com/apps
- URLhttps://your-store.myshopify.com/apps/loyalty/cp/api/redeem-points
- Authnone declared
Request body
Example request
{
"customerId": 67890,
"points": 100,
"redeemRuleId": 5,
"variantId": 12345678
}Response
Points redeemed successfully, returns updated customer loyalty information with new reward
Changes
- info
added the optional property
//to the response with the status
- info
- info
added the optional property
to the response with the status
- info