masaruk Logo

Notifications & Messaging API

System notifications and admin/provider messaging endpoints

1. Purpose

This document defines the Notifications and Messaging API endpoints for:

  • System notifications (push, SMS, email)
  • Manual messaging from Admin/Provider to customers
  • Notification read status management

All endpoints follow the conventions in api-principles-and-versioning.md.

3. Notifications API

3.1 Get User Notifications

GET/api/v1/notifications

Auth: Bearer token required

Roles: CUSTOMER / END_USER

ParameterTypeDescription
statusstringFilter: read / unread / all (default: all)
typestringFilter by type: booking_update, payment_update, trip_status, rating_request, general
pageintegerPage number (default: 1)
per_pageintegerItems per page (default: 20)

3.2 Mark Notification as Read

PUT/api/v1/notifications/{id}/read

Auth: Bearer token required

Roles: CUSTOMER / END_USER

Additional: User must own the notification

3.3 Mark All Notifications as Read

PUT/api/v1/notifications/read-all

Auth: Bearer token required

Roles: CUSTOMER / END_USER

3.4 Get Unread Count

GET/api/v1/notifications/unread-count

Auth: Bearer token required

Roles: CUSTOMER / END_USER

4. Messaging API (Admin/Provider → Customer)

4.1 Send Message to Customer

POST/api/v1/messages

Auth: Bearer token required

Roles: ADMIN, SUPER_ADMIN, PROVIDER_ADMIN, SUPPORT_AGENT

Validation Rules:
  • receiver_id: required, must exist
  • booking_id: optional, must belong to receiver if provided
  • subject: required, max 120 characters
  • body: required
Behavior:
  • Message is stored in database
  • Notification is created for the receiver
  • Delivery attempted via configured channels (Push, SMS, Email)

4.2 Get Sent Messages (Admin/Provider)

GET/api/v1/messages/sent

Auth: Bearer token required

Roles: ADMIN, SUPER_ADMIN, PROVIDER_ADMIN

ParameterTypeDescription
booking_idintegerFilter by booking
pageintegerPage number

Provider users only see messages they sent; Admin sees all.

5. System Notification Triggers (Internal)

These notifications are triggered automatically by the backend:

Trigger EventNotification TypeTemplate (Arabic)
Payment successpayment_updateتم تأكيد الدفع بنجاح
Booking confirmedbooking_updateتم تأكيد حجزك بنجاح
Booking cancelledbooking_updateتم إلغاء حجزك
Trip reminder (24h before)trip_statusرحلتك تبدأ غداً
Trip completedtrip_statusنتمنى لك رحلة سعيدة
Rating requestrating_requestنرجو تقييم رحلتك
Refund processedpayment_updateتم استرداد المبلغ

6. Error Cases

Error CodeHTTPDescription
NOTIFICATION_NOT_FOUND404Notification does not exist
NOTIFICATION_ACCESS_DENIED403User does not own this notification
MESSAGE_RECEIVER_NOT_FOUND404Receiver user not found
MESSAGE_BOOKING_MISMATCH400Booking does not belong to receiver
MESSAGE_SUBJECT_TOO_LONG422Subject exceeds 120 characters

7. Delivery Channels

Notifications can be delivered through multiple channels:

ChannelTechnologyUse Case
PushFirebase Cloud MessagingMobile app notifications
SMSTBD (Taqnyat, Unifonic, etc.)Critical updates, OTP
EmailTBD (SendGrid, Mailgun, etc.)Receipts, confirmations

Channel selection is configured at the backend level and may vary by notification type.

8. Cross-References

Related Entities:

Notification, Message, User, Booking

Related Screens:

إشعارات (Mobile), إرسال رسالة للعميل (Admin/Provider)

Related APIs:

auth-and-users-api.md, trips-and-bookings-api.md

Related Rules:

BR-1 to BR-7 in notifications-and-messaging-module.md

Related Roles:

CUSTOMER, ADMIN, SUPER_ADMIN, PROVIDER_ADMIN, SUPPORT_AGENT