Skip to main content

Create User Referral Code API

Overview

Generate and save a new referral code for a user. This API creates a unique referral code that users can share with others to earn rewards when they sign up or make transactions. The system automatically generates a unique referral code based on the user ID and timestamp.

API Details

Endpoint

POST https://api.gafapay.com:8443/gafapay/v3/reward_promotion/user_referral_code

Headers

authorization: Token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmYjhmMDkyMTBlMGY0NmI3YjQyNjJkNzdmNWI2YzI3MyIsInJvbGVzIjpbIlJPTEVfQ1VTVE9NRVIiXSwiZXhwIjoxNzYwMTU2MjgzfQ.iHC4alnoYacGsKM0GNPKBvlv9NFEzGU8xLhZ1Ysbx-g
requestid: 5bb30135-1815-41d5-827f-baed3daba4ae
companyid: 59388167894b4d10a04fe5da3b8a2104
Content-Type: application/json

Request Body

Required Parameters

  • company_id (String): Company identifier (passed in header)

Request Body Fields

  • user_id (String): Unique identifier of the user
    • Example: "fb8f09210e0f46b7b4262d77f5b6c273"
    • Description: The user for whom the referral code is being generated
  • user_type (Integer): Type of user
    • 2 = Customer
    • 3 = Merchant
    • 5 = Agent
    • Example: 2
  • referral_program_id (String, Optional): Referral program identifier
    • Example: "3a62eae282ea4e04bbe27e2dddbb1e5c"
    • Description: Links the referral code to a specific referral program

Request Body Example

{
"user_id": "fb8f09210e0f46b7b4262d77f5b6c273",
"user_type": 2,
"referral_program_id": "3a62eae282ea4e04bbe27e2dddbb1e5c"
}

Response

Success Response

{
"success": 1,
"error": [],
"data": {
"message": "REWARD_PROMOTION_SAVE_USER_REFERRAL_CODE_SUCCESSFULLY",
"referral_code_id": "C273551489XA"
}
}

Response Fields

  • success (integer): Response status indicator
    • 1 = Success
    • 0 = Failure
  • error (array): Array of error messages (empty on success)
  • data (object): Response data object
    • message (string): Success message indicating referral code creation
    • referral_code_id (string): The generated referral code that can be shared

Error Responses

Bad Request

{
"success": 0,
"error": ["BAD_REQUEST"],
"data": {}
}

User Already Has Referral Code

{
"success": 0,
"error": ["REWARD_PROMOTION_USER_REFERRAL_CODE_ALREADY_EXISTS"],
"data": {}
}

Example Usage

Request with Referral Program

curl --location 'https://api.gafapay.com:8443/gafapay/v3/reward_promotion/user_referral_code' \
--header 'authorization: Token YOUR_TOKEN_HERE' \
--header 'requestid: YOUR_REQUEST_ID' \
--header 'companyid: YOUR_COMPANY_ID' \
--header 'Content-Type: application/json' \
--data '{
"user_id": "fb8f09210e0f46b7b4262d77f5b6c273",
"user_type": 2,
"referral_program_id": "3a62eae282ea4e04bbe27e2dddbb1e5c"
}'

Merchant User Request

curl --location 'https://api.gafapay.com:8443/gafapay/v3/reward_promotion/user_referral_code' \
--header 'authorization: Token YOUR_TOKEN_HERE' \
--header 'requestid: YOUR_REQUEST_ID' \
--header 'companyid: YOUR_COMPANY_ID' \
--header 'Content-Type: application/json' \
--data '{
"user_id": "merchant_user_id_here",
"user_type": 3
}'

Response Messages

  • REWARD_PROMOTION_SAVE_USER_REFERRAL_CODE_SUCCESSFULLY: Successful creation
  • BAD_REQUEST: Invalid request parameters
  • REWARD_PROMOTION_USER_REFERRAL_CODE_ALREADY_EXISTS: User already has code

Notes

  • Immediate Availability: Generated codes can be used immediately after creation
  • Company Scoped: All referral codes are scoped to the company_id in headers
  • Case Insensitive Usage: Generated codes are uppercase but usage is case-insensitive
  • Multi-Company Support: Different companies can have overlapping user IDs but unique referral codes