> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vantio.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with Vantio integration in under 5 minutes

## Overview

This guide will walk you through integrating Vantio into your platform. You'll learn how to:

* Set up API authentication
* Create your first program
* Generate QR codes for ambassadors
* Track referrals and earnings

## Step 1: Get Your API Key

Before you can use the Vantio API, you need to obtain your secret API key.

1. Log in to your [Vantio Dashboard](https://dash.vantio.app)
2. Navigate to **Settings** → **API Keys**
3. Click **Create New API Key**
4. Copy your secret key (it starts with `sk_`)

<Warning>
  Keep your API key secure! Never expose it in client-side code or commit it to version control. Store it as an environment variable.
</Warning>

## Step 2: Set Up Authentication

All Vantio API requests require authentication using a Bearer token. Include your API key in the `Authorization` header:

```bash theme={null}
Authorization: Bearer sk_your_secret_key_here
```

### Example: Making Your First Request

Test your API key by fetching your users:

```bash theme={null}
curl -X GET "https://vantio.app/api/v1/users" \
  -H "Authorization: Bearer sk_your_secret_key_here"
```

## Step 3: Create a Program

Programs are the foundation of your referral system. Each program can have multiple ambassadors and track referrals independently.

<AccordionGroup>
  <Accordion icon="rocket" title="Using the Dashboard">
    The easiest way to create a program is through the Vantio Dashboard:

    1. Go to **Programs** in your dashboard
    2. Click **Create New Program**
    3. Fill in program details (name, description, commission rates)
    4. Save your program
  </Accordion>

  <Accordion icon="code" title="Using the API">
    You can also create programs programmatically using the API (if program creation endpoints are available in your plan).
  </Accordion>
</AccordionGroup>

## Step 4: Add Student Ambassadors

Student ambassadors are the users who will place posters and generate referrals.

### Add Ambassadors via Dashboard

1. Navigate to **Users** in your dashboard
2. Click **Add User** or **Invite Ambassador**
3. Enter student information (name, email, program assignment)
4. The student will receive an invitation email

### Add Ambassadors via API

```javascript theme={null}
// Example: Adding a user (if user creation endpoint exists)
const response = await fetch('https://vantio.app/api/v1/users', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    first_name: 'John',
    last_name: 'Doe',
    email: 'john.doe@example.com',
    program_id: 'prog_123abc'
  })
});
```

## Step 5: Generate QR Code Posters

Each ambassador needs QR code posters to place around campus. Posters link scans to the ambassador who placed them.

### View Posters via API

```javascript theme={null}
// Fetch all posters for a program
const response = await fetch(
  'https://vantio.app/api/v1/posters?programId=prog_123abc',
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  }
);

const data = await response.json();
console.log('Posters:', data.posters);
```

Each poster has a `qr_code_url` that you can download or display to ambassadors.

## Step 6: Track the Referral Flow

The Vantio referral flow works like this:

1. **QR Code Scan** → Creates an `impression`
2. **User Signs Up** → Create a `referral` linked to the impression
3. **User Makes Purchase** → Create an `earning` linked to the referral

### Example: Creating a Referral

When a user signs up after scanning a QR code:

```javascript theme={null}
async function createReferral(impressionId, signupData) {
  const response = await fetch('https://vantio.app/api/v1/referrals', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      impression_id: impressionId, // From the QR scan
      first_name: signupData.firstName,
      last_name: signupData.lastName,
      email: signupData.email
    })
  });
  
  return await response.json();
}
```

### Example: Creating an Earning

When a referred customer makes a purchase:

```javascript theme={null}
async function createEarning(referralId, orderTotal) {
  const commissionRate = 0.10; // 10% commission
  const amountInCents = Math.round(orderTotal * commissionRate * 100);
  
  const response = await fetch('https://vantio.app/api/v1/earnings', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      referral_id: referralId,
      amount: amountInCents, // Amount in cents
      currency: 'USD',
      type: 'purchase',
      description: `Commission from purchase`,
      idempotency_key: `earn_${Date.now()}` // Prevent duplicates
    })
  });
  
  return await response.json();
}
```

## Step 7: Monitor Performance

Track your referral program's performance using the API:

```javascript theme={null}
// Get all referrals
const referrals = await fetch(
  'https://vantio.app/api/v1/referrals?programId=prog_123abc',
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  }
);

// Get all earnings
const earnings = await fetch(
  'https://vantio.app/api/v1/earnings?programId=prog_123abc&status=paid',
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  }
);
```

## Next Steps

<CardGroup>
  <Card title="API Authentication Guide" icon="key" href="/essentials/markdown">
    Learn more about authentication and making API requests
  </Card>

  <Card title="Code Examples" icon="square-code" href="/essentials/code">
    Explore more code examples and integration patterns
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Browse the complete API documentation
  </Card>
</CardGroup>

## Need Help?

If you run into any issues:

* Check the [API Reference](/api-reference/introduction) for detailed endpoint documentation
* Review [Code Examples](/essentials/code) for common integration patterns
* Contact support through your dashboard
