Notification Routes
This page provides routes for managing notifications. The following routes are available:
POST /notifications
Creates a new notification.
Description: This endpoint creates a new notification.
Authentication: Requires authentication with the USER role and read permission.
Request Body:
{
"message": "This new notification", //(string, required) message of the notification
"userId": "667010b8d14c54c691968cc5" //(string, required) userId of the receiver
}Response:
- Success Response (201 Created):
{
"isRead": false,
"message": "This new notification",
"orgId": "666141dbfe2a0781e76f6549",
"userId": "667010b8d14c54c691968cc5",
"_id": "667d5d9fa54857e943886683",
"createdAt": "2024-06-27T12:39:59.132Z",
"updatedAt": "2024-06-27T12:39:59.132Z",
"__v": 0
}Errors:
500 Internal Server Error:Errors may occur due to authentication failure, request body validation failure, or other issues in thenotificationController.createNotificationlogic.404 Not Found:The requested resource could not be found.401 Unauthorized:The user is not authenticated or does not have the required permissions.400 Bad Request:The request body is invalid or missing required fields.
Usage: To create a new notification, send a POST request to /notifications with a JSON request body containing the notification details. The request must include an authenticated user with the USER role and read permission.
GET /notifications
Retrieves a list of notifications.
Description: This endpoint retrieves a list of notifications.
Authentication: Requires authentication with the USER role and read permission.
Response:
- Success Response (200 OK):
[
{
"_id": "667e36823bc6e03897f3651f",
"isRead": false,
"message": "This new notification",
"orgId": "666141dbfe2a0781e76f6549",
"userId": "66740a56d434270f2c248db0",
"createdAt": "2024-06-28T04:05:22.479Z",
"updatedAt": "2024-06-28T04:05:22.479Z",
"__v": 0
},
{
"_id": "667e36903bc6e03897f36522",
"isRead": false,
"message": "This is another notification",
"orgId": "666141dbfe2a0781e76f6549",
"userId": "66740a56d434270f2c248db0",
"createdAt": "2024-06-28T04:05:36.457Z",
"updatedAt": "2024-06-28T04:05:36.457Z",
"__v": 0
}
]Errors:
401 Unauthorized:Authentication failure500 Internal Server Error:Issues in thenotificationController.getNotificationlogic
Usage: To retrieve a list of notifications, send a GET request to /notifications. The request must include an authenticated user with the USER role and read permission.
PUT /notifications
Marks notifications as read.
Description: This endpoint marks notifications as read.
Authentication: Requires authentication with the USER role and read permission.
Response:
- Success Response (201 CREATED):
{
"_id": "667e36903bc6e03897f36522",
"isRead": true,
"message": "This another notification",
"orgId": "666141dbfe2a0781e76f6549",
"userId": "66740a56d434270f2c248db0",
"createdAt": "2024-06-28T04:05:36.457Z",
"updatedAt": "2024-06-28T04:12:19.150Z",
"__v": 0
}Errors:
401 Unauthorized:Authentication failure500 Internal Server Error:Issues in thenotificationController.markAsReadlogicUsage: To mark notifications as read, send a PUT request to
/notifications. The request must include an authenticated user with theUSERrole andreadpermission.
