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

# Getting Started

> Make your first API call in minutes

# Getting Started

This guide will walk you through making your first API call to the MLM Platform.

## Prerequisites

* An MLM Platform account
* Access to the Admin Dashboard
* A development environment with HTTP client capabilities

## Step 1: Get Your API Key

1. Log in to the [Admin Dashboard](https://app.mlm-platform.com)
2. Navigate to **Settings** > **API Keys**
3. Click **Create API Key**
4. Select **SANDBOX** environment for testing
5. Copy your API key and store it securely

<Warning>
  Never expose your API key in client-side code or public repositories.
</Warning>

## Step 2: Make Your First Request

Let's verify your API key by creating a test user.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://app.mlm-platform.com/api/v1/users \
    -H "Content-Type: application/json" \
    -H "x-tenant-api-key: your_api_key_here" \
    -d '{
      "email": "test@example.com",
      "membership_tier": "ORDINARY"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.mlm-platform.com/api/v1/users', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-tenant-api-key': 'your_api_key_here'
    },
    body: JSON.stringify({
      email: 'test@example.com',
      membership_tier: 'ORDINARY'
    })
  });

  const user = await response.json();
  console.log('Created user:', user);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://app.mlm-platform.com/api/v1/users',
      headers={
          'Content-Type': 'application/json',
          'x-tenant-api-key': 'your_api_key_here'
      },
      json={
          'email': 'test@example.com',
          'membership_tier': 'ORDINARY'
      }
  )

  user = response.json()
  print('Created user:', user)
  ```

  ```typescript TypeScript SDK theme={null}
  import { MLMPlatformClient } from '@mlm-platform/sdk';

  const client = new MLMPlatformClient({
    apiKey: 'your_api_key_here'
  });

  const user = await client.createUser({
    email: 'test@example.com',
    membershipTier: 'ORDINARY'
  });

  console.log('Created user:', user);
  ```
</CodeGroup>

## Step 3: Verify the Response

A successful response will look like this:

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "tenant_id": "123e4567-e89b-12d3-a456-426614174000",
  "email": "test@example.com",
  "membership_tier": "ORDINARY",
  "is_active": true,
  "can_recruit": true,
  "created_at": "2024-01-15T10:30:00Z"
}
```

Check the response `X-Environment` header to confirm which environment the platform selected (derived from your API key):

```
X-Environment: SANDBOX
```

## Step 4: Record a Purchase

Now let's record a purchase to trigger commission calculation:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://app.mlm-platform.com/api/v1/events/purchase \
    -H "Content-Type: application/json" \
    -H "x-tenant-api-key: your_api_key_here" \
    -d '{
      "user_id": "550e8400-e29b-41d4-a716-446655440000",
      "amount": 99.99,
      "currency": "USD"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.mlm-platform.com/api/v1/events/purchase', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-tenant-api-key': 'your_api_key_here'
    },
    body: JSON.stringify({
      user_id: '550e8400-e29b-41d4-a716-446655440000',
      amount: 99.99,
      currency: 'USD'
    })
  });

  const result = await response.json();
  console.log('Commissions created:', result.commissions_created);
  ```
</CodeGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/guides/authentication">
    Learn about API key security best practices
  </Card>

  <Card title="Webhooks" icon="webhook" href="/guides/webhooks">
    Set up webhooks for real-time events
  </Card>

  <Card title="Widget Embedding" icon="window" href="/guides/widget-embedding">
    Embed referral widgets in your app
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore all available endpoints
  </Card>
</CardGroup>
