Skip to navigation

Validate Referral Code

View as Markdown

A public endpoint to check whether a referral code is valid prior to registration or sign-in. Searches across both users and drivers databases, and returns the referrer type (USER or DRIVER) with a privacy-masked referrer name.


Endpoint Overview

  • Method: POST

  • Route: /api/v1/referral/validate

  • Authentication: None (Public)

  • Content-Type: application/json


Request Headers

HeaderTypeRequiredDescription
Content-TypestringYesMust be application/json

Request Body Schema

FieldData TypeRequiredDefaultAllowed Values / ConstraintsDescription
referral_codestringYes—Min length 1 (e.g. "CAP_8X9K2", "USR_1A2B3")Referral code to validate

Example Request Body

{
"referral_code": "CAP_8X9K2"
}

Response Body Schema (200 OK)

FieldData TypeOptionalAllowed Values / ConstraintsDescription
validbooleanNotrue, falseWhether the referral code is active and exists
referrer_typeenumYes"USER", "DRIVER"Platform role of code owner (omitted if invalid)
referrer_namestringYesMasked string or nullMasked name for privacy (e.g. "Ravi K**\*")

Response Examples

1. 200 OK — Valid Driver Referral Code

{
"valid": true,
"referrer_type": "DRIVER",
"referrer_name": "Ravi K***"
}

2. 200 OK — Valid User Referral Code

{
"valid": true,
"referrer_type": "USER",
"referrer_name": "Ananya S***"
}

3. 200 OK — Invalid / Non-Existent Referral Code

{
"valid": false
}

4. 400 Bad Request — Validation Error (Missing referral_code)

{
"success": false,
"message": "Validation failed: referral_code: Referral code is required",
"errors": [
{
"field": "referral_code",
"message": "Referral code is required"
}
]
}

5. 500 Internal Server Error

{
"error": "Failed to validate referral code"
}

Status Codes Reference

HTTP Status CodeCondition
200 OKCode validated successfully (returns valid: true or valid: false).
400 Bad RequestMissing or empty referral_code in request body.
500 Internal Server ErrorServer or database lookup error.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.