Skip to content

Referrals ​

Base /v1. Every person is credited to at most one referrer or affiliate, forever (growth_attributions, keyed by the person). An affiliate code or link wins over a user referral code when both arrive together. Nobody can be credited to themselves. Web links are SHARE_BASE_URL/r/<code>, deep links plemuz://r/<code>.

Flow ​

  1. The web page or app opening a link calls POST /referrals/clicks and keeps the returned clickToken.
  2. Straight after sign-up/sign-in the app calls POST /me/attribution with the code and/or click token it holds (within REFERRAL_CLAIM_WINDOW_DAYS of joining).
  3. When the referred person's first paid (non-trial) charge settles, a reward row is written and referral.reward_earned is emitted; identity's own consumer credits subscription days through the rewards port (REFERRAL_REWARD_REFERRER_DAYS, REFERRAL_REWARD_REFERRED_DAYS). Rewards are time, never money.

Fraud checks: at attribution, referrer inactive, either-way block, or a shared device → REFERRAL_NOT_ELIGIBLE. At reward time the same checks plus "paid by the referrer" and a shared payment-method fingerprint mark the reward blocked (silently).

Endpoints ​

MethodPathAuthBody / queryResponseErrors
GET/me/referraluser–{ code, webUrl, deepLink, qrPath, rewardDays: { referrer, referred } }USER_NOT_FOUND
GET/me/referralsuser–{ code, total, stats: { invited, signedUp, subscribed, rewardDaysEarned }, recent: [{ joinedAt, isVerified, hasSubscribed }] }USER_NOT_FOUND
POST/me/referraluser{ code }{ status: "ok" } (legacy, code only)as below
POST/me/attributionuser{ referralCode?, affiliateCode?, clickToken?, source?: code|link|qr|deep_link } (at least one of the first three)201 { kind: referral|affiliate, source, attributedAt }REFERRAL_ALREADY_SET 409, REFERRAL_WINDOW_CLOSED 422, REFERRAL_CODE_INVALID 422, REFERRAL_CLICK_INVALID 422, REFERRAL_NOT_ELIGIBLE 422
GET/me/attributionuser–the view above, or null–
POST/referrals/clickspublic (30/min/IP){ code, channel?: link|qr|deep_link, deviceKey? }201 { clickToken | null, expiresAt | null, deepLink } (null token for bots)REFERRAL_CODE_INVALID
GET/referrals/:code/qr.svgpublic, cacheable–image/svg+xml QR of the web linkVALIDATION_FAILED

Click tokens look like r_<uuid>.<secret> (user referral) or a_<uuid>.<secret> (affiliate); only the secret's hash is stored.

Events ​

TypeWhenPayload
identity.user.referreduser referral recorded (existing){ userId, referrerUserId }
identity.user.attributedany attribution recorded{ userId, kind, source, referrerUserId, affiliateId, affiliateLinkId, affiliateClickId, attributedAt }
referral.reward_earnedreferred person's first paid charge, not blocked{ rewardId, referrerUserId, referredUserId, paymentId, referrerDays, referredDays, earnedAt }

Notifications: referral.joined, referral.reward_earned.

Plemuz API v2