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

# MOGL API Quickstart: Make Your First Authenticated Call

> Go from zero to your first authenticated MOGL API response in minutes — register an account, get a JWT token, and fetch your profile with a real API call.

This guide walks you through the three steps needed to make your first authenticated request to the MOGL Core API: create an account, obtain a JWT token, and call a protected endpoint. By the end you will have a working token and a real API response in your terminal.

<Note>
  All examples use the MOGL production base URL: `https://api.mogl.online/api`.
</Note>

## Prerequisites

* An HTTP client — curl works for all examples below, but any HTTP library will work.
* Your intended account type: **athlete**, **agent**, or **partner (brand)**.

***

<Steps>
  <Step title="Register your account">
    Choose the registration endpoint that matches your role and create an account.

    <CodeGroup>
      ```bash Athlete theme={"dark"}
      curl -X POST https://api.mogl.online/api/athlete/register \
        -F "email=you@example.com" \
        -F "password=SecurePass1!"
      ```

      ```bash Agent theme={"dark"}
      curl -X POST https://api.mogl.online/api/agent/register-new \
        -H "Content-Type: application/json" \
        -d '{
          "email": "you@example.com",
          "password": "SecurePass1!"
        }'
      ```

      ```bash Partner (brand) theme={"dark"}
      curl -X POST https://api.mogl.online/api/partner/register \
        -H "Content-Type: application/json" \
        -d '{
          "email": "you@example.com",
          "password": "SecurePass1!"
        }'
      ```
    </CodeGroup>

    A `200` response confirms that the account was created. If you receive `409 Conflict`, an account with that email already exists — proceed to step 2 and log in.

    <Warning>
      Registration endpoints are rate-limited. Do not retry in a tight loop — wait a moment before re-attempting if you receive a `429` response.
    </Warning>
  </Step>

  <Step title="Log in and get your token">
    Call `POST /api/login` with your email and password to receive a JWT Bearer token.

    <CodeGroup>
      ```bash curl theme={"dark"}
      curl -X POST https://api.mogl.online/api/login \
        -H "Content-Type: application/json" \
        -d '{
          "email": "you@example.com",
          "password": "SecurePass1!"
        }'
      ```

      ```javascript JavaScript theme={"dark"}
      const resp = await fetch('https://api.mogl.online/api/login', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          email: 'you@example.com',
          password: 'SecurePass1!',
        }),
      });

      const { access_token } = await resp.json();
      console.log(access_token);
      ```

      ```python Python theme={"dark"}
      import requests

      resp = requests.post(
          'https://api.mogl.online/api/login',
          json={'email': 'you@example.com', 'password': 'SecurePass1!'},
      )
      access_token = resp.json()['access_token']
      print(access_token)
      ```
    </CodeGroup>

    The response body looks like this:

    ```json theme={"dark"}
    {
      "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
      "token_type": "Bearer",
      "user": { ... }
    }
    ```

    Copy the value of `access_token`. You will pass it in the `Authorization` header of every subsequent request.

    <Tip>
      Save the token to an environment variable so you can reuse it across requests without re-typing it:

      ```bash theme={"dark"}
      export MOGL_TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
      ```
    </Tip>
  </Step>

  <Step title="Make your first authenticated API call">
    Use your token to call a protected endpoint. The example below fetches your agent profile from `GET /api/agent/me`. If you registered as an athlete or partner, use `POST /api/me` instead (shown in the second tab).

    <CodeGroup>
      ```bash Agent profile (GET /agent/me) theme={"dark"}
      curl https://api.mogl.online/api/agent/me \
        -H "Authorization: Bearer $MOGL_TOKEN"
      ```

      ```bash Current user (POST /me) theme={"dark"}
      curl -X POST https://api.mogl.online/api/me \
        -H "Authorization: Bearer $MOGL_TOKEN" \
        -H "Content-Type: application/json"
      ```

      ```javascript JavaScript (agent profile) theme={"dark"}
      const resp = await fetch('https://api.mogl.online/api/agent/me', {
        headers: {
          Authorization: `Bearer ${access_token}`,
        },
      });

      const profile = await resp.json();
      console.log(profile);
      ```

      ```python Python (agent profile) theme={"dark"}
      import requests

      resp = requests.get(
          'https://api.mogl.online/api/agent/me',
          headers={'Authorization': f'Bearer {access_token}'},
      )
      print(resp.json())
      ```
    </CodeGroup>

    A `200` response returns your profile data. If you receive a `401`, your token may be missing or expired — return to step 2 to get a fresh token.
  </Step>
</Steps>

***

## What's next

You are now authenticated and ready to explore the full API surface.

* **[Authentication](/authentication)** — Understand token expiry, how to log out, and how to handle `401` and `403` errors in production.
* **[API Reference](/api-reference/core-api)** — Complete reference for all Core API endpoints, including deals, payments, messaging, and more.
