Referral API

FonProxy referral endpoints: get referral info, update codes, view referral graph and earnings.

Updated 2026-04-09 16:13:00
Referral API

For authentication and common headers, see API General.

Overview

Get Referral Info Auth required

GET /referral

Returns the user's referral code, percentages, and stats. Auto-creates a referral code on first access.

Response

{
  "id": "xK9mR2pL1w",
  "code": "a3f8c2d1",
  "incomePercentage": 5,
  "salePercentage": 0,
  "clicks": 142,
  "registrations": 23,
  "totalIncome": 12.50,
  "pendingIncome": 3.75
}
NameTypeDescription
idstringReferral ID
codestringEditable referral code (used in referral link)
incomePercentagenumberPercentage the referrer earns from each referred top-up
salePercentagenumberDiscount percentage for referred users (future)
clicksnumberTotal visitors who came via this referral
registrationsnumberTotal users who registered via this referral
totalIncomenumberTotal completed referral income (USD)
pendingIncomenumberPending referral income not yet credited (USD)

Code

Update Referral Code Auth required

PATCH /referral/code

Update the referral code. Must be 3–30 characters, alphanumeric + underscore + hyphen.

Request Body

NameTypeDescriptionRequired
codestringNew referral codeYes

Response

{ "code": "john_doe", "message": "referral.code_updated" }

Errors:

{ "message": "referral.code_invalid" }
{ "message": "referral.code_taken" }

Analytics

Referral Graph Auth required

GET /referral/graph

Returns time-series chart data for clicks, registrations, and income.

Query Parameters

NameTypeDescriptionRequired
fromstringISO date start. Default 30 days agoNo
tostringISO date end. Default nowNo
granularitystringhour, day, week, month. Default autoNo

Response

{
  "graph": "referral",
  "granularity": "day",
  "from": "2026-02-23T00:00:00.000Z",
  "to": "2026-03-25T00:00:00.000Z",
  "series": [
    {
      "key": "clicks",
      "label": "Clicks",
      "color": "#3B82F6",
      "points": [
        { "t": "2026-03-24T00:00:00.000Z", "v": 15 },
        ...
      ]
    },
    {
      "key": "registrations",
      "label": "Registrations",
      "color": "#22C55E",
      "points": [
        { "t": "2026-03-24T00:00:00.000Z", "v": 3 },
        ...
      ]
    },
    {
      "key": "income",
      "label": "Income (USD)",
      "color": "#E6318B",
      "points": [
        { "t": "2026-03-24T00:00:00.000Z", "v": 2.50 },
        ...
      ]
    }
  ],
  "meta": { "currency": "USD" }
}

How Referrals Work

  1. User gets a unique referral code from GET /referral
  2. Frontend builds a link: https://fonproxy.com/?ref=<code>
  3. Visitor arrives β†’ logs in database.
  4. Visitor registers β†’ invitedById is set on the new user + referrer is notified
  5. Referred user tops up β†’ a pending referral income transaction is created for the referrer
  6. After 2 days (instant in dev mode) the pending transaction is credited to the referrer's balance + referrer is notified
  7. User can track everything in GET /referral and GET /referral/graph
Referral API β€” FonProxy Referral Program, Codes & Stats