Public Methods

React Native API Integration

1. Add a Subscriber

POST https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers

Request Body

When using this method please take note of your Campaign Goal as our tracking logic will depend on if you are tracking a single or multi-step conversion event.

GOAL: One Conversion Event If you have your Campaign Goal set up to track one conversion event, the following tracking logic will take place:

  • If a referral, a referral will be automatically created and set to Confirmed in the correct campaign.

  • If not a referral, an organic subscriber will be created in the campaign UUID specified.

  • If the subscriber exists in our database, the subscriber will be 'identified'. Data is not overwritten. Additional data will be created.

GOAL: Two or Three Conversion Events If you have your Campaign Goal set up to track two or three conversion events, the following tracking logic will take place:

  • If a referral, a referral will be created and set to Pending in the correct campaign.

  • If not a referral, an organic subscriber will be created in the campaign UUID specified.

  • If the subscriber exists in our database, the subscriber will be 'identified'. Data is not overwritten.

To add a subscriber (for example, post a successful signup or login) call the function and send the params information such as email address and name. The minimum values you should send for the endpoint to work are the following:

final subscriber = { 
    "email": "johnDoe123@gmail.com", 
    "domain": "https://a.domain.co/", 
}

To identify and create a referral, you must also send either the setReferrer OR the required mobile params so that our matching algorithm can automatically identify a referral.

"os_type": "Android",
"device": "Android",
"ip_address": "123.156.219.010",
"screen_size": "432.0 x 960.0",

NOTE: The mobile parameters must be sent in the correct format for our system to automatically identify and create a referral. See the Getting Started section here.

The accepted Screen Size formats are:

"screen_size":"393*852"
"screen_size":"393 x 852"
"screen_size":"393x852"
"screen_size":"393.0 x 852.0"
// in case you need to hard code values
var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");


var raw = JSON.stringify({
 "email": "test24@gmail.com",
 "name": "Test User 24",
 "phone_number": "9898989896",
 "extra_field": "some extra data",
 "extra_field_2": "some more extra data",
 "referrer": "",
 "conversion_value": 0,
 "conversion_category": "",
 "transaction_id": "",
 "os_type": "Android",
 "device": "Android",
 "ip_address": "127.0.0.1",
 "screen_size": "1920.0 x 1080.0",
 "hosting_url": "https://app.referralhero.com/dashboard/lists/MF83c9616aa3/analytics/traffic",
 "crypto_wallet_address": "",
 "crypto_wallet_provider": "",
 "points": 22,
 "double_optin": false,
 "other_identifier_value": "",
 "option_field_value": "",
 "is_quick_add_referral": true,
 "landing_page_url": "",
 "subscribe_page_url": "",
 "lifetime_spend": ""
});

var requestOptions = {
 method: 'POST',
 headers: myHeaders,
 body: raw,
 redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/MF4345c63888/subscribers", requestOptions)
 .then(response => response.json())
 .then(result => console.log(result))
 .catch(error => console.log('error', error));

2. Add Pending Referral

POST https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/pending_referral

This method is most commonly used to create a referral entering the 1st step of your multi-step conversion event funnel (i.e. after a referred user successfully signs up for your app). If you want us to automatically add every user to your campaign and determine if the user is a referral or not, use the Add Subscriber method instead. This logic only checks for referrals:

Tracking Logic

GOAL: Two or Three Conversion Events

Your campaign Goal must be set up to track two or three conversion events, and then the following tracking logic will take place:

  • If a referral, a referral will be automatically created and set to Pending in the correct campaign.

  • If not a referral, no subscriber will be created.

Request Body

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Authorization", "xxxxxxxxxxxxxxxxxx");

var raw = JSON.stringify({
  "name": "Pending Referral",
  "os_type": "IOS",
  "ip_address": "123.456.789.0123",
  "screen_size": "64*32",
  "device": "IOS",
  "email": "testpending1@email.com",
  "Phone_nubmer": "",
  "Cryoto_wallet_address": "",
  "referrer": "8f01d5db",
  "hosting_url": "https://app.referralhero.com"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/pending_referral", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

To add a pending referral, simply call ReferralHero's createPendingReferral function and send the referralParams data.

The minimum values for this endpoint to work:

final referralParams = {
  "email": signup_email,
  "referrer": "M12345fc2",
};

OR:

final referralParams = {
  'email': signup_email,
  'device': getDeviceType(), // Get device type
  'ip_address': await getIpAddress(), // Get IP address
  'os_type': getOperatingSystem(), // Get operating system type
  'screen_size': transformResolution(getDeviceScreenSize()) // Get screen size
};

NOTE: The mobile parameters must be sent in the correct format for our system to automatically identify and create a referral. See the Getting Started section here.

3. Track Referral

POST https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/track_referral_conversion_event

This method is used for tracking a referral conversion event (i.e. a purchase, but can be any conversion event).

Tracking Logic:

  • If a referral and pre-existing in the campaign as Pending

OR

  • If a referral and setReferrer or mobile params are provided, a referral is automatically created in the correct campaign and

The Referral Is Set To:

  • Confirmed (if tracking two conversion events)

  • Unconfirmed (if tracking three conversion events)

Note:

1. Your campaign must be set up as a custom event or a multi-step event otherwise, an error will return.

2. If the referral is present in ReferralHero with pending status, a successful response custom_event_completed will return.

3. If the referral unique identifier is not present in the ReferralHero, but the referrer unique identifier is present, a successful response custom_event_completed with the data of the new confirmed referral will return.

4. If a referral exists but the referral status is not pending, the error custom event is already completed will return.

5. If the referral unique identifier is not present in ReferralHero and the referrer is also not provided in the API, the error referer is invalid or not present will return.

6. If the referral status is unconfirmed or confirmed, the error custom event is already completed will return.

When tracking referrals on your App you should ALWAYS send the ACTUAL unique identifier (email, phone number, crypto wallet address, or other ID) of the user in referralParams class Object.

Request Body

  • uniqueIdentifier is a placeholder.

  • When tracking referrals on your App you should ALWAYS send the ACTUAL unique identifier (email, phone number, crypto wallet address, or other ID) of the user in referralParams class Object

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "xxxxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");

var raw = JSON.stringify({
  "email": "test17@gmail.com",
  "name": "Test name updated",
  "phone_number": "3289408393",
  "Crypto_wallet_address": ""
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/track_referral_conversion_event", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

4. Confirm Referral

POST https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id/confirm

Use this method when your Campaign Goal is set to track three conversion events and you want to confirm a referral when your third conversion event occurs (complete profile, upgrade to a paid plan, end of the trial, etc).

Tracking Logic:

  • If a referral and pre-existing in the campaign as Unconfirmed

The Referral Is Set To:

  • Confirmed (if tracking three conversion events)

Note: only verified referrals can be confirmed. Trying to confirm a non-verified referral will return a subscriber_not_found error.

Request Body

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Authorization", "xxxxxxxxxxxxx");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id/confirm", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

5. Organic Track Referral

POST https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/organic_track_referral

If you would like to add an organic subscriber or a track referral on the conversion page to your referral campaign, you can use the following method. This method would most commonly be used if the user has not been previously added to your campaign and instead directly passes through a post-checkout/subscribe event.

Tracking Logic:

  • If a referral and pre-existing in the campaign as Pending

OR

  • If a referral and setReferrer or mobile params are provided, a referral is automatically created in the correct campaign and

The Referral Is Set To:

  • Confirmed (if tracking two conversion events)

  • Unconfirmed (if tracking three conversion events)

OR

  • If not a referral, an organic subscriber is created in the campaign UUID specified.

Request Body

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Authorization", "xxxxxxxxxxxx");

var raw = JSON.stringify({
  "email": "testorganic1@gmail.com",
  "name": "Test organic User1",
  "hosting_url": "https://app.referralhero.com/dashboard/lists/:uuid/analytics/traffic",
  "referrer": "2c2dbefb"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/organic_track_referral", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

The Unique Identifier is the only required body parameter, otherwise, all other available subscriber attributes can be found above under 'Add a Subscriber'.

If the referral is NOT pre-existing in the campaign (and you want to identify and create a referral), you must send either the setReferrer OR the required mobile parameters in the correct format so that our matching algorithm can automatically identify a referral. See the Getting Started section here.

6. Update Subscriber Details

PATCH https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id

This method is used to update various user-related data like username, address, etc. Request parameters are the same as before in the Add a Subscriber API.

Required body parameters are noted below, otherwise, all other available subscriber attributes can be found above under 'Add a Subscriber'.

Request Body

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
 "email": "test102@gmail.com",
 "name": "Test name new",
 "os_type": "Ubuntu"
});

var requestOptions = {
 method: 'PATCH',
 headers: myHeaders,
 body: raw,
 redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id", requestOptions)
 .then(response => response.json())
 .then(result => console.log(result))
 .catch(error => console.log('error', error));

7. Get Subscriber Details

GET https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id

This method is used to get the details of a particular subscriber.

Path Parameters

var myHeaders = new Headers();
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "xxxxxxxxxxxxx");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/subscriber_id", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

8. Delete Subscriber

DELETE https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id

This method is used to Delete a Subscriber.

Path Parameters

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

9. Capture Share

POST https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id/click_capture

This method is used with parameters like 'copy', 'sms', 'facebook', 'twitter', etc. to capture a Share Event.

Request Body

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "social": "facebook"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id/click_capture", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

10. Get My Referrals

GET https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber-id/referrals_data

This method is used for retrieving all referrals of the specific subscriber.

Path Parameters

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id/referrals_data", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

11. Get Leaderboard

GET https://dev.referralhero.com/api/sdk/v1/lists/:uuid/leaderboard

This method is used for retrieving the campaign leaderboard.

Path Parameters

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
  method: 'GET',
  headers: myHeaders
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/MFb1f0135c55/leaderboard", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

12. Get Referrer

GET https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/referrer

This method is used to retrieve the referrer of a user. By calling this method, you would know if someone was a referral or not, and then could:

  • Apply a discount code automatically to the checkout process

  • Personalize text shown on a page

Path Parameters

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxxx");
myHeaders.append("Accept", "application/vnd.referralhero.v1");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "os_type": "ios",
  "devise": "device",
  "ip_address": "192.168.0.1",
  "screen_size": "1200x1800"
});


var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/referrer", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

NOTE:

The mobile parameters must be sent in the correct format for our system to automatically identify a referral. See the Getting Started section here.

13. Get Rewards

GET https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/:subscriber_id/rewards

Use this method to Get Rewards unlocked by a specific subscriber.

Path Parameters

var myHeaders = new Headers();
myHeaders.append("Authorization", "xxxxxxxxxxxxxxxx");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/vnd.referralhero.v1");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://dev.referralhero.com/api/sdk/v1/lists/:uuid/subscribers/sub_bfdc2b6e2f7e/rewards", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Last updated