> ## Documentation Index
> Fetch the complete documentation index at: https://doc-dev.weir.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Admin Login

> Admin user login with username and password

# Admin Login

Authenticate admin users with username and password to access admin APIs.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.weir.ai/auth/login' \
    -H 'Content-Type: application/json' \
    -d '{
      "username": "admin@weir.ai",
      "password": "SecureAdminPass123!"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "data": {
      "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "refreshToken": "admin_refresh_123456789",
      "expiresIn": 3600,
      "user": {
        "id": "admin_123456789",
        "fullname": "Admin User",
        "email": "admin@weir.ai",
        "role": "Super_Admin"
      }
    },
    "message": "Login successful",
    "status": "success"
  }
  ```
</ResponseExample>

## Request Body

<ParamField body="username" type="string" required>
  Admin username or email.
</ParamField>

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

## Usage Examples

<CodeGroup>
  ```javascript JavaScript theme={null}
  const adminLogin = async (username, password) => {
    const response = await fetch('https://api.weir.ai/auth/login', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ username, password })
    });
    if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
    return await response.json();
  };
  ```

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

  def admin_login(username, password):
      response = requests.post(
          'https://api.weir.ai/auth/login',
          json={'username': username, 'password': password}
      )
      response.raise_for_status()
      return response.json()
  ```
</CodeGroup>

<Note>
  Admin login uses the same endpoint as regular user login but with admin credentials.
</Note>
