The Notifications API delivers in-app alerts to StockManager users through a combination of a persistent Server-Sent Events stream and traditional REST endpoints for polling, bulk marking, and administrative creation. Notifications are per-user; every event delivered over SSE is also retrievable via the REST endpoints for clients that cannot maintain a long-lived connection. Creating and deleting notifications requires theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/InnoDev69/StockManager/llms.txt
Use this file to discover all available pages before exploring further.
admin or root role; reading and marking require only an active session.
Notification Object
The following fields are present on every notification object returned by any endpoint in this section.Primary key of the notification record.
Short heading displayed in the notification panel.
Full body text of the notification.
Visual category:
info, warning, error, or success.Optional deep-link path (e.g.
/items/17) the user can follow for more context. null when not set.ISO-8601 timestamp of when the notification was created.
false until the notification is explicitly marked as read.Real-time Stream
GET /api/notifications/stream
Opens a long-lived Server-Sent Events connection. The responseContent-Type is text/event-stream; charset=utf-8 and the connection remains open until the client disconnects or the server replaces it with a newer one from the same user.
Auth: any authenticated session.
Only one active stream per user is maintained. When a second connection is opened by the same user, the server signals the first stream to close before the new one begins sending events.
Events
event: init
Fired once immediately on connect. Contains the last 5 unread notifications and the total unread count.
event: update
Fired whenever a new notification is created for this user (triggered server-side after POST /api/notifications/create or any automated alert). Contains the last 10 unread notifications and the updated count.
Event data shape
Bothinit and update carry the same JSON structure:
Array of notification objects. Up to 5 on
init, up to 10 on update.Total number of unread notifications for this user at the time of the event.
JavaScript example
Browser-native
EventSource automatically reconnects after network interruptions using exponential back-off. No manual reconnection logic is needed in most clients.REST Endpoints
GET /api/notifications/unread
Returns the last 10 unread notifications for the authenticated user plus the total unread count. Use this for initial page load or as a fallback when SSE is unavailable. Auth: any authenticated session. ResponseUp to 10 most recent unread notification objects.
Total number of unread notifications, which may exceed 10.
GET /api/notifications/all
Returns all notifications for the authenticated user with offset-based pagination. Includes both read and unread notifications, ordered by creation date descending. Auth: any authenticated session.Maximum number of notifications to return. Defaults to
20.Number of records to skip before returning results. Defaults to
0.POST /api/notifications/:id/read
Marks a single notification as read (is_read = true). The notification does not need to belong to the currently authenticated user — ownership is not validated at the route level.
Auth: any authenticated session.
| Status | Meaning |
|---|---|
200 | {"message": "Notificación marcada como leída"} |
500 | Unexpected database error. |
POST /api/notifications/read-all
Marks every notification belonging to the authenticated user as read in a single operation. Auth: any authenticated session.| Status | Meaning |
|---|---|
200 | {"message": "Todas las notificaciones marcadas como leídas"} |
500 | Unexpected database error. |
Administrative Endpoints
POST /api/notifications/create
Creates a notification for a specific user. After persisting the record the server immediately signals the target user’s SSE stream so theupdate event is delivered in real time.
Auth: admin or root role required.
ID of the user who should receive the notification.
Short heading for the notification.
Full body text.
Visual category:
info, warning, error, or success.Optional deep-link path (e.g.
/items/17). Omit or pass null to leave unset.| Status | Meaning |
|---|---|
201 | {"message": "Notificación creada exitosamente"} |
400 | user_id, title, or message is missing. |
500 | Unexpected database error. |
DELETE /api/notifications/:id/delete
Permanently deletes a notification record from the database. Auth:admin or root role required.
| Status | Meaning |
|---|---|
200 | {"message": "Notificación eliminada exitosamente"} |
500 | Unexpected database error. |