Skip to main content
POST
/
api
/
auth
/
login
Login
curl --request POST \
  --url https://api.example.com/api/auth/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "username": "<string>",
  "password": "<string>"
}
'
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "userId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "username": "johndoe",
  "email": "[email protected]",
  "role": "RESIDENT",
  "roles": ["RESIDENT"],
  "roleDetails": [
    {
      "id": "7a9b8c3d-1234-5678-90ab-cdef12345678",
      "code": "RESIDENT",
      "description": "Community Resident"
    }
  ],
  "expiresAt": "2026-03-05T15:30:00Z",
  "residentInfo": {
    "id": "9c8b7a6d-5432-1098-76ab-fedcba987654",
    "fullname": "John Doe",
    "email": "[email protected]",
    "phone": "+1234567890",
    "number": "A-101",
    "address": "123 Main Street, Apt 101",
    "comunidades": ["1a2b3c4d-5678-90ab-cdef-1234567890ab"],
    "comunidad": {
      "id": "1a2b3c4d-5678-90ab-cdef-1234567890ab",
      "nombre": "Sunset Community",
      "direccion": "123 Main Street",
      "email": "[email protected]",
      "phone": "+1234567890",
      "tipoComunidad": "Residential",
      "cantidadViviendas": 150
    },
    "comunidadesCompletas": [
      {
        "id": "1a2b3c4d-5678-90ab-cdef-1234567890ab",
        "nombre": "Sunset Community",
        "direccion": "123 Main Street",
        "email": "[email protected]",
        "phone": "+1234567890",
        "tipoComunidad": "Residential",
        "cantidadViviendas": 150
      }
    ]
  }
}

Request Body

username
string
required
User’s username (3-15 characters)
password
string
required
User’s password

Response

token
string
JWT authentication token
userId
string
User’s unique identifier (GUID)
username
string
User’s username
email
string
User’s email address
role
string
User’s primary role (for backward compatibility)
roles
array
List of role codes assigned to the user
roleDetails
array
Detailed information about each role
expiresAt
string
Token expiration date/time in ISO 8601 format
residentInfo
object
Additional information if user has a resident profile

Example Request

curl -X POST https://api.happyhabitat.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "password": "SecurePass123"
  }'

Example Response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "userId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "username": "johndoe",
  "email": "[email protected]",
  "role": "RESIDENT",
  "roles": ["RESIDENT"],
  "roleDetails": [
    {
      "id": "7a9b8c3d-1234-5678-90ab-cdef12345678",
      "code": "RESIDENT",
      "description": "Community Resident"
    }
  ],
  "expiresAt": "2026-03-05T15:30:00Z",
  "residentInfo": {
    "id": "9c8b7a6d-5432-1098-76ab-fedcba987654",
    "fullname": "John Doe",
    "email": "[email protected]",
    "phone": "+1234567890",
    "number": "A-101",
    "address": "123 Main Street, Apt 101",
    "comunidades": ["1a2b3c4d-5678-90ab-cdef-1234567890ab"],
    "comunidad": {
      "id": "1a2b3c4d-5678-90ab-cdef-1234567890ab",
      "nombre": "Sunset Community",
      "direccion": "123 Main Street",
      "email": "[email protected]",
      "phone": "+1234567890",
      "tipoComunidad": "Residential",
      "cantidadViviendas": 150
    },
    "comunidadesCompletas": [
      {
        "id": "1a2b3c4d-5678-90ab-cdef-1234567890ab",
        "nombre": "Sunset Community",
        "direccion": "123 Main Street",
        "email": "[email protected]",
        "phone": "+1234567890",
        "tipoComunidad": "Residential",
        "cantidadViviendas": 150
      }
    ]
  }
}

Error Codes

Status CodeCodeDescription
400VALIDATION_ERRORMissing or invalid request parameters
401UNAUTHORIZEDInvalid username or password
500INTERNAL_ERRORInternal server error

Build docs developers (and LLMs) love