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
| Field | Type | Required | Description |
|---|---|---|---|
sReferralCode | string | yes | 1–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).
| Field | Description |
|---|---|
dReferredAt | When the referrer was applied. |
nTrendingDiscount | Trending discount percent now held by the user. Present only when this call granted one. |
dTrendingDiscountExpiry | ISO timestamp when the discount ends, or null if it does not expire. Present together with nTrendingDiscount. |
dSubscription, isSubscribed | Present only when this call extended the subscription. |
Re-applying the same code is a no-op and returns
{ "message": "referrer already applied", "dReferredAt": … }.
Errors
| Status | Meaning |
|---|---|
400 | Attempting to self-refer. |
403 | User's current referrer is permanent and cannot be overridden. |
404 | Code 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" }'