-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
All endpoints that require a current user to be logged in.
- Request: endpoints that require authentication
- Error Response: Require authentication
-
Status Code: 401
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Authentication required" }
-
All endpoints that require authentication and the current user does not have the correct role(s) or permission(s).
- Request: endpoints that require proper authorization
- Error Response: Require proper authorization
-
Status Code: 403
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Forbidden" }
-
Returns the information about the current user that is logged in.
-
Require Authentication: false
-
Request
- Method:
GET
- URL:
/api/session
- Body: none
- Method:
-
Successful Response when there is a logged in user
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "user": { "id": 1, "firstName": "Hongjoong", "lastName": "Kim", "email": "khj@kaykew.io", "username": "khj1107" } }
-
-
Successful Response when there is no logged in user
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "user": null }
-
Logs in a current user with valid credentials and returns the current user's information.
-
Require Authentication: false
-
Request
-
Method:
POST
-
URL:
/api/session
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "credential": "khj@kaykew.io", "password": "8makes1team" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "user": { "id": 1, "firstName": "Hongjoong", "lastName": "Kim", "email": "khj@kaykew.io", "username": "khj1107" } }
-
-
Error Response: Invalid credentials
-
Status Code: 401
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Invalid credentials" }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "credential": "Email or username is required", "password": "Password is required" } }
-
Creates a new user, logs them in as the current user, and returns the current user's information.
-
Require Authentication: false
-
Request
-
Method:
POST
-
URL:
/api/users
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "firstName": "Hongjoong", "lastName": "Kim", "email": "khj@kaykew.io", "username": "khj1107", "password": "8makes1team" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "user": { "id": 1, "firstName": "Hongjoong", "lastName": "Kim", "email": "khj@kaykew.io", "username": "khj1107" } }
-
-
Error response: User already exists with the specified email
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "User already exists", "errors": { "email": "User with that email already exists" } }
-
-
Error response: User already exists with the specified username
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "User already exists", "errors": { "username": "User with that username already exists" } }
-
-
Error response: Body validation errors
-
Status Code: 400
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "email": "Invalid email", "username": "Username is required", "firstName": "First Name is required", "lastName": "Last Name is required" } }
-
Returns all the notebooks of the current user.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/notebooks
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "notebooks": [ { "id": 1, "ownerId": 1, "name": "Work", "favorite": true, "createdAt": "2024-08-29T21:28:48.950Z", "updatedAt": "2024-08-29T21:28:48.950Z" } ] }
-
Returns all the favorite notebooks of the current user.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/notebooks/favorites
- Body: none
- Method:
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "notebooks": [ { "id": 1, "ownerId": 1, "name": "Work", "favorite": true, "createdAt": "2024-08-29T21:28:48.950Z", "updatedAt": "2024-08-29T21:28:48.950Z" } ] }
Returns a notebook and its associated notes by notebook ID for the logged-in user.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/notebooks/:id
- Body: none
- Method:
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "id": 1, "ownerId": 1, "name": "Work", "favorite": true, "createdAt": "2024-08-29T21:28:48.950Z", "updatedAt": "2024-08-29T21:28:48.950Z", "Notes": [ { "id": 1, "ownerId": 1, "notebookId": 1, "title": "Project Plan", "description": "Outline the project phases: research, design, development, testing, and deployment.", "createdAt": "2024-08-29T21:28:48.960Z", "updatedAt": "2024-08-29T21:28:48.960Z" }, { "id": 2, "ownerId": 1, "notebookId": 1, "title": "Meeting Notes", "description": "Discussed the project timeline, assigned tasks, and set the next meeting for Friday.", "createdAt": "2024-08-29T21:28:48.960Z", "updatedAt": "2024-08-29T21:28:48.960Z" } ] }
-
Error Response: Notebook not found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Notebook not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this notebook." }
Creates a new notebook and returns a new notebook
-
Require Authentication: true
-
Request
-
Method:
POST
-
URL:
/api/notebooks
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "name": "new-notebook" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "id": 3, "ownerId": 1, "name": "new-notebook", "favorite": false, "createdAt": "2024-08-29T21:28:48.960Z", "updatedAt": "2024-08-29T21:28:48.960Z" }
-
-
Error Response: Validation errors
-
Status Code: 400
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Validation error", "errors": { "name": "Notebook name is required.", "name": "Notebook name must be less than 50 characters." } }
-
Edits an existing notebook for the logged in user.
-
Require Authentication: true
-
Request
-
Method:
PUT
-
URL:
/api/notebooks/:id
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "name": "new-notebook-edited", "favorite": true }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "id": 3, "ownerId": 1, "name": "new-notebook-edited", "favorite": true, "createdAt": "2024-08-29T21:28:48.960Z", "updatedAt": "2024-08-30T21:28:48.960Z" }
-
-
Error Response: Validation errors
-
Status Code: 400
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Validation error", "errors": { "name": "Notebook name is required.", "name": "Notebook name must be less than 50 characters." } }
-
-
Error Response: Notebook not found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Notebook not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this notebook." }
Deletes an existing notebook for the logged-in user, including its associated notes and tags.
-
Require Authentication: true
-
Request
- Method:
DELETE
- URL:
/api/notebooks/:id
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Notebook, its notes, and associated tags successfully deleted" }
-
-
Error Response: Notebook not found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Notebook not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this notebook." }
-
Error Response: Failed to Delete Notebook
- Status Code: 500
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Failed to delete notebook, its notes, and associated tags." }
Returns all details for a specific note, including its associated tags.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/notebooks/:id
- Body: none
- Method:
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "id": 1, "ownerId": 1, "notebookId": 1, "title": "Project Plan", "description": "Outline the project phases: research, design, development, testing, and deployment.", "createdAt": "2024-08-29T21:28:48.960Z", "updatedAt": "2024-08-29T21:28:48.960Z", "Tags": [ { "id": 1, "userId": 1, "name": "Work", "createdAt": "2024-08-29T21:28:48.971Z", "updatedAt": "2024-08-29T21:28:48.971Z" } ] }
-
Error Response: Note Not Found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Note not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this note." }
Creates a new note for a specific notebook and returns the newly created note.
-
Require Authentication: true
-
Request
-
Method:
POST
-
URL:
/api/notes
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "title": "New Note", "description": "This is a new note.", "notebookId": 1 }
-
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "id": 3, "title": "New Note", "description": "This is a new note.", "notebookId": 1, "ownerId": 1, "createdAt": "2024-08-03T12:00:00.000Z", "updatedAt": "2024-08-03T12:00:00.000Z" }
-
Error Response: Validation Errors
- Status Code: 400
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Validation error", "errors": { "title": "Note title is required.", "title": "Note title must be less than 100 characters.", "description": "Note description is required." } }
-
Error Response: Missing Required Fields
- Status Code: 400
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "All fields are required." }
Edits an existing note and returns the updated note with its associated tags.
-
Require Authentication: true
-
Request
-
Method:
PUT
-
URL:
/api/notes/:id
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "title": "Edited Note", "description": "This is an edited note.", "notebookId": 1 }
-
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "id": 3, "title": "Updated Note Title", "description": "Updated note description.", "notebookId": 1, "ownerId": 1, "createdAt": "2024-08-03T12:00:00.000Z", "updatedAt": "2024-08-03T12:05:00.000Z", "Tags": [ { "id": 1, "name": "Important" } ] }
-
Error Response: Note Not Found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Note not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this note." }
-
Error Response: Validation Errors
- Status Code: 400
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Validation error", "errors": { "title": "Note title is required.", "title": "Note title must be less than 100 characters.", "description": "Note description is required." } }
Deletes an existing note and its associated tags.
-
Require Authentication: true
-
Request
- Method:
DELETE
- URL:
/api/notes/:id
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type: application/json
-
Body:
{ "message": "Note and its associated tags successfully deleted" }
-
-
Error Response: Notebook not found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Note not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this note." }
-
Error Response: Failed to Delete Note
- Status Code: 500
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Failed to delete note and its associated tags." }
Adds a new tag to a specific note and returns the updated note with its associated tags.
-
Require Authentication: true
-
Request
-
Method:
POST
-
URL:
/api/notes/:id/tags
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "name": "New Tag" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "id": 3, "title": "Updated Note Title", "description": "Updated note description.", "notebookId": 1, "ownerId": 1, "createdAt": "2024-08-03T12:00:00.000Z", "updatedAt": "2024-08-03T12:05:00.000Z", "Tags": [ { "id": 1, "name": "Important" }, { "id": 3, "name": "New Tag" } ] }
-
-
Error Response: Note not found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Note not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this note." }
-
Error Response: Failed to Add Tag to Note
- Status Code: 500
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Failed to add tag to note." }
Deletes a tag from a specific note and returns the updated note with its associated tags.
-
Require Authentication: true
-
Request
- Method:
DELETE
- URL:
/api/notes/:noteId/tags/:tagId
- Body: none
- Method:
-
Successful Response
- Status Code: 200
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "id": 3, "title": "Updated Note Title", "description": "Updated note description.", "notebookId": 1, "ownerId": 1, "createdAt": "2024-08-03T12:00:00.000Z", "updatedAt": "2024-08-03T12:05:00.000Z", "Tags": [] }
-
Error Response: Tag not found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Tag not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this note." }
-
Error Response: Failed to Delete Tag From Note
- Status Code: 500
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Failed to delete tag from note." }
Fetches all tasks of the current user that are due within the next 5 days.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/tasks/reminders
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "tasks": [ { "id": 1, "userId": 1, "title": "Finish project", "description": "Complete the capstone project", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "high", "completed": false, "createdAt": "2024-08-01T10:00:00.000Z", "updatedAt": "2024-08-01T11:00:00.000Z" }, ] }
-
-
Error Response: Failed to fetch reminders
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Failed to fetch reminders." }
-
Returns all tasks associated with the logged-in user.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/tasks
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
[ { "id": 1, "userId": 1, "title": "Finish project", "description": "Complete the capstone project", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "high", "completed": false, "createdAt": "2024-08-01T10:00:00.000Z", "updatedAt": "2024-08-01T11:00:00.000Z" }, ]
-
-
Error Response
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Failed to fetch tasks." }
-
Returns detailed information about a specific task.
-
Require Authentication: true
-
Request
- Method:
GET
- URL:
/api/tasks/:taskId
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "id": 1, "userId": 1, "title": "Finish project", "description": "Complete the capstone project", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "high", "completed": false, "createdAt": "2024-08-01T10:00:00.000Z", "updatedAt": "2024-08-01T11:00:00.000Z" }
-
-
Error Response: Task Not Found
- Status Code: 404
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "Task not found." }
-
Error Response: Unauthorized access
- Status Code: 403
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
{ "message": "You do not have access to this task." }
-
Error Response
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Failed to fetch task details." }
-
Creates a new task for the logged-in user.
-
Require Authentication: true
-
Request
-
Method:
POST
-
URL:
/api/tasks
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "title": "Finish project", "description": "Complete the capstone project", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "high" }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "id": 1, "userId": 1, "title": "Finish project", "description": "Complete the capstone project", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "high", "completed": false, "createdAt": "2024-08-01T10:00:00.000Z", "updatedAt": "2024-08-01T11:00:00.000Z" }
-
-
Error Response: Validation Errors
-
Status Code: 400
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "errors": [ "Task title is required.", "Description is required.", "Due date is required.", "Priority is required." ] }
-
Updates a task's details.
-
Require Authentication: true
-
Request
-
Method:
PUT
-
URL:
/api/tasks/:taskId
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "title": "Finish project edited", "description": "Complete the capstone project edited", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "medium", "completed": true }
-
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "id": 1, "userId": 1, "title": "Finish project edited", "description": "Complete the capstone project edited", "dueDate": "2024-08-03T12:00:00.000Z", "priority": "medium", "completed": true, "createdAt": "2024-08-01T10:00:00.000Z", "updatedAt": "2024-08-01T11:00:00.000Z" }
-
-
Error Response: Task Not Found
-
Status Code: 404
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Task not found." }
-
-
Error Response: Server Error
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Failed to update task." }
-
Deletes a task owned by the logged-in user.
-
Require Authentication: true
-
Request
- Method:
DELETE
- URL:
/api/tasks/:taskId
- Body: none
- Method:
-
Successful Response
-
Status Code: 200
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Task successfully deleted" }
-
-
Error Response: Task Not Found
-
Status Code: 404
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Task not found." }
-
-
Error Response: Server Error
-
Status Code: 500
-
Headers:
- Content-Type:
application/json
- Content-Type:
-
Body:
{ "message": "Failed to delete task." }
-