📘 Task Management REST API Documentation

🔹 Overview

This REST API allows management of users and tasks with role-based permissions. Admins can view all tasks they created, while users see only their own tasks.


1️⃣ Add User

POST /adduser.php

ParameterTypeDescription
namestringFull name of the user
usernamestringUnique username (no spaces allowed)
passwordstringPassword (will be stored securely)
emailstringEmail address
roleenum('admin','user')User role type
created_bystringUsername of the creator

🧾 Example JSON Body (Postman → Raw → JSON)

{
  "name": "John Doe",
  "username": "johnd",
  "password": "123456",
  "email": "john@example.com",
  "role": "user",
  "created_by": "admin"
}

2️⃣ Authenticate User

POST /authuser.php

ParameterTypeDescription
usernamestringUser login name
passwordstringUser password

🧾 Example JSON Body

{
  "username": "johnd",
  "password": "123456"
}

3️⃣ Get Users by Creator

GET /getuser.php/{created_by}/userlist

Returns a list of all users created by the specified creator.

🧩 Example:

GET https://test.myfuntopia.com/restapi/getuser.php/admin/userlist

4️⃣ Add Task

POST /addtask.php

ParameterTypeDescription
user_idintID of the user assigned to the task
titlestringTask title
statusstringTask status
created_bystringUsername of the creator

🧾 Example JSON Body

{
  "user_id": 2,
  "title": "Complete project documentation",
  "status":"Pending"
  "created_by": "admin"
}

5️⃣ Get Tasks (Role-Based)

GET /gettask.php/{created_by}/{user_id}/tasklist

🔹 Role Behavior:
If the user role is admin → show all tasks created by {created_by}.
If the user role is user → show only tasks assigned to {user_id}.

🧩 Example:

GET https://test.myfuntopia.com/restapi/gettask.php/admin/3/tasklist

🧾 Example Response:

{
  "status": true,
  "data": [
    { "task_id": 1, "title": "Fix API Bug", "status": "Pending", "assigned_to": "John Doe" }
  ]
}

6️⃣ Update Task

PUT /updatetask.php/{task_id}/update

ParameterTypeDescription
statusenum('Pending','Approved','Rejected','Done')Updated task status

🧾 Example JSON Body

{
  "status": "Approved"
}

🧩 Example URL:

PUT https://test.myfuntopia.com/restapi/updatetask.php/5/update

7️⃣ Update User

PUT /updateuser.php/{user_id}/updateuser

ParameterTypeDescription
namestringUpdated user name
emailstringUpdated email address
roleenum('admin','user')User role

Note: Username cannot be changed.

🧾 Example JSON Body

{
  "name": "John Doe Updated",
  "email": "john.new@example.com",
  "role": "user"
}

🧩 Example URL:

PUT https://test.myfuntopia.com/restapi/updateuser.php/2/updateuser

🧪 Example Postman Collection

PurposeMethodURL Example
LoginPOSThttps://test.myfuntopia.com/restapi/authuser.php
Add UserPOSThttps://test.myfuntopia.com/restapi/adduser.php
List UsersGEThttps://test.myfuntopia.com/restapi/getuser.php/admin/userlist
Add TaskPOSThttps://test.myfuntopia.com/restapi/addtask.php
Get Tasks (Admin/User)GEThttps://test.myfuntopia.com/restapi/gettask.php/admin/3/tasklist
Update TaskPUThttps://test.myfuntopia.com/restapi/updatetask.php/5/update
Update UserPUThttps://test.myfuntopia.com/restapi/updateuser.php/3/updateuser