Skip to content

Promotions & Referrals

Phase 2 includes a full promotions engine supporting percentage and fixed-amount discounts, promotional codes, usage limits, validity windows, and a referral program.

Promotions

A Promotion defines a discount rule that can be applied during enrollment or subscription renewal.

FieldDescription
NameDisplay name
DescriptionOptional description
DiscountTypepercentage or fixed_amount
DiscountValueAmount or percentage to deduct
SpecificPlanIdRestrict to a single plan (null = all plans)
ValidFrom / ValidUntilOptional date window
MaxTotalUsesOptional global usage cap
MaxUsesPerUserOptional per-member cap
IsActiveWhether the promotion is available

Discount Types

TypeCodeExample
Percentagepercentage20% off first month
Fixed amountfixed_amount€10 off

Validation Flow

When a promo code or promotion ID is submitted at enrollment:

  1. The promotion is looked up and validated:
    • IsActive = true
    • Within ValidFrom / ValidUntil window
    • CurrentUses < MaxTotalUses (if set)
    • Member usage < MaxUsesPerUser (if set)
    • Plan matches SpecificPlanId (if set)
  2. If valid, the discount is applied to the computed price
  3. A PromotionUsage record is created to track the application

Promotional Codes

Promo codes are standalone codes that map to a Promotion. They allow distributing specific discounts externally (marketing campaigns, events, referrals).

MethodPathPermissionDescription
GET/api/promo-codespromo_codes:readList codes
POST/api/promo-codespromo_codes:writeCreate a code
GET/api/promo-codes/{id}promo_codes:readGet code details
DELETE/api/promo-codes/{id}promo_codes:deleteDeactivate code
POST/api/promo-codes/validate— (public)Validate a code before use

Promotions API

MethodPathPermissionDescription
GET/api/promotionspromotions:readList promotions
POST/api/promotionspromotions:writeCreate promotion
GET/api/promotions/{id}promotions:readGet promotion details
PUT/api/promotions/{id}promotions:writeUpdate promotion
DELETE/api/promotions/{id}promotions:deleteDeactivate promotion

Referral Program

Every member receives a unique ReferralCode upon enrollment. When a new member enrolls using an existing member's referral code:

  1. A Referral record is created linking referrer → referee
  2. An optional reward is applied (configured per referral program settings)
  3. The referrer is notified

Referral Entities

EntityDescription
ReferralCodeUnique code per member (auto-generated at enrollment)
ReferralRecords a successful referral — who referred whom and when

Referral API

MethodPathPermissionDescription
GET/api/referralsreferrals:readList all referrals
GET/api/referrals/leaderboardreferrals:readTop referrers leaderboard
GET/api/users/me/referral-code— (authenticated)Get own referral code
GET/api/users/me/referrals— (authenticated)Get own referral history

Cleanup Automation

CleanupExpiredPromoCodesJob runs nightly to deactivate promotional codes whose ValidUntil date has passed. This keeps the code list clean without requiring manual housekeeping.

Frontend Routes

RouteViewPermission
/club/promotionsPromotionsViewpromotions:read
/club/promotions/newPromotionCreateViewpromotions:write
/club/promotions/:idPromotionDetailViewpromotions:read
/club/referralsReferralsViewreferrals:read
/club/referrals/leaderboardReferralLeaderboardViewreferrals:read