Notifications
Notifications are in-app messages stored in the notification Cosmos DB container. They are separate from alerts: alerts dispatch content externally (email, SMS, push), while notifications are created as a side-effect of alert dispatch and are read back from the app. The endpoints below manage retrieval, FCM token registration, read-status updates, and assignee operations.
The date field in all responses is always current_user['nowUTCWithShiftDateTime'].strftime('%Y-%m-%dT%H:%M:%S%z') — the current server time expressed in the industry's shift-adjusted UTC offset.
GET /api/user/notification/ — All Notifications
Returns all notifications for the authenticated industry, optionally scoped to a recent window of days.
GET /api/user/notification/?days=7
Authorization: Bearer <access_token>
Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
days | No | 0 | Number of recent days to include. 0 returns all records with no date filter |
Execution flow
daysdefaults to0if the parameter is absent or not sent.NotificationService({days}).get_all_notifications()queries thenotificationcontainer filtered byindustryIdfromcurrent_user. Whendays > 0, the query adds a recency filter for the last N days.NotificationDataFormatter().format_all_notification(raw)shapes the records into the response structure.
Response
If the formatted result is non-empty:
HTTP 200
{
"status": "success",
"notifications": [ { ... }, { ... } ],
"date": "2024-11-09T10:30:00+0530"
}
If the formatted result is empty:
HTTP 201
{
"status": "success",
"notifications": [],
"date": "2024-11-09T10:30:00+0530"
}
The 201 status on an empty result is intentional — it signals "success with no content" rather than an error condition.
GET /api/user/notificationRange — Range Query
Returns notifications between two explicit dates.
GET /api/user/notificationRange?startDate=01/11/2024&endDate=09/11/2024
Authorization: Bearer <access_token>
Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
startDate | Yes | — | Start of the range (DD/MM/YYYY) |
endDate | Yes | — | End of the range (DD/MM/YYYY) |
Validation
| Check | Error |
|---|---|
startDate absent | 1403 "'startDate' missing" |
endDate absent | 1403 "'endDate' missing" |
Execution flow
NotificationService({startDate, endDate}).get_range_notifications() queries the container for records in the inclusive date window. The result is processed by the same NotificationDataFormatter().format_all_notification() call and returns the same 200 / 201 response shape as the all-notifications endpoint.
POST /api/user/notification/register/fcm — Register FCM Token
Registers a Firebase Cloud Messaging token for the current user's device. Tokens registered here are later batch-fetched by DatabaseSupporter.get_fcm_ids() when the alert dispatcher builds its FCM recipient set.
POST /api/user/notification/register/fcm
Authorization: Bearer <access_token>
X-Device-Id: device-abc123
Content-Type: application/json
{
"fcmToken": "eHhO9..."
}
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer JWT |
X-Device-Id | Yes | Unique identifier for the calling device |
Body fields
| Field | Required | Description |
|---|---|---|
fcmToken | Yes | The FCM registration token from the Firebase client SDK |
Validation
| Check | Error |
|---|---|
fcmToken absent from body | 1403 "'fcmToken' missing" |
X-Device-Id header absent | 1403 "'X-Device-Id' missing" |
Execution flow
NotificationService(args).register_fcm_user(args) writes the token to the user's record in Cosmos DB, keyed by X-Device-Id. If a token already exists for that device ID it is overwritten.
On exception → 400 with the error message from the caught exception.
Response
HTTP 200
{
"status": "success",
"message": "FCM token registered successfully"
}
PATCH /api/user/notification/updateRead — Mark Notifications as Read
Updates the read status of one or more notifications. This endpoint is PATCH, not PUT.
PATCH /api/user/notification/updateRead
Authorization: Bearer <access_token>
Content-Type: application/json
{
"notifications": [
{ "id": "notif-001", "read": true },
{ "id": "notif-002", "read": true }
]
}
Body
Validated against NotificationReadUpdateRequest.
| Field | Required | Description |
|---|---|---|
notifications | Yes | Array of notification objects. Each object must contain enough identity information for the service to locate the Cosmos DB document |
Execution flow
NotificationService(args).update_notification_read_status(body['notifications']) patches each document in the notification container. Only documents whose industryId matches the authenticated user's industry can be updated.
Response
HTTP 200
{
"status": "success",
"message": "notifications updated successfully"
}
POST /api/user/notification/assignee — Assign a Notification
Assigns a notification to another user. After the database update, a WebSocket broadcast is sent to the industry's admin channel to inform the assignee in real time.
POST /api/user/notification/assignee
Authorization: Bearer <access_token>
Content-Type: application/json
Body
Validated against NotificationAssigneeModel.
| Field | Required | Description |
|---|---|---|
assigneeId | Yes | User ID of the person being assigned |
notificationId | Yes | ID of the notification to assign |
| (additional fields) | Varies | Other fields required by NotificationAssigneeModel |
Execution flow
NotificationService(args).add_notification_assignee(body)writes the assignment to the notification document in Cosmos DB.AdminNotificationService().send_web_socket_notification('Notification Assigned', f'{current_user["userId"]} assigned an alert to {body["assigneeId"]}')broadcasts the event over Azure Web PubSub. This is a fire-and-forget broadcast — it is not stored as a separate notification document.
Response
HTTP 200
{
"status": "success",
"message": "Assignee added successfully"
}
DELETE /api/user/notification/assignee — Remove Assignee
Removes an existing assignee from a notification.
DELETE /api/user/notification/assignee
Authorization: Bearer <access_token>
Content-Type: application/json
Execution flow
NotificationService(args).delete_notification_assignee(body) clears the assignee field from the notification document in Cosmos DB. No WebSocket broadcast is sent on removal.
Response
HTTP 200
{
"status": "success",
"message": "Assignee deleted successfully"
}
PATCH /api/user/notification/assignee — Mark as Resolved
Marks a notification as resolved. Uses PATCH on the same /assignee path as the DELETE and POST endpoints, distinguished by HTTP method.
PATCH /api/user/notification/assignee
Authorization: Bearer <access_token>
Content-Type: application/json
Execution flow
NotificationService(args).update_notification_as_resolved(body) sets the resolved flag on the notification document in Cosmos DB.
Response
HTTP 200
{
"status": "success",
"message": "notifications marked as resolved successfully"
}
Status Code Reference
| Code | Meaning |
|---|---|
200 | Operation succeeded |
201 | Success — no notifications found for the given query |
400 | Exception during FCM registration |
401 | Missing or invalid JWT |
1403 | Missing required parameter (startDate, endDate, fcmToken, or X-Device-Id) |