Create Referral Program - kangaroorewards/api-docs GitHub Wiki

Create Referral Program

In this tutorial, you will learn how to create a referral program through the Kangaroo Rewards API.

Objective: To demonstrate the process of creating a referral program via the Kangaroo Rewards API.

Note: It's important to note that modifying the email template is restricted to updates made solely from the Kangaroo business portal.

Prerequisites:

Step-by-Step Instructions

Step 1: Set up your environment with issuing an access token

First, ensure you have your API access key and X-Application-Key from Kangaroo Rewards. This key is necessary for authenticating your API requests.

export ACCESS_KEY="YOUR_ACCESS_KEY_HERE"
export APPLICATION_KEY="YOUR_APPLICATION_KEY_HERE"

For instructions on issuing an access token, please refer to this tutorial link.

Step 2: Create a referral program

To create a referral program, make a POST request to the appropriate endpoint, including the necessary information.

Note: When creating a new referral program, the previous active referral program will be deactivated, and the new one will be enabled.

curl -X POST "https://api.kangaroorewards.com/referral-programs" \
-H "Authorization: Bearer <ACCESS_KEY>" \
-H "X-Application-Key: <APPLICATION_KEY>" \
-H "Accept: application/vnd.kangaroorewards.api.v1+json;" \
-H "Content-Type: application/json" \
-d '{
  "cond_min_amount": 30.00,
  "referee_earns": 50,
  "referer_earns": 10,
  "expires_in": 35,
  "enabled": true,
  "link_referral_enabled": true,
}'
  • cond_min_amount: Required - The minimum purchase amount condition.
  • expires_in: Required - Expires in number of days.
  • referee_earns: Required - How many points the referee earns.
  • referer_earns: Required - How many points the referer earns.
  • link_referral_enabled: Optional - It indicates whether the referral link is enabled, it's true be default.
  • enabled: Optional - It indicates whether the referral program is enabled, it's true be default.

Step 3: Handle the response appropriately in your code.

Response sample:

{
  "data": {
    "id": 1370,
    "rule_name": "BACKEND_REFERRAL_RULES_PURCHASE",
    "cond_min_amount": 30,
    "referee_earns": 50,
    "referer_earns": 10,
    "expires_in": 35,
    "enabled": true,
    "link_referral_enabled": true,
    "referral_link": ""
  }
}

Summary

In this tutorial, we demonstrated how to create a referral program using the Kangaroo Rewards API. We provided a step-by-step guide, including how to set up referral details. Additionally, we highlighted that modifying the email template must be done exclusively through the Kangaroo business portal. By following these instructions, users can efficiently manage their referral programs.

Best Practices

  • Always store your client secret and access token securely and never expose them in your source code.
  • Handle API responses appropriately, including error handling to manage failed requests.
  • Limit the number of API requests to avoid exceeding your quota.

Additional Resources

Troubleshooting

  • Ensure your Access Token is correct, isn't expired and has the necessary permissions.
  • Check the API endpoint URLs for any typos.
  • Double check all the required headers are present including Content-Type and Accept.
  • Review the error messages returned by the API for clues on what went wrong.
⚠️ **GitHub.com Fallback** ⚠️