Skip to main content
POST
/
api
/
auth
/
register
Register
curl --request POST \
  --url https://api.example.com/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "roleId": "<string>",
  "firstName": "<string>",
  "lastName": "<string>",
  "username": "<string>",
  "email": "<string>",
  "password": "<string>"
}
'
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "8d7c6b5a-4321-0987-65ba-fedcba098765",
    "roleId": "7a9b8c3d-1234-5678-90ab-cdef12345678",
    "roleCode": "RESIDENT",
    "roles": [
      {
        "id": "7a9b8c3d-1234-5678-90ab-cdef12345678",
        "code": "RESIDENT",
        "description": "Community Resident"
      }
    ],
    "roleIds": ["7a9b8c3d-1234-5678-90ab-cdef12345678"],
    "roleCodes": ["RESIDENT"],
    "firstName": "Jane",
    "lastName": "Smith",
    "username": "janesmith",
    "email": "[email protected]",
    "isActive": true,
    "createdAt": "2026-03-04T10:30:00Z",
    "residentInfo": null,
    "userCommunityIds": []
  },
  "expiresAt": "2026-03-11T10:30:00Z"
}

Request Body

roleId
string
required
Role identifier (GUID) to assign to the new user
firstName
string
required
User’s first name
lastName
string
required
User’s last name
username
string
required
Unique username (3-15 characters)
email
string
required
Valid email address
password
string
required
Password (6-20 characters)

Response

token
string
JWT authentication token for the newly created user
user
object
Created user information
expiresAt
string
Token expiration date/time (ISO 8601 format)

Example Request

curl -X POST https://api.happyhabitat.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "roleId": "7a9b8c3d-1234-5678-90ab-cdef12345678",
    "firstName": "Jane",
    "lastName": "Smith",
    "username": "janesmith",
    "email": "[email protected]",
    "password": "SecurePass456"
  }'

Example Response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "8d7c6b5a-4321-0987-65ba-fedcba098765",
    "roleId": "7a9b8c3d-1234-5678-90ab-cdef12345678",
    "roleCode": "RESIDENT",
    "roles": [
      {
        "id": "7a9b8c3d-1234-5678-90ab-cdef12345678",
        "code": "RESIDENT",
        "description": "Community Resident"
      }
    ],
    "roleIds": ["7a9b8c3d-1234-5678-90ab-cdef12345678"],
    "roleCodes": ["RESIDENT"],
    "firstName": "Jane",
    "lastName": "Smith",
    "username": "janesmith",
    "email": "[email protected]",
    "isActive": true,
    "createdAt": "2026-03-04T10:30:00Z",
    "residentInfo": null,
    "userCommunityIds": []
  },
  "expiresAt": "2026-03-11T10:30:00Z"
}

Validation Rules

  • Username: 3-15 characters, must be unique
  • Email: Valid email format, must be unique
  • Password: 6-20 characters
  • RoleId: Must be a valid GUID of an existing role
  • FirstName and LastName: Required fields

Error Codes

Status CodeCodeDescription
400VALIDATION_ERRORInvalid or missing request parameters
400INVALID_OPERATIONUsername or email already exists
500INTERNAL_ERRORInternal server error

Build docs developers (and LLMs) love