Back to Home
Reflio Docs

Welcome to Reflio Docs

Complete guide to integrating Reflio into your SaaS. Set up referral programs, track conversions, and reward your users—all in under 10 minutes.

1. Quick Start

Step 1: Create Account

Sign up at reflio.app/signup and create your first project.

Step 2: Get Your API Keys

Go to Dashboard → Integration to find:

  • Public Key (pk_...) - For widget and frontend
  • Secret Key (sk_...) - For backend API calls

Step 3: Create a Campaign

In Dashboard → Campaigns, click "Create New Campaign" and configure:

  • Who gets rewarded: Both, Referrer only, or Referred only
  • Reward types: Cash, Credit, or Discount
  • Trigger event: Signup, First Payment, or Subscription

Step 4: Connect Stripe (Optional)

Go to Dashboard → Integration → Connect Stripe to enable automatic reward payouts.

2. Widget Integration

The Reflio widget shows users their referral code and stats. Add it to your user dashboard:

<script 
  src="https://www.reflio.app/widget.js" 
  data-api-key="pk_YOUR_PUBLIC_KEY"
  data-user-id="{{user.id}}"
  data-user-email="{{user.email}}"
  data-user-name="{{user.name}}"
  data-theme="dark">
</script>

Parameters:

  • data-api-key: Your public API key (pk_...)
  • data-user-id: Unique identifier for this user
  • data-user-email: User's email address
  • data-user-name: (Optional) User's display name
  • data-theme: "dark" or "light"

3. Checkout Integration

Step 1: Add Referral Code Field

Add an optional referral code input to your checkout/signup form:

<label for="referral-code">Have a referral code?</label>
<input 
  type="text" 
  id="referral-code" 
  placeholder="Enter code"
/>

Step 2: Validate Code (Frontend)

const validateCode = async (code, email) => {
  const res = await fetch('https://www.reflio.app/api/referrals/validate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      api_secret: 'YOUR_SECRET_KEY', // Call from backend!
      referral_code: code,
      referred_email: email
    })
  });
  
  const data = await res.json();
  return data.valid; // true/false
};

Step 3: Track Referral (Backend)

After successful payment, call this from your backend:

const trackReferral = async () => {
  await fetch('https://www.reflio.app/api/referrals/track', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      api_secret: process.env.REFLIO_SECRET_KEY,
      referral_code: 'ABC12345',
      referred_email: 'newuser@example.com',
      referred_external_user_id: 'user_123',
      stripe_customer_id: 'cus_xxx', // Optional
      stripe_payment_intent_id: 'pi_xxx', // Optional
      purchase_amount: 99.99,
      currency: 'USD'
    })
  });
};

4. API Reference

GET /api/widget/code

Get or create a referral code for a user.

Query Parameters:

  • api_key - Your public key (required)
  • user_id - User identifier (required)
  • email - User email (required)
  • name - User name (optional)

POST /api/referrals/validate

Check if a referral code is valid.

Request Body:

  • api_secret - Your secret key (required)
  • referral_code - Code to validate (required)
  • referred_email - New user's email (required)

POST /api/referrals/track

Record a new referral.

Request Body:

  • api_secret - Your secret key (required)
  • referral_code - Valid code (required)
  • referred_email - New user's email (required)
  • referred_external_user_id - Your user ID (optional)
  • stripe_customer_id - Stripe customer (optional)
  • stripe_payment_intent_id - Payment intent (optional)
  • purchase_amount - Purchase value (optional)
  • currency - Currency code (default: USD)

5. Stripe Webhooks

Reflio automatically qualifies referrals when Stripe payments succeed.

Events We Listen For:

  • checkout.session.completed
  • payment_intent.succeeded
  • invoice.payment_succeeded
  • customer.subscription.created
  • charge.refunded (marks as cancelled)

Setup Instructions:

  1. Go to Stripe Dashboard → Developers → Webhooks
  2. Add endpoint: https://www.reflio.app/api/webhooks/stripe
  3. Select the events listed above
  4. Copy the signing secret (whsec_...)
  5. Add to your environment variables: STRIPE_WEBHOOK_SECRET

6. Fraud Protection

Built-in fraud prevention:

  • Duplicate Detection: Prevents same user from being referred twice
  • Self-Referral Block: Users can't refer themselves
  • Campaign Limits: Set max referrals per user, total budget, expiry dates
  • Manual Review: Flag suspicious referrals in dashboard

7. Support

Need help? We're here for you:

Ready to get started?

Join early adopters and get 50% off for life. No commission fees, ever.