Overview
The Alerts API provides notification and calendar event management functionality. It supports creating alerts with different severity levels, scheduling notifications, and managing calendar events. Alerts can be marked as read and support time-based scheduling.Endpoints
Get Alerts
Retrieves all alerts for the authenticated user.Response
Array of alert objects
Example Request
Example Response
Create Alert
Creates a new alert or notification.Request Body
Title/subject of the alert
Detailed message content
Alert severity: ‘info’, ‘warning’, or ‘critical’
Initial read status (typically false for new alerts)
Whether this is a calendar event
When the event is scheduled (ISO 8601 format)
When to send the notification (ISO 8601 format)
Response
The newly created alert object
Example Request - Simple Alert
Example Request - Scheduled Event
Example Response
Update Alert
Updates an existing alert’s details.Path Parameters
The ID of the alert to update
Request Body
Accepts the same fields as Create Alert (all optional for updates):Updated title
Updated message
Updated severity level
Updated read status
Updated event flag
Updated scheduled time
Updated notification time
Example Request
Delete Alert
Deletes an alert from the system.Path Parameters
The ID of the alert to delete
Example Request
Error Responses
Alert deleted successfully
Alert not found
Unauthorized - Authentication required
Mark Alert as Read
Marks a specific alert as read.Path Parameters
The ID of the alert to mark as read
Example Request
Response
Returns success status (typically 200 OK).Alert Types
The system supports three severity levels:Info
- General notifications and informational messages
- Calendar events and reminders
- Status updates
- Scheduled maintenance windows
- Upcoming inventory audits
- System announcements
Warning
- Important notifications requiring attention
- Non-critical issues
- Low stock alerts
- Upcoming loan due dates
- Expiring items
Critical
- Urgent notifications requiring immediate action
- System errors or failures
- Out of stock items
- Overdue loans
- Failed system operations
- Security alerts
Business Logic Notes
Alert vs Event Distinction
- Alerts (
isEvent: false): Notifications about system states or issues - Events (
isEvent: true): Calendar-based items with specific scheduled times - Events typically have both
scheduledAt(event time) andnotifyAt(notification time)
Notification Scheduling
scheduledAt: When the actual event occursnotifyAt: When to notify the user about the event- Example: Event at 9 AM, notification at 8 AM (1 hour advance notice)
- Backend should implement a notification service to process
notifyAttimes
Read Status Management
- Alerts are created with
isRead: falseby default - Use the dedicated
/alerts/{id}/readendpoint for marking as read - This provides better audit trails than direct updates
- Consider implementing bulk “mark all as read” functionality
Date Format
- All timestamps use ISO 8601 format with timezone information
- Always include timezone (typically UTC) in API requests
- Client should convert to local timezone for display
Automatic Alert Generation
Consider implementing automatic alerts for:- Low stock thresholds (when inventory falls below minimum)
- Overdue loans (daily check for loans past
expectedReturnDate) - Upcoming loan due dates (1-3 days before
expectedReturnDate) - Scheduled maintenance or audit reminders
Alert Lifecycle
- Created: Alert is generated (manual or automatic)
- Delivered: Notification sent to user (via push, email, in-app)
- Read: User acknowledges the alert
- Archived/Deleted: Alert is removed after a retention period
Performance Considerations
- Implement pagination for alerts list (can grow very large)
- Consider soft deletes for audit purposes
- Archive old read alerts after a retention period (e.g., 30 days)
- Index on
isReadandcreatedAtfor efficient querying
