How referrals work
Roles
Self-referral is ignored: the same customer cannot use their own code, and
referred_customer_id matching the event customer is rejected.
Requesting a code
Referrers obtain a code through the Storefront API:POST /api/storefront/v1/customers/{id}/referrals/request-code
If the customer already has a code for that campaign, the existing row is returned. New codes:
- Are 8 characters from
A–Z/0–9(ambiguous characters likeIandOare omitted) - Set
max_usesfromattributes.max_participations_per_customer - Start with
uses_count: 0
Qualifying event
The referee must emit a behavior event that:- Matches campaign
attributes.trigger(for example"PURCHASE"or a custom type such as"REFERRALS") - Includes a valid
referral_code - Is processed as fulfilled when you want rewards applied (same fulfillment rules as other campaigns)
- Increments the code’s
uses_count(blocked whenuses_count >= max_uses) - Increments campaign
attributes.uses - Applies referee rewards from
attributes.referee_ruleson the referee’s event (if any rules exist) - Inserts a
REWARD_REFERRERevent for the referrer and processes it asynchronously with the campaign’s mainrules
Referrer vs referee rules
At least one of referrer or referee rewards must be configured when creating the campaign. Referrer rules can include normal conditions (payment method, audiences, and so on). Those conditions are evaluated on the
REWARD_REFERRER event context.
Example shape:
Campaign configuration
Hard limit enforced at processing time is the code use limit (
uses_count vs max_uses), not stock.
Event reversal
Reversing the referee’s original event can also reverse the linked referrer reward:- Masivo looks up a
REWARD_REFERRERevent whosedata.original_event_idmatches the reversed event. - If that referrer event is
RESOLVED, it is included in the normal reversal flow.