Referrals
Create Referral
Create a new referral linking a referrer to a referred customer with an optional reward.
POST
/
v1
/
referrals
Create a referral
curl --request POST \
--url https://billing.example.com/v1/referrals \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"referrer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referred_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reward_amount": 500,
"currency": "USD"
}
'import requests
url = "https://billing.example.com/v1/referrals"
payload = {
"referrer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referred_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reward_amount": 500,
"currency": "USD"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
referrer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
referred_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
reward_amount: 500,
currency: 'USD'
})
};
fetch('https://billing.example.com/v1/referrals', 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://billing.example.com/v1/referrals",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'referrer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'referred_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'reward_amount' => 500,
'currency' => 'USD'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/referrals"
payload := strings.NewReader("{\n \"referrer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"referred_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"reward_amount\": 500,\n \"currency\": \"USD\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/referrals")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"referrer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"referred_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"reward_amount\": 500,\n \"currency\": \"USD\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/referrals")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"referrer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"referred_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"reward_amount\": 500,\n \"currency\": \"USD\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referrer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referred_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"status": "pending",
"reward_amount": 123,
"currency": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"qualified_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
referrer_id | string (UUID) | Yes | The unique identifier of the customer making the referral. |
referred_id | string (UUID) | Yes | The unique identifier of the newly referred customer. |
reward_amount | integer | No | The reward amount in the smallest currency unit (e.g., cents). Defaults to 500 (i.e., $5.00 USD). |
currency | string | No | The three-letter ISO 4217 currency code. Defaults to USD. |
Example Request
curl -X POST https://api.recurso.dev/v1/referrals \
-H "Authorization: Bearer rsk_live_7f3a9b2c1d4e8f0a" \
-H "Content-Type: application/json" \
-d '{
"referrer_id": "d4e5f6a7-b8c9-4d0e-a1f2-b3c4d5e6f7a8",
"referred_id": "f7a8b9c0-d1e2-4f3a-b4c5-d6e7f8a9b0c1",
"reward_amount": 1000,
"currency": "USD"
}'
Response
{
"id": "ref_Kp8mN2xLvQ",
"referrer_id": "d4e5f6a7-b8c9-4d0e-a1f2-b3c4d5e6f7a8",
"referred_id": "f7a8b9c0-d1e2-4f3a-b4c5-d6e7f8a9b0c1",
"reward_amount": 1000,
"currency": "USD",
"status": "pending",
"reward_credited": false,
"created_at": "2026-06-23T17:00:00Z",
"updated_at": "2026-06-23T17:00:00Z",
"completed_at": null
}
Notes
- The referral is created with a
pendingstatus. It transitions tocompletedonce the referred customer completes their first payment. - The reward is credited to the referrer’s account balance only after the referral reaches
completedstatus. - A customer cannot refer themselves. Attempting to set
referrer_idequal toreferred_idreturns a422error. - Each referred customer can only be linked to one referrer. Duplicate referrals for the same
referred_idreturn a409 Conflict.
Use the Generate Referral Code endpoint to create shareable referral codes that automatically link referrals on sign-up.
Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Body
application/json
Response
Referral created.
Show child attributes
Show child attributes
⌘I
Create a referral
curl --request POST \
--url https://billing.example.com/v1/referrals \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"referrer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referred_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reward_amount": 500,
"currency": "USD"
}
'import requests
url = "https://billing.example.com/v1/referrals"
payload = {
"referrer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referred_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"reward_amount": 500,
"currency": "USD"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
referrer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
referred_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
reward_amount: 500,
currency: 'USD'
})
};
fetch('https://billing.example.com/v1/referrals', 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://billing.example.com/v1/referrals",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'referrer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'referred_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'reward_amount' => 500,
'currency' => 'USD'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/referrals"
payload := strings.NewReader("{\n \"referrer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"referred_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"reward_amount\": 500,\n \"currency\": \"USD\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/referrals")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"referrer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"referred_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"reward_amount\": 500,\n \"currency\": \"USD\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/referrals")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"referrer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"referred_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"reward_amount\": 500,\n \"currency\": \"USD\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referrer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"referred_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "<string>",
"status": "pending",
"reward_amount": 123,
"currency": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"qualified_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}