# API Documentation - Ninja Sage Login Users

## Base URL
`/admin/api/login-users`

## Endpoints

### 1. List Login Users
- **Method**: `GET`
- **URL**: `/`
- **Query Params**:
  - `page` (int): Page number (default: 1)
  - `per_page` (int): Items per page (default: 25)
  - `q` (string): Search query (username)
  - `active` (string): Filter by active status ('1' or '0')
  - `sort` (string): Sort field (e.g. `username:asc`, `created_at:desc`)
- **Response**: JSON with `data` (array), `meta` (pagination), `rev` (revision for SSE).

### 2. Create Login User
- **Method**: `POST`
- **URL**: `/`
- **Body**:
  - `username` (required, string, max:128)
  - `password_hash` (required, string, max:2048) - The raw password hash or string
  - `auth_token` (optional, string, max:64)
  - `auth_signature` (optional, string, max:512)
  - `auth_device_id` (optional, string, max:128)
  - `note` (optional, string, max:255)
  - `sort_order` (optional, int)
  - `is_active` (optional, boolean)
- **Response**: JSON with created object.

### 3. Show Login User
- **Method**: `GET`
- **URL**: `/{id}`
- **Response**: JSON with object.

### 4. Update Login User
- **Method**: `PUT`
- **URL**: `/{id}`
- **Body**: Same as Create, but fields are optional. `password_hash` is optional.
- **Response**: JSON with updated object.

### 5. Delete Login User
- **Method**: `DELETE`
- **URL**: `/{id}`
- **Response**: 204 No Content.

### 6. Realtime Stream (SSE)
- **Method**: `GET`
- **URL**: `/stream`
- **Query Params**:
  - `since` (int): Last known revision number.
- **Response**: `text/event-stream` with `rev` events.

### 7. Import Sample
- **Method**: `GET`
- **URL**: `/import-sample`
- **Description**: Parses `d:\NEW\kingjoki\New Folder\LoginUser` and returns parsed data for preview.

---

## NestJS Module
The functionality is also mirrored in the NestJS backend under the `login-users` module.
- **Base URL**: `/login-users`
- **Endpoints**: Standard CRUD (`GET /`, `GET /:id`, `POST /`, `PUT /:id`, `DELETE /:id`).
- **Validation**: Uses DTOs with `class-validator`.
