Mark notification as read
PUT/company/notifications/read/:id
Updates the status of a notification to mark it as read, recording the current date and time of the reading.
Objective
Allow companies to mark notifications as read to maintain accurate tracking of pending alerts and improve the user experience.
Use Cases
- User Interaction: When the user clicks on a notification
- Multi-Device Sync: Mark as read across all devices
- Bulk Reading: Mark multiple notifications in batch
- Notification Management: Status update from the notification panel
Update Flow
flowchart TD
A[PUT /read/{id}] --> B{ID Provided?}
B -->|No| C[Check Body]
B -->|Yes| D[Use Path ID]
C -->|Found| E[Use Body ID]
C -->|Not Found| F[Check Query]
F -->|Found| G[Use Query ID]
F -->|Not Found| H[400 Bad Request]
D --> I{User Authenticated?}
E --> I
G --> I
I -->|No| J[404 USER_NOT_FOUND]
I -->|Yes| K{Company Exists?}
K -->|No| L[401 CIA_NOT_FOUND]
K -->|Yes| M{Notification Exists?}
M -->|No| N[404 NOTIFICATION_NOT_FOUND]
M -->|Yes| O[Update Notification]
O --> P[Set isRead: true]
P --> Q[Set readedAt: now]
Q --> R[Save to Database]
R --> S[Return Notification - 200]
Parameter Flexibility
The notification ID can be sent in three ways (in order of priority):
- Path parameter (recommended):
/company/notifications/read/{id} - Query parameter:
/company/notifications/read?id={id} - Request body:
{ id: {id} }
The system checks in this order: body → query → params
Updated Fields
isRead: Set to true
readedAt: Set to the server's current date and time
Important Notes
- The operation is idempotent: calling the endpoint multiple times with the same ID does not cause errors
- If the notification was already marked as read, `
Request
Responses
- 200
- 401
- 404
Notification marked as read successfully.
Unauthorized. The user does not have an associated company.
CIA_NOT_FOUND:
- The authenticated user does not have an assigned company
- The company was deactivated or deleted
Resource not found. This could be due to two reasons:
USER_NOT_FOUND:
- The token contains a user ID that does not exist
NOTIFICATION_NOT_FOUND:
- The provided ID does not correspond to any notification
- The notification was previously deleted