Docs/Events/Referral events

Referral events#

Referral events are addressed to the advocate: the customer whose referral code a friend used. They use the hierarchy and envelope documented in the Events overview.

Ref pattern: referrals/{action}

Catalog#

Event groupRefDescription
referral_friend_orderedreferrals/friend_orderedA friend placed an order with the advocate's code
referral_reward_earnedreferrals/reward_earnedThe advocate's reward code was issued after the delay ran

Webhooks subscribed to * or referrals receive both events. Subscribe to a single ref to receive only that event.

Context#

context.order is the advocate's order (the one their referral code came from) and context.customer is the advocate. No event is sent when the advocate's order has no customer id (e.g. guest checkout) or no address.

event_data shape#

Every key is always present; values marked nullable can be null.

referral_friend_ordered#

FieldTypeDescription
referral_codestringThe advocate's referral code
share_urlstring, nullableLink that applies the code in your store; null without a storefront URL or once the code expired
reward_valuenumberAdvocate reward amount or percentage
reward_typestringpercentage or fixed
currencystring, nullableCurrency of a fixed reward
reward_delay_daysnumberDays after the friend's order until the reward is issued
friend_order_numberstring, nullableThe friend's order number
unique_idstringIdempotency key, unique per referral
referral_redemption_idstringKarla's id for this referral
event_groupstringreferral_friend_ordered
{
  "referral_code": "ANNA-7KQ2",
  "share_url": "https://shop.example.com/discount/ANNA-7KQ2?redirect=/",
  "reward_value": 10.0,
  "reward_type": "percentage",
  "currency": "EUR",
  "reward_delay_days": 14,
  "friend_order_number": "1042",
  "unique_id": "karla_referral_friend_ordered:5b1f0c9e-2a8d-4f6b-9c1e-3d7a2b4e6f80",
  "referral_redemption_id": "5b1f0c9e-2a8d-4f6b-9c1e-3d7a2b4e6f80",
  "event_group": "referral_friend_ordered"
}

referral_reward_earned#

FieldTypeDescription
reward_codestringThe discount code issued to the advocate
reward_valuenumberReward amount or percentage
reward_typestringpercentage or fixed
currencystring, nullableCurrency of a fixed reward
reward_expires_atstringWhen the reward code expires (ISO 8601, UTC)
friend_order_numberstring, nullableThe friend's order number
unique_idstringIdempotency key, unique per referral
referral_redemption_idstringKarla's id for this referral
event_groupstringreferral_reward_earned
{
  "reward_code": "REWARD-9XP4",
  "reward_value": 10.0,
  "reward_type": "fixed",
  "currency": "EUR",
  "reward_expires_at": "2027-01-15T00:00:00+00:00",
  "friend_order_number": "1042",
  "unique_id": "karla_referral_reward_earned:5b1f0c9e-2a8d-4f6b-9c1e-3d7a2b4e6f80",
  "referral_redemption_id": "5b1f0c9e-2a8d-4f6b-9c1e-3d7a2b4e6f80",
  "event_group": "referral_reward_earned"
}

Delivery#

Referral events are sent once, best effort: a delivery that fails is not retried. Don't rely on them as guaranteed delivery; the reward code is also issued in Shopify regardless of whether the event arrives.

In the Karla Shopify app, both events are available as Shopify Flow triggers, Referral Friend Ordered and Referral Reward Earned. Their karla object carries referralCode, shareUrl, rewardCode, rewardValue, rewardType, currency, rewardDelayDays, rewardExpiresAt and friendOrderNumber (for example {{karla.rewardCode}}); fields the event does not carry are empty. unique_id, referral_redemption_id and event_group are webhook-only and not available in Flow.

Was this helpful?