Skip to main content

POST /referrals/apply-code

Attach a referrer to this user by their referral code. The referrer's code must have been activated (24h cooldown).

The first referrer applied is recorded permanently. Applying another code may change the active referrer; when the current one cannot be changed the call is refused.

Applying a code may also grant the user perks attached to that code: free subscription days, and a trending discount (a percentage that can be time-limited). A discount is granted only when it is higher than the discount the user currently holds; an expired discount counts as 0, so a new referrer can grant again.

Use case​

End-user signup flow — apply a referral code you captured from a UTM param, affiliate link, or manual input.

Body​

FieldTypeRequiredDescription
sReferralCodestringyes1–64 chars. Matched case-insensitively.

Response 200​

{
"message": "referral code applied",
"dReferredAt": "2026-04-20T10:00:00.000Z"
}

When the referrer grants a trending discount, the response also contains:

{
"nTrendingDiscount": 20,
"dTrendingDiscountExpiry": "2026-05-20T10:00:00.000Z"
}

When the referrer grants free subscription days that extend the user's subscription, the response also contains dSubscription (ISO timestamp) and isSubscribed (boolean).

FieldDescription
dReferredAtWhen the referrer was applied.
nTrendingDiscountTrending discount percent now held by the user. Present only when this call granted one.
dTrendingDiscountExpiryISO timestamp when the discount ends, or null if it does not expire. Present together with nTrendingDiscount.
dSubscription, isSubscribedPresent only when this call extended the subscription.

Re-applying the same code is a no-op and returns { "message": "referrer already applied", "dReferredAt": … }.

Errors​

StatusMeaning
400Attempting to self-refer.
403User's current referrer is permanent and cannot be overridden.
404Code not found or still within the 24h activation cooldown.

Example​

curl -X POST "$BASE_URL/referrals/apply-code" \
-H "Authorization: Bearer $ACCESS" \
-H "x-user-id: $USER_ID" \
-H "Content-Type: application/json" \
-d '{ "sReferralCode": "ABCDEF" }'