Referrals
A referral program gives each member a code to share. When a friend joins with that code, Weave records who referred whom and fires one event for each side, so your rules can reward the member who shared and the friend who joined.
For example, a coffee chain gives a member 500 points and their friend a free drink when the friend signs up with the member's code.
Get a member's code
Each program membership can have one referral code. Ask for it with:
curl -X POST https://api.loomloyalty.com/customers/cust_123/programs/cpgm_456/referrals \
-H "Authorization: Bearer $LOOM_API_KEY"
The response is the customer program with its referralCode. The first call generates the code, and every later call returns the same one, so you can call it whenever you show the member their code.
Codes follow the program's referralCodeInformation. A program that sets none gets two 4-character parts joined by a hyphen, such as K7QX-9PM2.
Enroll a friend with the code
Pass the code as referralCode when you create the friend's customer record:
curl -X POST https://api.loomloyalty.com/customers \
-H "Authorization: Bearer $LOOM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"identity": { "firstName": "Sam", "lastName": "Rivera" },
"externalId": "user-2002",
"referralCode": "K7QX-9PM2"
}'
The friend is enrolled in the code's program and the referral is recorded. A code can only be given when the customer is created, not on an update.
| Error code | When |
|---|---|
CUSTOMER_REFERRAL_CODE_UNKNOWN | No member has this code. |
CUSTOMER_REFERRAL_CODE_INACTIVE | The member who owns the code is no longer active. |
CUSTOMER_REFERRAL_CODE_UPDATE_NOT_ALLOWED | referralCode was sent on an update. |
A rejected code rejects the enrollment, so show the friend a message and let them try again or join without a code.
Reward both sides
A recorded referral fires two events:
| Event type | Sent for | Reward idea |
|---|---|---|
referral.referrer | The member who shared the code | 500 bonus points |
referral.referee | The friend who joined | A welcome offer |
Both carry the programCode, the referralCode, the referrerCustomerId and the refereeCustomerId. Create an event rule on each event type in the Hub, under Engage, then Event Rules. To cap how many friends one member is rewarded for, add a condition or a target to the referrer rule.