Skip to content

Authentication API

Endpoints for user authentication, registration, profile management, and security.

Prefix: /api/auth

Endpoints

Registration & Login

MethodPathDescriptionAuth Required
POST/registerCreate a new accountNo
POST/loginAuthenticate and get JWT tokenNo
POST/refreshRefresh an existing JWT tokenYes

Profile

MethodPathDescriptionAuth Required
GET/meGet current user profileYes
PUT/meUpdate profile informationYes
POST/me/avatarUpload profile avatarYes
DELETE/me/avatarDelete profile avatarYes

Two-Factor Authentication

MethodPathDescriptionAuth Required
POST/2fa/setupGenerate TOTP setup (QR code)Yes
POST/2fa/verifyVerify TOTP code and enable 2FAYes
POST/2fa/disableDisable 2FAYes

Sessions

MethodPathDescriptionAuth Required
GET/sessionsList active sessionsYes
DELETE/sessions/{id}Revoke a sessionYes

License

MethodPathDescriptionAuth Required
GET/licenseGet license statusYes
POST/license/activateActivate license keyYes
POST/license/deactivateDeactivate licenseYes

User Management (Admin)

MethodPathDescriptionRole
GET/usersList all usersAdmin
PUT/users/{id}/roleChange user roleAdmin
PUT/users/{id}/statusEnable/disable userAdmin
PUT/users/{id}/environmentsSet environment accessAdmin

Example: Login

http
POST /api/auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "your_password"
}

Response:

json
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "bearer",
  "user": {
    "id": 1,
    "email": "user@example.com",
    "username": "user",
    "role": "admin",
    "is_active": true
  }
}

UniSync Documentation