Registering New Advocates via API

Learn how to register new advocates in your referral program using the Genius Referrals RESTful API. Registering new advocates on the Genius Referrals platform is straightforward and efficient. Below, we will guide you through the process effectively.

Prerequisites

  • Registration on the Platform: Sign up for Genius Referrals and obtain your API credentials.
  • Genius Referrals SDK: Ensure you have installed the Genius Referrals SDK for PHP.
Step 1: Authenticating Your Account
Before registering a new advocate, authenticate your account using your credentials (API token).
Step 2: Required Parameters
To register a new advocate, you need to provide the following information:

  • Account Slug: Identifier for the referral program, a string of up to 65 characters.
  • First Name: The advocate's first name should be a string with a maximum length of 128 characters.
  • Last Name: The advocate's last name should be a string with a maximum length of 128 characters.
  • Email Address: The advocate's email address must be a string with a maximum length of 128 characters.
  • Payout Threshold: An integer that indicates the minimum amount of bonuses the advocate must generate before they can redeem them.
  • Advocate Currency: A 3-digit code representing the unit of virtual or tangible rewards given to advocates, equivalent to the international currency code.
  • Can Refer: A boolean value (0 or 1) specifies whether the advocate can refer your services.
Step 3: Using Our SDKs
To register a new advocate, use the postAdvocate(...) method provided in our SDKs. This method is designed to facilitate integration and optimize the registration process.

Below is a practical example using the PHP SDK to guide you in the implementation:
Practical Example: Using the PHP SDK
<?php

require_once "../vendor/autoload.php";
$contentType = "application/json"; // The content type
$xAuthToken = "2f266b71bn8038e6"; // Your API Token, you can get your token here https://app.geniusreferrals.com/en/settings/api-access
$accountSlug = 'sandbox';

$client = new GeniusReferralsLib\GeniusReferralsClient($contentType, $xAuthToken);
$advocates = $client->getAdvocates();

// Preparing data needed to sent on the request
$advocate = new \GeniusReferralsLib\Models\Advocate();
$advocate->name = 'John';
$advocate->lastname = 'Doe';
$advocate->email = 'john.doe@example.com';
$advocate->payoutThreshold = 1;
$advocate->canRefer = 1;

// New advocate successfully created
$newAdvocate = $advocates->postAdvocate($accountSlug, new \GeniusReferralsLib\Models\AdvocateForm($advocate));

// Adding the currency to the advocate
$advocatePatchForm = new \GeniusReferralsLib\Models\AdvocatePatchForm();
$advocatePatchForm->currencyCode = 'USD';

// Advocate currency successfully added to the advocate
$updatedAdvocate = $advocates->patchAdvocate($accountSlug, $newAdvocate->token, $advocatePatchForm);
Please Note: Be sure to replace accountSlug and xAuthToken with the values provided for your account.
Step 4: Using Our RESTful API
In addition to our SDKs, you can efficiently register advocates using our RESTful API. This approach allows you to integrate advocate registration directly into your applications, offering flexibility and control over the process.

For more information on using our API, refer to the API documentation, which includes examples and detailed guides to help you implement this functionality effectively. When sending sensitive information, be sure to follow best security practices.
Please Note: If you cannot send personal information about your customers to our platform for security reasons, you may use placeholders for the first name, last name, and email address. Ensure you store these placeholders securely in your application.
Sample Applications
The sample applications showcase how to integrate with Genius Referrals using our SDKs and RESTful API. These applications connect functionality with code, simplifying the integration process and making it more accessible.

Explore our sample applications for practical insights and streamline the integration of your processes with Genius Referrals.
Was this page helpful?
LANGUAGE