4.5 KiB
4.5 KiB
User API
Create New User
Endpoint
POST: http://localhost:3070/api/user
Request Body
{
"firstName": "Jhon",
"lastName": "Doe",
"email": "kalanajayasekara@niolla.lk",
"role": "System Developer",
"accountType": "admin",
"department": "IT Department"
}
Respond
{
"success": true,
"message": "User Created Successfully",
"data": {
"id": "usr_763107d9-b56f-4b81-9d86-1889f98a6e6c",
"firstName": "Jhon",
"lastName": "Doe",
"email": "kalanajayasekara@niolla.lk",
"accountType": "admin",
"role": "System Developer",
"department": "IT Department"
}
}
Get All Users
Endpoint
GET: http://localhost:3070/api/user
Respond
{
"success": true,
"data": [
{
"id": "usr_b00045f7-aafb-482a-8587-d28beb5195ec",
"firstName": "Kalana",
"lastName": "Jayasekara",
"email": "kalanamanupiya32@gmail.com",
"accountType": "admin",
"role": "Manager",
"department": "Operations",
"createdAt": "2026-02-14T19:14:25.000Z",
"updatedAt": "2026-02-14T19:14:25.000Z"
},
{
"id": "usr_763107d9-b56f-4b81-9d86-1889f98a6e6c",
"firstName": "Kalana",
"lastName": "Manupiya",
"email": "kalanajayasekara@niolla.lk",
"accountType": "admin",
"role": "System Developer",
"department": "IT Department",
"createdAt": "2026-02-12T19:32:15.000Z",
"updatedAt": "2026-02-12T19:32:15.000Z"
},
{
"id": "usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4",
"firstName": "Jhon",
"lastName": "Doe",
"email": "sathira@niolla.lk",
"accountType": "admin",
"role": "System Developer",
"department": "IT Department",
"createdAt": "2026-02-12T19:24:04.000Z",
"updatedAt": "2026-02-12T19:24:04.000Z"
}
],
"pagination": {
"totalUsers": 3,
"totalPages": 1,
"currentPage": 1,
"pageSize": 20
}
}
This API uses Pagination:
GET /user?page=1
GET /user?page=2
GET /user?page=3
Get User by ID
Endpoint
GET: http://localhost:3070/api/user/:id
Ex: http://localhost:3070/api/user/usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4
Response
{
"success": true,
"data": {
"id": "usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4",
"firstName": "Sathira",
"lastName": "Sri Sathsara",
"email": "sathira@niolla.lk",
"accountType": "admin",
"role": "System Developer",
"department": "IT Department",
"createdAt": "2026-02-12T19:24:04.000Z",
"updatedAt": "2026-02-14T21:33:19.751Z",
"profile": {
"profile_id": "prof_a1b2c3d4-e5f6-7890-1234-567890abcdef",
"user_id": "usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4",
"theme": "light",
"notificationsEnabled": true,
"profilePicture_id": "up_xyz789",
"backgroundImage_id": "up_abc123",
"dob": "1995-03-15T00:00:00.000Z",
"phone_number": "+1 234-567-8900",
"createdAt": "2026-02-12T19:24:04.000Z",
"updatedAt": "2026-02-12T19:24:04.000Z"
}
}
}
Update User
Endpoint
PATCH: http://localhost:3070/api/user/:id
Ex: http://localhost:3070/api/user/usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4
Request Body
Can send single field or multiple fields. The following fields can be updated:
{
"firstName": "Sathira",
"lastName": "Sri Sathsara",
"email": "sathira@niolla.lk",
"role": "System Developer",
"roleID": "role_123",
"accountType": "admin",
"department": "IT Department",
"theme": "dark",
"notificationsEnabled": false,
"profilePicture_id": "up_profile_123",
"backgroundImage_id": "up_background_456",
"dob": "1995-03-15",
"phone_number": "+1 234-567-8900"
}
Response
{
"success": true,
"message": "User updated successfully",
"data": {
"id": "usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4",
"firstName": "Sathira",
"lastName": "Sri Sathsara",
"email": "sathira@niolla.lk",
"accountType": "admin",
"role": "System Developer",
"department": "IT Department",
"profile": {
"theme": "dark",
"notificationsEnabled": false,
"profilePicture_id": "up_profile_123",
"backgroundImage_id": "up_background_456",
"dob": "1995-03-15T00:00:00.000Z",
"phone_number": "+1 234-567-8900"
}
}
}
Delete User
Endpoint
DELETE: http://localhost:3070/api/user/:id
Ex: http://localhost:3070/api/user/usr_b00045f7-aafb-482a-8587-d28beb5195ec
Respond
{
"success": true,
"message": "User deleted successfully"
}