totask users API Documentation
Authentication Routes
All authentication-related endpoints are prefixed with /auth
.
Register a User
Endpoint: POST /auth/register
Description: Registers a new user.
Request Body:
{
"name": "User's Name",
"email": "user@example.com",
"password": "userpassword"
}
Response:
- 201 Createdjson
{ "user": { "id": "user_id", "name": "User's Name", "email": "user@example.com", ... } }
Login
Endpoint: POST /auth/login
Description: Logs in a user.
Request Body:
{
"email": "user@example.com",
"password": "userpassword"
}
Response:
- 200 OKjson
{ "user": "user_id", "tokens": { ... } }
Logout
Endpoint: POST /auth/logout
Description: Logs out the current user.
Response:
- 204 No Content
Refresh Tokens
Endpoint: POST /auth/refresh-tokens
Description: Refreshes authentication tokens.
Request Body:
{
"refreshToken": "refresh_token"
}
Response:
- 200 OKjson
{ "access": { ... }, "refresh": { ... } }
Forgot Password
Endpoint: POST /auth/forgot-password
Description: Sends a password reset email.
Request Body:
{
"email": "user@example.com"
}
Response:
- 204 No Content
Reset Password
Endpoint: POST /auth/reset-password
Description: Resets the user's password.
Request Body:
{
"password": "newpassword"
}
Query Param: token
Response:
- 204 No Content
Change Password
Endpoint: POST /auth/change-password
Description: Changes the user's password.
Request Body:
{
"email": "user@example.com",
"password": "currentpassword",
"newPassword": "newpassword"
}
Response:
- 204 No Content
Send Verification Email
Endpoint: POST /auth/send-verification-email
Description: Sends a verification email.
Response:
- 204 No Content
Verify Email
Endpoint: POST /auth/verify-email
Description: Verifies the user's email.
Query Param: token
Response:
- 204 No Content
User Routes
All user-related endpoints are prefixed with /users
.
Create a User
Endpoint: POST /users
Description: Creates a new user (admin only).
Request Body:
{
"name": "User's Name",
"email": "user@example.com",
"password": "userpassword"
}
Response:
- 201 Createdjson
{ "id": "user_id", "name": "User's Name", "email": "user@example.com", ... }
Get Users
Endpoint: GET /users
Description: Retrieves a list of users (admin only).
Query Parameters:
name
role
username
sortBy
limit
page
Response:
- 200 OKjson
{ "results": [ ... ], "page": 1, "limit": 10, "totalPages": 1, "totalResults": 1 }
Get Current User
Endpoint: GET /users/user
Description: Retrieves the currently logged-in user.
Response:
- 200 OKjson
{ "id": "user_id", "name": "User's Name", "email": "user@example.com", ... }
Get User by ID
Endpoint: GET /users/:userId
Description: Retrieves a user by ID.
Response:
- 200 OKjson
{ "id": "user_id", "name": "User's Name", "email": "user@example.com", ... }
Update User
Endpoint: PUT /users/:userId
Description: Updates a user by ID.
Request Body:
{
"name": "New Name",
"email": "newemail@example.com",
...
}
Response:
- 200 OKjson
{ "id": "user_id", "name": "New Name", "email": "newemail@example.com", ... }
Delete User
Endpoint: POST /users/:userId
Description: Deletes a user by ID.
Response:
- 204 No Content
Add Board to Favorites
Endpoint: PUT /users/addToFav
Description: Adds a board to the user's favorites.
Request Body:
{
"boardId": "board_id"
}
Response:
- 200 OKjson
{ "favoriteBoards": [ ... ] }
Remove Board from Favorites
Endpoint: PUT /users/removeFromFav
Description: Removes a board from the user's favorites.
Request Body:
{
"boardId": "board_id"
}
Response:
- 200 OKjson
{ "favoriteBoards": [ ... ] }
Get Favorite Boards
Endpoint: GET /users/getFav
Description: Retrieves the user's favorite boards.
Response:
- 200 OKjson
{ "favoriteBoards": [ ... ] }
Search Users
Endpoint: GET /users/getUsers
Description: Searches for users by email.
Query Parameters:
email
limit
Response:
- 200 OKjson
{ "results": [ ... ] }
Delete Profile Picture
Endpoint: PUT /users/deleteProfilePic/:userId
Description: Deletes the user's profile picture.
Response:
- 200 OKjson
{ "id": "user_id", "profilePhotoUrl": null, ... }
Get Users Grouped by Month
Endpoint: GET /users/usersByMonth
Description: Retrieves users grouped by the month they were created.
Response:
- 200 OKjson
{ "results": [ ... ] }