Notifications Endpoints
API reference for in-app notification operations — list, mark as read, and bulk mark all as read.
Notifications Endpoints
Manage in-app notifications for the authenticated user. Notifications are generated automatically by the system for events like fine generation, reservation fulfillment, and overdue alerts.
Base Path: /api/v1/notifications
All endpoints require authentication (authenticate middleware applied globally on the router).
Get My Notifications
GET /api/v1/notificationsReturns the 50 most recent notifications for the authenticated user, sorted by newest first. Also includes an unreadCount for badge display.
Authorization: Any authenticated user
Success Response — 200 OK
{
"notifications": [
{
"_id": "...",
"userId": "...",
"title": "New Fine Generated",
"message": "An overdue fine of $5 has been generated for a book you have checked out.",
"type": "WARNING",
"isRead": false,
"createdAt": "2026-07-06T00:00:00.000Z",
"updatedAt": "2026-07-06T00:00:00.000Z"
}
],
"unreadCount": 3
}Notification Types
| Type | Usage |
|---|---|
INFO | General information (default) |
WARNING | Fine alerts, overdue notices |
SUCCESS | Reservation fulfilled, book returned |
ERROR | System errors or critical alerts |
Mark Notification as Read
PUT /api/v1/notifications/:id/readMarks a single notification as read. Only the notification owner can mark it.
Authorization: Any authenticated user (own notifications only)
Path Parameters
| Parameter | Description |
|---|---|
id | Notification ID |
Success Response — 200 OK
{
"message": "Marked as read",
"notification": {
"_id": "...",
"isRead": true,
"title": "...",
"message": "..."
}
}Error Responses
| Code | Condition |
|---|---|
404 | Notification not found or not owned by user |
500 | Internal server error |
Mark All as Read
PUT /api/v1/notifications/mark-all-readMarks all unread notifications for the authenticated user as read in a single operation.
Authorization: Any authenticated user
Success Response — 200 OK
{
"message": "All notifications marked as read"
}Route Summary
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /notifications | ✅ | Get own notifications (max 50) |
PUT | /notifications/mark-all-read | ✅ | Mark all as read |
PUT | /notifications/:id/read | ✅ | Mark single notification as read |