Delete notification
DELETE/company/notifications/:id
Permanently delete a system notification. This action is irreversible and frees up space in the database.
Objective
Allow companies to manage their notifications by deleting those they do not need to keep, enabling controlled cleanup of the alert history.
Use Cases
- Cleanup of old notifications: Delete irrelevant historical notifications
- Individual deletion: When a user decides to delete a specific notification
- Storage management: Reduce database size by deleting unnecessary records
- Deletion after action: Delete notifications after completing the associated action
Deletion Flow
flowchart TD
A[DELETE /{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[Delete Notification]
O --> P[Permanent Deletion]
P --> Q[Return Deleted Notification - 200]
Parameter Flexibility
The notification ID can be sent in three ways (in order of priority):
- Path parameter (recommended):
/company/notifications/{id} - Query parameter:
/company/notifications/{id}?id={id}(not recommended, redundant) - Request body:
{ id: {id} }(alternative for certain clients)
The system checks in this order: body → query → params
Deletion Impact
- Permanent: The notification cannot be recovered
- Immediate: Deletion takes effect at the moment of the call
- No rollback: There is no recycle bin or restoration
- De-indexing: The notification disappears from all queries
Considerations
- It is recommended to implement
Request
Responses
- 200
- 401
- 404
Notification successfully deleted.
The response contains the notification as it existed before being deleted. This information can be useful for:
- Confirming what was deleted
- Updating the UI locally
- Logging/auditing
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 already deleted previously