> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Shashank-H/gaiter-gaurd/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> User authentication endpoints for registration, login, token refresh, and profile management

## Register user

<api>POST /auth/register</api>

Create a new user account with email and password.

### Request body

<ParamField body="email" type="string" required>
  User email address. Must be a valid email format.
</ParamField>

<ParamField body="password" type="string" required>
  User password. Must be at least 8 characters long.
</ParamField>

### Response

<ResponseField name="message" type="string">
  Success message confirming user registration.
</ResponseField>

<ResponseField name="user" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="number">
      Unique user identifier.
    </ResponseField>

    <ResponseField name="email" type="string">
      Registered email address.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of account creation.
    </ResponseField>
  </Expandable>
</ResponseField>

### Status codes

* `201` - User successfully registered
* `400` - Invalid email format or password requirements not met
* `409` - User with this email already exists
* `500` - Registration failed due to server error

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.gaiterguard.com/auth/register \
    --header 'Content-Type: application/json' \
    --data '{
      "email": "user@example.com",
      "password": "securePassword123"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.gaiterguard.com/auth/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email: 'user@example.com',
      password: 'securePassword123'
    })
  });
  const data = await response.json();
  ```

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

  response = requests.post(
      'https://api.gaiterguard.com/auth/register',
      json={
          'email': 'user@example.com',
          'password': 'securePassword123'
      }
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "message": "User registered",
    "user": {
      "id": 1,
      "email": "user@example.com",
      "createdAt": "2026-03-03T22:49:00.000Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Email and password are required"
  }
  ```

  ```json 409 theme={null}
  {
    "error": "User with this email already exists"
  }
  ```
</ResponseExample>

***

## Login user

<api>POST /auth/login</api>

Authenticate a user and receive access and refresh tokens.

### Request body

<ParamField body="email" type="string" required>
  User email address.
</ParamField>

<ParamField body="password" type="string" required>
  User password.
</ParamField>

### Response

<ResponseField name="accessToken" type="string">
  JWT access token for authenticating API requests. Valid for a limited time.
</ResponseField>

<ResponseField name="refreshToken" type="string">
  JWT refresh token for obtaining new access tokens.
</ResponseField>

<ResponseField name="user" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="number">
      Unique user identifier.
    </ResponseField>

    <ResponseField name="email" type="string">
      User email address.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of account creation.
    </ResponseField>
  </Expandable>
</ResponseField>

### Status codes

* `200` - Login successful
* `400` - Email and password are required
* `401` - Invalid credentials
* `500` - Login failed due to server error

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.gaiterguard.com/auth/login \
    --header 'Content-Type: application/json' \
    --data '{
      "email": "user@example.com",
      "password": "securePassword123"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.gaiterguard.com/auth/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email: 'user@example.com',
      password: 'securePassword123'
    })
  });
  const data = await response.json();
  ```

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

  response = requests.post(
      'https://api.gaiterguard.com/auth/login',
      json={
          'email': 'user@example.com',
          'password': 'securePassword123'
      }
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "user": {
      "id": 1,
      "email": "user@example.com",
      "createdAt": "2026-03-03T22:49:00.000Z"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Invalid credentials"
  }
  ```
</ResponseExample>

***

## Refresh access token

<api>POST /auth/refresh</api>

Obtain a new access token using a valid refresh token.

### Request body

<ParamField body="refreshToken" type="string" required>
  Valid refresh token obtained from login.
</ParamField>

### Response

<ResponseField name="accessToken" type="string">
  New JWT access token for authenticating API requests.
</ResponseField>

<ResponseField name="refreshToken" type="string">
  New JWT refresh token (rotated for security).
</ResponseField>

### Status codes

* `200` - Token refresh successful
* `400` - Refresh token is required
* `401` - Invalid refresh token
* `500` - Token refresh failed due to server error

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.gaiterguard.com/auth/refresh \
    --header 'Content-Type: application/json' \
    --data '{
      "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.gaiterguard.com/auth/refresh', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
    })
  });
  const data = await response.json();
  ```

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

  response = requests.post(
      'https://api.gaiterguard.com/auth/refresh',
      json={
          'refreshToken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
      }
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Invalid refresh token"
  }
  ```
</ResponseExample>

***

## Get current user

<api>GET /auth/me</api>

Retrieve the authenticated user's profile information.

<Info>This endpoint requires authentication.</Info>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication. Format: `Bearer <jwt>`
</ParamField>

### Response

<ResponseField name="user" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="number">
      Unique user identifier.
    </ResponseField>

    <ResponseField name="email" type="string">
      User email address.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of account creation.
    </ResponseField>
  </Expandable>
</ResponseField>

### Status codes

* `200` - User profile retrieved successfully
* `401` - Unauthorized (missing or invalid token)
* `404` - User not found
* `500` - Failed to get user info

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.gaiterguard.com/auth/me \
    --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.gaiterguard.com/auth/me', {
    headers: {
      'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
    }
  });
  const data = await response.json();
  ```

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

  response = requests.get(
      'https://api.gaiterguard.com/auth/me',
      headers={
          'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
      }
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "user": {
      "id": 1,
      "email": "user@example.com",
      "createdAt": "2026-03-03T22:49:00.000Z"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Missing or invalid authorization header"
  }
  ```

  ```json 404 theme={null}
  {
    "error": "User not found"
  }
  ```
</ResponseExample>
