Skip to main content

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):

  1. Path parameter (recommended): /company/notifications/read/{id}
  2. Query parameter: /company/notifications/read?id={id}
  3. 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

Notification marked as read successfully.