Referrals
Accept referral offer (POST)
Changed onAccepts a referral offer when a new customer uses a referral link.
Referral flow overview:
- Existing customer (referrer) shares referral link
- New customer (referee) clicks link
- Link contains unique token
- New customer signs up or browses
- Call this endpoint with token and email
- System creates referral record
- May generate welcome discount for referee
- 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:
- Validates referral token is valid
- Checks referral program is active
- Verifies referee hasn't used a referral before
- Creates referral record linking referee to referrer
- Generates welcome discount code (if configured)
- May award immediate points to referee
- Tracks referral for future reward distribution
- 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:
- Call this endpoint early in customer journey
- Store referral token in cookie/session if email not available yet
- Show welcome discount prominently after acceptance
- Explain referral benefits clearly
- Handle already-accepted gracefully
- Track conversion rate of referrals
- 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
post/loyalty/cp/api/referral-rules/accept-offer
Request
- Base URLhttps://your-store.myshopify.com/apps
- URLhttps://your-store.myshopify.com/apps/loyalty/cp/api/referral-rules/accept-offer
- Authnone declared
Request body
Response
Referral offer accepted successfully
Changes
- info
added the optional property
to the response with the status - info
added the optional property
to the response with the status
- info
- info
added the optional property
to the response with the status - info
added the optional property
to the response with the status
- info