Retention Programs
Loyalty points, memberships, service packages, gift cards, store credit, and referrals.
8 min read
Overview
Retention programs give clients a reason to keep coming back and to deepen their relationship with the brand. Kagami provides five retention instruments: loyalty points, memberships, service packages, gift cards, and store credit (wallet). These are linked to the client profile and redeemable at checkout.

Loyalty Points
A loyalty programme rewards clients with points on every visit or purchase.
Earning Points
Earning is driven by loyalty rules (loyalty_rules, per brand, each switchable on or off). When an invoice is paid for a client, every active rule is applied:
| Rule type | Effect at checkout |
|---|---|
per_visit |
A fixed number of points per paid invoice |
per_spend |
points for every unit_minor (e.g. 1 point per ₹100) of the invoice total, rounded down |
birthday, referral |
Selectable in the rule form but not applied by the checkout earn path (referral points come from the referral programme, see below) |
Points are not earned on an invoice that was paid with loyalty points (to stop a redeem-and-earn loop). There is no per-category or retail-vs-service rate, and no birthday multiplier. Staff can also add points manually or adjust a balance (never below zero) from the Loyalty page.
Reward Tiers
Tiers are defined per brand (reward_tiers) and are based on the current points balance only. There is no annual-spend qualification and no yearly reset.
Each tier has a name, min_points, a colour, perks text, a points multiplier and a discount percentage. A client's tier is the highest active tier whose min_points is at or below their balance, so spending points can lower it.
The client portal shows the current tier, the next tier and points needed, and displays the tier's discount percentage. Tier benefits are informational today: the points multiplier and discount percentage are stored and shown but are not applied at checkout or when earning points.
Redeeming Points
At checkout, "Loyalty points" is a payment tender (also usable inside a split payment). The tender amount in rupees is converted 1:1 to points and debited through the redeem_loyalty_points function, which locks the client row and refuses if the balance is insufficient. If a later checkout step fails, the points are restored. Clients can also use points toward an online booking deposit.
The Retention > Loyalty settings screen also stores loyalty_configs (is_enabled, points_per_100, points_value, min_redeem, max_redeem_pct). Those fields are not read by the live checkout path above (the helpers in lib/retention/loyalty.ts that use them have no callers), so there is currently no enforced minimum redemption, rupee-per-point rate or per-visit cap, and the Enabled switch does not gate earning. Only is_enabled and expiry_days are used, by the expiry job.
Expiry
When loyalty_configs.is_enabled is on with expiry_days set, a daily job (/api/cron/loyalty-points-expiry) sends a WhatsApp reminder 7 days before a balance lapses and then zeroes balances with no transactions for expiry_days. The clock resets on any earn, redeem or adjustment.
Loyalty Account
Each client has a points ledger per brand (loyalty_transactions, types earn, redeem, adjust, expire), where the latest balance_after is the balance. The Loyalty page shows brand totals (earned, redeemed, active members, outstanding) and a leaderboard of the top 50 balances. Tier is derived from the balance, not stored.
Memberships
Memberships are recurring monthly or annual subscriptions that give clients access to benefits at a fixed fee.
Membership Structures
| Type | Example |
|---|---|
| Included services | "Glow Plan" — 2 haircuts + 1 deep conditioning per month |
| Discount on all services | "Silver Member" — 15% off all services |
| Mixed | "Unlimited Blowouts" — unlimited blowouts + 10% off everything else |
Membership Lifecycle
Plans have a kind (club, a recurring benefit plan, or value_pack, a prepaid pack with a validity period) and a billing cycle (weekly, monthly, quarterly, annually).
- Purchase — staff enrol the client at checkout; status starts
active - Dates —
renews_at/next_payment_atare recorded from the billing cycle (ends_atfor value packs) - Status — staff can set a membership to
paused,cancelledorexpired
No scheduled job was found that bills or renews a membership automatically or notifies the client before renewal; the dates are informational and renewal is a manual sale (unverified beyond a search of the cron routes).
Free-Session Redemption Audit Trail
Every time a membership's included free service is redeemed, a membership_redemptions
row is written (migration 0088). This mirrors the package_redemptions pattern:
| Column | Purpose |
|---|---|
client_membership_id |
Which membership subscription was used |
appointment_id |
The appointment the service was rendered for (nullable) |
invoice_id |
The invoice the redemption was applied to (nullable) |
redeemed_at |
Timestamp of redemption |
The remaining session allowance is derived by counting redemptions — there is no mutable counter that can go out of sync. This provides a tamper-evident audit trail for disputes.
Using Membership Benefits at Checkout
When a client with an active membership is checked out:
- Included services are shown as covered (₹0 or reduced price)
- Remaining included service allowance is shown
- Discount is applied automatically to eligible items
Service Packages
A package is a pre-paid bundle of specific services, sold at a fixed price.
Examples
- "Keratin Care Pack" — 3 keratin treatments for ₹6,000 (vs ₹2,500 each = ₹7,500)
- "Bride Package" — trial + bridal hair + bridal makeup for ₹15,000
- "10-visit Massage Pass" — 10 × 60-min massages for ₹8,000
Package Tracking
- Each package purchase has a session balance (e.g. "8 of 10 used")
- Balance decrements when a package service is redeemed at checkout
- Expiry date (optional) — balance forfeited after expiry
- Balance visible on client profile and at checkout
Selling Packages to a Client (no appointment required)
Packages can be sold directly from the client profile without an open appointment:
- Open the client → Packages tab
- Tap Sell Package → select package definition
- Confirm payment method → package is created and linked to the client immediately
This enables upsells at the front desk between visits (e.g. selling a "10-session colour
pass" during a checkout conversation). The sale creates a client_packages row and a
linked payment record. No appointment is required.
Gift Cards
A gift card is a pre-loaded monetary value, redeemed by its code.
- A brand can define gift card templates (name, face value, optional sale price, validity in days), or an issuer can enter a custom value.
- Each card gets a generated unique code. When issuing, staff can record the purchasing client, a recipient name and notes.
- A card expires after its validity period (365 days when none is given).
- Partial use is supported: the remaining balance stays on the card. Redemption is refused for an expired card or when the amount is above the balance.
- Cards are looked up by code within the brand. Each card keeps a list of its redemptions.
Store Credit (Wallet)
Store credit is a client-specific monetary balance, kept as a ledger per brand (apply_store_credit), that can be spent at checkout.
- Staff add credit to a client with a note.
- A referral reward can be paid as store credit (see Referrals below).
Prepaid wallets (stored-value wallet cards, with an optional expiry date) are a separate feature; see the Prepaid Wallets page in the dashboard.
Referrals
Each brand has one referral programme (referral_programs), created inactive on first use so nothing pays out until an owner switches it on.
- Referrer gets a personal code and share link (
/r/<code>) from the client portal's Refer tab or from staff. Staff can also enter a referral by hand. - Friend opens the link, enters name and mobile number, and ticks a consent box. The referrer cannot refer themselves, and a person who has already paid the salon is not a new referral. The friend becomes a client record if they are not one already.
- Qualification depends on the programme's trigger:
signup(immediately),first_visit, orfirst_paid_visit. For visit triggers the event qualifies on the friend's first paid invoice if it meetsmin_visit_value_minor. Inservices_onlymode the pre-discount service subtotal decides, and a first bill below the minimum closes the referral with no reward. - Rewards (
auto_issue_rewardpays on qualification): the referrer can get store credit, loyalty points, a percentage discount code, or a flat-amount voucher; the friend can get store credit, a percentage or flat discount, or nothing. A flat friend voucher is issued as soon as the referral is created and is spent on the first bill. - Limits: optional maximum referrals per client, an expiry window (
expiry_days), and whether a voucher earned at one location can be redeemed at another.
Event statuses: pending, qualified, rewarded, expired, cancelled, reward_failed, closed. Referrals form a tree (a referred friend can refer others) and the tool rejects cycles. Staff manage events and log follow-up calls (booked, not interested, no answer, call later) on the Referrals page. A daily maintenance cron (/api/cron/referral-maintenance) expires stale pending referrals, nudges staff about referrals nobody has followed up, and warns before rewards expire.
Key Data Entities
- loyalty_rules — earn rules (per visit, per spend)
- loyalty_transactions — the points ledger (earn, redeem, adjust, expire); balance is the latest
balance_after - loyalty_configs — loyalty switch and expiry window (other fields not enforced, see above)
- reward_tiers — tier definition (
min_points, multiplier, discount, perks) - referral_programs / referral_events / referral_codes — the programme, each referral, and each client's code
- Membership — the membership plan definition
- MembershipSubscription — a client's active membership instance (billing, status, allowance)
- Package / PackagePurchase — a bundle definition and a client's purchased instance with remaining balance
- GiftCard — a card with a code, value, and remaining balance
- Referral — a referral record (referrer, referee, state, rewards)
- WalletEntry — a store credit transaction (credit or debit)
Permissions
- The retention pages (loyalty, referrals, memberships, packages, prepaid wallets) appear in the dashboard navigation for org owner, brand manager and location manager. Front desk and stylists do not see them there.
- These actions check a permission key that can be changed per role in Settings -> Roles & permissions. All default to the three manager roles (org owner, brand manager, location manager):
| Action | Permission key |
|---|---|
| Create or edit membership plans | memberships.plans |
| Create, edit or delete packages and combos | packages.manage |
| Issue gift cards, add store credit, issue or top up prepaid wallets | wallets.add_money |
| Redeem a gift card | billing.create |
- Selling a package needs a manager role or the
billing.createpermission. - Saving the loyalty settings and the referral programme settings checks brand access in the action; who can reach those pages is set by the navigation roles above.