> ## Documentation Index
> Fetch the complete documentation index at: https://docs.learnway.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Referrals

> Generate referral links, track invited referees, and calculate earned referral commissions.

# Referrals

LearnWay rewards users with bonus XP and Gems for inviting friends to learn on the platform.

***

## Generate / Get Referral Code

### Endpoint

```http theme={null}
POST /api/v2/referral/code
```

### Headers

```http theme={null}
Authorization: Bearer <jwt_access_token>
```

### Response (201 Created)

```json theme={null}
{
  "referralCode": "CRYPTOSAGE2026"
}
```

***

## Get Referral Statistics

Retrieves total invited users, completed onboarding milestones, and accumulated referral rewards.

### Endpoint

```http theme={null}
GET /api/v2/referral/stats
```

### Headers

```http theme={null}
Authorization: Bearer <jwt_access_token>
```

### Response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "referralCode": "CRYPTOSAGE2026",
    "totalInvited": 12,
    "activeLearners": 8,
    "totalGemsEarned": 400,
    "totalXPEarned": 2500,
    "referrals": [
      {
        "username": "bob_web3",
        "joinedAt": "2026-08-15T09:00:00.000Z",
        "hasCompletedFirstCourse": true,
        "bonusClaimed": true
      }
    ]
  }
}
```
