Delete notification
DELETE/company/:id
Permanently delete a system notification. This action cannot be undone.
Use Cases:
- When the user clears old notifications
- Bulk deletion of notifications
- Compliance with data deletion requests
- Automated cleanup of expired notifications
Typical Flow:
- User selects Delete option on a notification
- Client displays confirmation to the user
- If confirmed:
- Calls this endpoint with the notification ID
- The server:
- Validates the JWT token
- Verifies the notification exists and belongs to the user's company
- Permanently deletes the record from the database
- Returns the deleted notification
- Client removes the notification from the UI locally
Considerations:
- Only notifications belonging to the user's company can be deleted
- Deletion is permanent and irreversible
- Client-side confirmation is recommended before calling the endpoint
- For bulk deletions, consider implementing a batch endpoint
Implementation Example:
// Example frontend call
async function deleteNotification(notificationId) {
if (confirm('Are you sure you want to delete this notification?')) {
try {
const response = await fetch(`/company/notifications/${notificationId}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${userToken}`
}
});
if (response.ok) {
const deletedNotification = await response.json();
removeNotificationFromUI(deletedNotification._id);
}
} catch (error) {
console.error('Error deleting notification:', error);
}
}
}
System Impact:
- Reduces storage usage
- Improves performance in future queries
- Permanently removes sensitive data
Request
Responses
- 200
- 401
- 404
Notification successfully deleted.
Unauthorized - Invalid or missing JWT token
Notification not found - The ID does not correspond to an existing notification