EstateHub

Customer Notifications API

Base URL: http://localhost:8000/api/v1
Prefix: /customers/notifications
Auth: JWT Bearer token for an active customer
Headers: Content-Type: application/json


1. List Notifications

Retrieve the authenticated customer’s notification history.

GET/customers/notifications/

Auth: Required

Headers

HTTP
Authorization: Bearer {{access_token}}

Success Example

HTTP 200 OK

JSON
{
  "success": true,
  "message": "Notifications retrieved successfully.",
  "data": {
    "notifications": {
      "count": 1,
      "next": null,
      "previous": null,
      "results": [
        {
          "id": "b18c23d8-7c92-492f-96a4-2c5d6d9a4d10",
          "title": "Payment verified",
          "body": "Your payment has been verified successfully.",
          "type": "payment",
          "reference_type": "payment",
          "reference_id": "8d4b6d2e-1b7f-4a4b-8f2c-1efba83f9c91",
          "is_read": false,
          "read_at": null,
          "created_at": "2026-09-14T10:00:00Z",
          "updated_at": "2026-09-14T10:00:00Z"
        }
      ]
    }
  }
}

Notes

Returns only the logged-in customer’s notifications, newest first.

Default page size: 20.

Optional query parameters:

ParameterExamplePurpose
page2Pagination
is_readfalseRead/unread filter
typepaymentNotification category

Example:

HTTP
GET {{base_url}}/customers/notifications/?is_read=false&type=payment&page=1

Valid types:

property, conversation, appointment, purchase, rental, auction, investment, payment, payout, support, system.

Invalid filters return HTTP 400. Invalid pages return HTTP 404.

Currently generated customer alerts cover:

  • Purchase reservation submitted

  • Rental application submitted

  • Reservation payment submitted

  • Purchase payment submitted

  • Lease payment submitted

  • Payment verified

  • Payment rejected

  • Cash payment recorded

  • KYC approved

  • KYC rejected

  • Appointment confirmed

  • Appointment declined

  • Appointment rescheduled

  • Appointment canceled

  • New seller or agent message

Customer notifications use:

typereference_typereference_idNotification usage
purchasepurchasePurchase UUIDPurchase reservation submitted
rentalrentalRental application UUIDRental application submitted
paymentpaymentPayment UUIDPayment submitted, verified, rejected, or cash recorded
systemkycVerification UUIDKYC approval or rejection
appointmentappointmentAppointment UUIDAppointment status changes
conversationconversationConversation UUIDNew seller or agent message

The frontend should route notifications using reference_type and reference_id:

  • purchase → customer purchase details

  • rental → customer rental application details

  • payment → customer payment details

  • kyc → customer KYC details

  • appointment → customer appointment details

  • conversation → customer conversation details


2. Unread Count

Retrieve the customer’s unread notification count.

GET/customers/notifications/unread-count/

Auth: Required

Headers

HTTP
Authorization: Bearer {{access_token}}

Success Example

HTTP 200 OK

JSON
{
  "success": true,
  "message": "Unread notification count retrieved successfully.",
  "data": {
    "unread_count": 5
  }
}

Notes

Counts only the logged-in customer’s unread notifications.

The count is independent of notification-list filters.


3. Notification Details

Retrieve one notification belonging to the customer.

GET/customers/notifications/{notification_id}/

Auth: Required

Headers

HTTP
Authorization: Bearer {{access_token}}

Success Example

HTTP 200 OK

JSON
{
  "success": true,
  "message": "Notification retrieved successfully.",
  "data": {
    "notification": {
      "id": "b18c23d8-7c92-492f-96a4-2c5d6d9a4d10",
      "title": "Payment verified",
      "body": "Your payment has been verified successfully.",
      "type": "payment",
      "reference_type": "payment",
      "reference_id": "8d4b6d2e-1b7f-4a4b-8f2c-1efba83f9c91",
      "is_read": false,
      "read_at": null,
      "created_at": "2026-09-14T10:00:00Z",
      "updated_at": "2026-09-14T10:00:00Z"
    }
  }
}

Notes

Viewing details does not mark the notification as read.

Missing notifications and notifications belonging to another user return HTTP 404.


4. Update Read State

Mark a notification as read or unread.

PATCH/customers/notifications/{notification_id}/

Auth: Required

Headers

HTTP
Authorization: Bearer {{access_token}}
Content-Type: application/json

Request Body

JSON
{
  "is_read": true
}

Success Example

HTTP 200 OK

JSON
{
  "success": true,
  "message": "Notification updated successfully.",
  "data": {
    "notification": {
      "id": "b18c23d8-7c92-492f-96a4-2c5d6d9a4d10",
      "title": "Payment verified",
      "body": "Your payment has been verified successfully.",
      "type": "payment",
      "reference_type": "payment",
      "reference_id": "8d4b6d2e-1b7f-4a4b-8f2c-1efba83f9c91",
      "is_read": true,
      "read_at": "2026-09-14T10:05:00Z",
      "created_at": "2026-09-14T10:00:00Z",
      "updated_at": "2026-09-14T10:05:00Z"
    },
    "unread_count": 0
  }
}

Notes

is_read is required.

Use false to mark the notification unread and clear read_at.

Repeating the current state preserves the timestamp and does not broadcast another event.

State changes broadcast notification.updated to the customer’s connected tabs or devices.

Invalid or missing is_read returns HTTP 400.

Missing or other-user notification IDs return HTTP 404.


5. Mark All Read

Mark all currently unread notifications belonging to the customer as read.

POST/customers/notifications/read-all/

Auth: Required

Headers

HTTP
Authorization: Bearer {{access_token}}

Success Example

HTTP 200 OK

JSON
{
  "success": true,
  "message": "Notifications marked as read successfully.",
  "data": {
    "updated": 5,
    "unread_count": 0
  }
}

Notes

No request body is required.

Other customers’ read states remain independent.

The server broadcasts notifications.read_all when records change.

New notifications can make the returned unread count nonzero.


6. Live Notification Connection

Receive notification events through WebSockets.

WebSocketws://localhost:8000/ws/customers/notifications/?token={access_token}

Auth: Required

Success Example

A new notification arrives as:

JSON
{
  "type": "notification.created",
  "notification": {
    "id": "b18c23d8-7c92-492f-96a4-2c5d6d9a4d10",
    "title": "Appointment confirmed",
    "body": "Your appointment for Downtown Apartment has been confirmed by the seller.",
    "type": "appointment",
    "reference_type": "appointment",
    "reference_id": "8d4b6d2e-1b7f-4a4b-8f2c-1efba83f9c91",
    "is_read": false,
    "read_at": null,
    "created_at": "2026-09-24T10:00:00Z",
    "updated_at": "2026-09-24T10:00:00Z"
  },
  "unread_count": 1
}

Notes

Use the server’s root URL without ``.

Use wss:// with HTTPS deployments.

The connection joins the authenticated customer’s private group automatically.

WebSocket events do not use the REST success/message/data envelope.

EventPayload
notification.creatednotification, unread_count
notification.updatedUpdated notification, unread_count
notifications.read_allread_at, updated, unread_count

Read-all event example:

JSON
{
  "type": "notifications.read_all",
  "read_at": "2026-09-14T10:05:00+00:00",
  "updated": 5,
  "unread_count": 0
}

Perform read/unread updates through REST. Sending client messages over this socket returns:

JSON
{
  "type": "error",
  "message": "Use REST APIs to update notifications."
}

Invalid authentication or unavailable customer access closes the connection with code 4403.

Customer access is rechecked on incoming messages and outgoing events.

Notifications persist before broadcasting. Failed live delivery does not undo the saved notification.

After connecting or reconnecting, fetch history and unread count through REST. Missed events are not automatically replayed.

Deduplicate displayed notifications by ID.


Common Success Format

REST endpoints use:

JSON
{
  "success": true,
  "message": "Operation completed successfully.",
  "data": {}
}

Common Error Format

HTTP 400 — validation error:

JSON
{
  "success": false,
  "message": "Validation failed.",
  "errors": {
    "is_read": [
      "This field is required."
    ]
  }
}

HTTP 401 — missing authentication:

JSON
{
  "success": false,
  "message": "Authentication credentials were not provided.",
  "errors": {}
}

Invalid or expired tokens also return HTTP 401 with token-specific error details.

HTTP 403 — insufficient permissions:

JSON
{
  "success": false,
  "message": "You do not have permission to perform this action.",
  "errors": {}
}

Non-customer, inactive, blocked, and deleted accounts cannot access these APIs.

HTTP 404 — missing or other-user notification:

JSON
{
  "success": false,
  "message": "Notification not found.",
  "errors": {}
}

Malformed JSON returns HTTP 400.

Unsupported methods return HTTP 405.

Unsupported request content types may return HTTP 415.