Skip to main content

Notification Service โ€“ API Reference ๐Ÿ””

This document describes the read-only notification APIs exposed by the Notification Service in ShopVerse.

Notifications are generated asynchronously based on domain events and are accessed via the API Gateway.


๐ŸŒ Base URLโ€‹


/api/notifications


๐Ÿ” Authentication & Authorizationโ€‹

  • JWT is validated at the API Gateway
  • Gateway injects:
    • X-User-Email
    • X-User-Role
  • Users can access only their notifications
  • Admins can access all notifications

๐Ÿ“ฅ Get My Notifications (User)โ€‹

Fetch notifications for the authenticated user.

โžค Endpointโ€‹


GET /api/notifications

โžค Query Parameters (Optional)โ€‹

ParamDescription
pagePage number
sizePage size
unreadFilter unread notifications

โžค Success Response (200 OK)โ€‹

[
{
"id": "NTF101",
"eventType": "ORDER_PLACED",
"message": "Your order ORD789 has been placed successfully",
"timestamp": "2026-01-21T12:35:00",
"read": false
}
]

โœ”๏ธ Mark Notification as Readโ€‹

Mark a notification as read.

โžค Endpointโ€‹

PUT /api/notifications/{notificationId}/read

โžค Success Response (200 OK)โ€‹

{
"message": "Notification marked as read"
}

๐Ÿ‘‘ Get All Notifications (Admin)โ€‹

Fetch all notifications in the system.

โžค Endpointโ€‹

GET /api/notifications/all

โžค Role Requiredโ€‹

ADMIN

โžค Success Response (200 OK)โ€‹

[
{
"id": "NTF101",
"userEmail": "user@example.com",
"eventType": "PAYMENT_SUCCESS",
"message": "Payment successful for order ORD789",
"timestamp": "2026-01-21T12:45:00",
"read": true
}
]

๐Ÿ“ก Events Sourceโ€‹

Notifications are generated from Kafka events published by:

Source ServiceEvent Examples
Auth ServiceUSER_REGISTERED, USER_LOGIN
Order ServiceORDER_PLACED
Payment ServicePAYMENT_SUCCESS
Product ServicePRODUCT_CREATED

๐Ÿ”„ Request Flowโ€‹


๐Ÿ›ก๏ธ Security Rules Summaryโ€‹

RoleAccess
CUSTOMEROwn notifications
ADMINAll notifications

Ownership is enforced using X-User-Email.


โš ๏ธ Common Errorsโ€‹

StatusMeaning
401Unauthorized
403Forbidden
404Notification not found
500Internal server error

๐Ÿ“Œ Summaryโ€‹

The Notification API provides:

  • Asynchronous user notifications
  • Secure, role-based access
  • Clean read-only endpoints
  • Event-driven extensibility

It improves user experience without impacting core workflows.