0% found this document useful (0 votes)
10 views2 pages

Referral

The Referral System API allows authenticated users to manage referral codes and redemptions through various endpoints. Users can create, list, and validate referral codes, as well as redeem them and access referral statistics. Access levels differ for regular and staff users, with certain functionalities restricted to authenticated users only.

Uploaded by

manish.ekbana42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Referral

The Referral System API allows authenticated users to manage referral codes and redemptions through various endpoints. Users can create, list, and validate referral codes, as well as redeem them and access referral statistics. Access levels differ for regular and staff users, with certain functionalities restricted to authenticated users only.

Uploaded by

manish.ekbana42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Referral System API Documentation

Authentication

All endpoints require authentication using JWT tokens.

Endpoints

1. Referral Codes Management

List Referral Codes

Endpoint: GET /referral/codes/


Description : Retrieves all referral codes for the authenticated user
Response : List of referral codes with their details
Access:
Regular users: Can only see their own codes
Staff users: Can see all codes

Create Referral Code

Endpoint: POST /referral/codes/


Description : Creates a new referral code for the authenticated user
Request Body : Referral code details
Response : Created referral code details
Access: Authenticated users only (will change it to the admin only soon)

Validate Referral Code

Endpoint: POST /referral/codes/validate_code/


Description : Validates if a referral code is valid and returns its benefits
Request Body :

{
"code": "string" // The referral code to validate
}

Response :

{
"valid": true,
"discount_amount": "amount",
"bonus_amount": "amount"
}

Error Response :

{
"valid": false,
"reason": "error message"
}

2. Referral Redeem Management

List Referral Redeems

Endpoint: GET /referral/redeem/


Description : Retrieves all referral redemptions where the user is either the referrer or referred user
Response : List of referral redemptions
Access:
Regular users: Can only see their own referrals (as referrer or referred)
Staff users: Can see all referrals

Create Referral Redeem

Endpoint: POST /referral/redeem/


Description : Creates a new referral redemption using a valid referral code
Request Body : Referral redemption details
Response : Created referral redemption details
Validation Rules:
User cannot use their own referral code
User cannot be referred more than once
Access: Authenticated users only

Get Referral Statistics

Endpoint: GET /referral/redeem/stats/


Description : Retrieves referral statistics for the authenticated user
Response : Statistics including:
Total referrals made
Total bonus earned
Total discount given
Other relevant metrics
Access: Authenticated users only

Notes
1. All monetary values (discount_amount, bonus_amount) are handled as big int values (poisa) like 100 will be 1 rupees
2. The system automatically tracks usage count of referral codes
3. The referral code will be auto generated for users while user is being created. (referral code might be missing for the old users)

You might also like