SWENS API Documentation

📋 Table of Contents

👤 User Service
User Registration
POST http://localhost:8080/users
Request Body:
{ "name": "Test1", "email": "test1@gmail.com", "password": "test2@123", "role": "user" }
Responses:
201 Created
{ "id": "2211578c-15e5-410a-9aac-1fc2827d1db0", "email": "temp4@gmail.com", "password": "$2a$10$TWNO.OH7pPlcbBGjyzTMkupgDGalAbzocokT9JaZRI/XLKgEX99gi", "role": "user" }
400 Bad Request
{ "message": "Email address already exists" }
🔐 Authentication Service
User Login
POST http://localhost:8080/auth/login
Request Body:
{ "email": "test1@gmail.com", "password": "test1@123" }
Responses:
200 Success 401 Unauthorized
{ "name": "Test1", "accessToken": "accessToken", "refreshToken": "refreshToken" }
Token Validation
GET http://localhost:8080/auth/validate
Authentication Required: Include accessToken in Headers
Responses:
200 Success 401 Unauthorized
{ "role": "admin", "message": "Token is valid", "email": "email" }
Refresh Token Generation
POST http://localhost:8080/auth/refresh
Request Body:
{ "refreshToken": "token" }
Responses:
200 Success 401 Unauthorized
{ "name": "email", "accessToken": "accessToken", "refreshToken": "refreshToken" }
Note: Minor naming convention issue - name field contains email value
📋 Task Service
Authentication Required: Pass accessToken as Bearer token in all requests
Response Codes: 200 OK, 201 Created, 401 Unauthorized, 403 Forbidden (for user access), 404 Not Found

🛡️ Admin Specific Endpoints

Get All Users by Role
GET http://localhost:8080/task/admin/role?role=user
Purpose: Retrieves all users from database to store in Redis for task assignment
Query Parameters:
role=user (passed as query parameter, not in body)
Response:
[ { "id": "2211578c-15e5-410a-9aac-1fc2827d1db0", "name": "Test4", "email": "temp4@gmail.com", "role": "user" }, { "id": "c01af79e-6f71-4598-8142-c9c4adc44419", "name": "Test4", "email": "temp4", "role": "user" } ]
Create New Task
POST http://localhost:8080/task/admin
Request Body:
{ "description": "Project Final Test", "status": "Start", "taskName": "Email Testing", "dueDate": "2025-06-15T14:30:00Z", "assignedUsers": [ { "userId": "64462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "email2" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "email3" } ], "workflowId": "workflow-39bb8c39-d2ab-44aa-a205-8e25bf161c84" }
Response:
{ "taskId": "683d4aca7dda4e6e8e85e529", "description": "Project Final Test", "status": "Start", "dueDate": "2025-06-15 20:00:00", "assignedUsers": [ { "userId": "64462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "email" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "email" } ], "createdAt": "2025-06-02 12:25:06", "updatedAt": "2025-06-02 12:25:06", "workflowId": "workflow-065da3e5-3de5-4448-83f7-436b1881f314", "unavailableUsers": [], "taskName": "Email Testing", "adminEmail": "email" }
Update Task (Admin)
PUT http://localhost:8080/task/admin/{taskId}
Request Body:
{ "status": "Completed", "description": "Added second user too", "dueDate": "2025-06-29T14:30:00Z", "assignedUsers": [ { "userId": "464462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "email2" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "email3" } ] }
Response:
{ "taskId": "683cc495566d8425c0b18b4f", "description": "Added second user too", "status": "Completed", "dueDate": "2025-06-29 20:00:00", "assignedUsers": [ { "userId": "464462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "email" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "email" } ], "createdAt": "2025-06-02 02:52:29", "updatedAt": "2025-06-02 12:32:40", "workflowId": "workflow-39bb8c39-d2ab-44aa-a205-8e25bf161c84", "unavailableUsers": null, "taskName": "Email Testing", "adminEmail": "rinky.zafar@gmail.com" }
Get Assigned Users
GET http://localhost:8080/task/admin/assigned
Response:
[ { "id": "2211578c-15e5-410a-9aac-1fc2827d1db0", "name": "Test4", "email": "temp4@gmail.com", "role": "user" } ]
Get Free Users
GET http://localhost:8080/task/admin/free
Response:
[ { "id": "2211578c-15e5-410a-9aac-1fc2827d1db0", "name": "Test4", "email": "temp4@gmail.com", "role": "user" } ]
Get Single Task
GET http://localhost:8080/task/admin/{taskId}
Response:
{ "taskId": "683d4aca7dda4e6e8e85e529", "description": "Project Final Test", "status": "Start", "dueDate": "2025-06-15 20:00:00", "assignedUsers": [ { "userId": "64462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "zafar.rinky@gmail.com" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "waseeqzafar04@gmail.com" } ], "createdAt": "2025-06-02 12:25:06", "updatedAt": "2025-06-02 12:25:06", "workflowId": "workflow-065da3e5-3de5-4448-83f7-436b1881f314", "unavailableUsers": null, "taskName": "Email Testing", "adminEmail": "rinky.zafar@gmail.com" }
Get All Tasks
GET http://localhost:8080/task/admin
Response:
[ { "taskId": "683d4aca7dda4e6e8e85e529", "description": "Project Final Test", "status": "Start", "dueDate": "2025-06-15 20:00:00", "assignedUsers": [ { "userId": "64462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "zafar.rinky@gmail.com" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "waseeqzafar04@gmail.com" } ], "createdAt": "2025-06-02 12:25:06", "updatedAt": "2025-06-02 12:25:06", "workflowId": "workflow-065da3e5-3de5-4448-83f7-436b1881f314", "unavailableUsers": null, "taskName": "Email Testing", "adminEmail": "rinky.zafar@gmail.com" } ]
Delete Task
DELETE http://localhost:8080/task/admin/{taskId}
Responses:
204 No Content 404 Not Found
{ "message": "Task not found" }

👤 User Specific Endpoints

Get User Tasks
GET http://localhost:8080/task/user
Response:
[ { "taskId": "683d4aca7dda4e6e8e85e529", "description": "Project Final Test", "status": "Start", "dueDate": "2025-06-15 20:00:00", "assignedUsers": [ { "userId": "64462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "zafar.rinky@gmail.com" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "waseeqzafar04@gmail.com" } ], "createdAt": "2025-06-02 12:25:06", "updatedAt": "2025-06-02 12:25:06", "workflowId": "workflow-065da3e5-3de5-4448-83f7-436b1881f314", "taskName": "Email Testing" } ]
Update Task (User)
PUT http://localhost:8080/task/user/{taskId}
Request Body:
{ "status": "Completed", "description": "final mail check" }
Response:
{ "taskId": "683d4aca7dda4e6e8e85e529", "description": "final mail check", "status": "Completed", "dueDate": "2025-06-15 20:00:00", "assignedUsers": [ { "userId": "64462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "email" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "email" } ], "createdAt": "2025-06-02 12:25:06", "updatedAt": "2025-06-02 12:25:06", "workflowId": "workflow-065da3e5-3de5-4448-83f7-436b1881f314", "taskName": "Email Testing" }
🔄 Workflow Service
Authentication Required: Pass accessToken as Bearer token in all requests
Admin Only: All workflow endpoints are restricted to admin users
Response Codes: 200 OK, 201 Created, 401 Unauthorized, 404 Not Found
Create Workflow
POST http://localhost:8080/workflow
Response:
{ "workflowId": "workflow-065da3e5-3de5-4448-83f7-436b1881f314", "createdAt": 1748846546078, "updatedAt": 1748846546078, "completionPercentage": 0 }
Get All Workflows
GET http://localhost:8080/workflow
Response:
[ { "id": "683cb94a60fc40c1c0713905", "workflowId": "workflow-e1999340-9f10-4be1-af68-5d66e9cc6067", "createdAt": 1748810058240, "updatedAt": 1748810269081, "tasks": [ { "taskId": "683cb9a1e0a06cddff213948", "taskName": "Email Testing", "assignedUsers": [ { "userId": "464462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "zafar.rinky@gmail.com" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "waseeqzafar04@gmail.com" } ], "workflowId": "workflow-e1999340-9f10-4be1-af68-5d66e9cc6067", "eventType": null, "taskStatus": "Completed", "timestamp": 0, "adminEmail": "adminEmail" } ], "completionPercentage": 100, "adminEmail": "adminEmail" } ]
Get Specific Workflow
GET http://localhost:8080/workflow/{workflowId}
Response:
{ "id": "683cb94a60fc40c1c0713905", "workflowId": "workflow-e1999340-9f10-4be1-af68-5d66e9cc6067", "createdAt": 1748810058240, "updatedAt": 1748810269081, "tasks": [ { "taskId": "683cb9a1e0a06cddff213948", "taskName": "Email Testing", "assignedUsers": [ { "userId": "464462888-7540-4373-a02c-03f1023a1e1a", "userName": "Test2", "email": "zafar.rinky@gmail.com" }, { "userId": "89517ff0-587f-4e46-a98a-f6db03fa6bc6", "userName": "Test3", "email": "waseeqzafar04@gmail.com" } ], "workflowId": "workflow-e1999340-9f10-4be1-af68-5d66e9cc6067", "eventType": null, "taskStatus": "Completed", "timestamp": 0, "adminEmail": "adminEmail" } ], "completionPercentage": 100, "adminEmail": "adminEmail" }