Validate Referral Code
curl --request GET \
--url https://api.example.com/v1/referral/{code}/validate \
--header 'x-client-key: <x-client-key>'import requests
url = "https://api.example.com/v1/referral/{code}/validate"
headers = {"x-client-key": "<x-client-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-client-key': '<x-client-key>'}};
fetch('https://api.example.com/v1/referral/{code}/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/referral/{code}/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-client-key: <x-client-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/referral/{code}/validate"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-client-key", "<x-client-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/referral/{code}/validate")
.header("x-client-key", "<x-client-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/referral/{code}/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-client-key"] = '<x-client-key>'
response = http.request(request)
puts response.read_body{
"valid": true
}
{
"valid": false
}
Referral
Validate Referral Code
Validate a referral code entered by a user during registration
GET
/
v1
/
referral
/
{code}
/
validate
Validate Referral Code
curl --request GET \
--url https://api.example.com/v1/referral/{code}/validate \
--header 'x-client-key: <x-client-key>'import requests
url = "https://api.example.com/v1/referral/{code}/validate"
headers = {"x-client-key": "<x-client-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-client-key': '<x-client-key>'}};
fetch('https://api.example.com/v1/referral/{code}/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/referral/{code}/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-client-key: <x-client-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/referral/{code}/validate"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-client-key", "<x-client-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/referral/{code}/validate")
.header("x-client-key", "<x-client-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/referral/{code}/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-client-key"] = '<x-client-key>'
response = http.request(request)
puts response.read_body{
"valid": true
}
{
"valid": false
}
GET https://api.baanx.com/v1/referral/{code}/validate
Validates a referral code when a user enters it, checking whether it is valid or has expired.
Overview
Use this endpoint during the registration flow to verify a referral code before accepting it. Returns a boolean indicating whether the code is currently valid.This endpoint only requires the client key — no user Bearer token is needed, as it is intended for use during registration before a user account exists.
Authentication
This endpoint requires only a client key:x-client-key: YOUR_CLIENT_KEY
Request
Headers
string
required
Your public API client key
boolean
default:false
Set to
true to route requests to the US backend environmentPath Parameters
string
required
The referral code to validate (e.g.,
FHLSO5)Request Example
curl -X GET https://api.baanx.com/v1/referral/FHLSO5/validate \
-H "x-client-key: YOUR_CLIENT_KEY"
const code = 'FHLSO5';
const response = await fetch(`https://api.baanx.com/v1/referral/${code}/validate`, {
method: 'GET',
headers: {
'x-client-key': 'YOUR_CLIENT_KEY'
}
});
const data = await response.json();
console.log(data.valid); // true or false
import requests
code = "FHLSO5"
url = f"https://api.baanx.com/v1/referral/{code}/validate"
headers = {
"x-client-key": "YOUR_CLIENT_KEY"
}
response = requests.get(url, headers=headers)
print(response.json())
interface ValidateReferralResponse {
valid: boolean;
}
const validateReferralCode = async (code: string): Promise<ValidateReferralResponse> => {
const response = await fetch(`https://api.baanx.com/v1/referral/${code}/validate`, {
method: 'GET',
headers: {
'x-client-key': 'YOUR_CLIENT_KEY'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return await response.json();
};
Response
200 Success
boolean
true if the referral code is valid and can be used. false if the code is expired or has reached its usage cap.{
"valid": true
}
{
"valid": false
}
Error Responses
{
"message": "Invalid request"
}
{
"message": "Referral code is required"
}
{
"message": "Internal server error"
}
Related Endpoints
GET /v1/referral/- Get the authenticated user’s own referral code
Was this page helpful?