Skip to Content
HomeLink Hub
Chat

List my chat rooms

GET
/api/v1/chat/rooms

Access: Bearer token required.

Every non-deleted room the caller participates in, sorted by lastMessageAt descending (most recent conversation first). createdBy, participants and lastMessageSenderId are populated with firstName, lastName, avatar; referencedProperty with title, media, pricing.rentPrice, pricing.salePrice. There is no pagination and no projection: each room carries its entire embedded messages array (including soft-deleted messages, with senderId as a raw id), so the payload grows with conversation length. No unread count is computed; clients derive it from each message's readBy. The same payload is pushed over Socket.IO as the chat:rooms event.

Envelope: chat endpoints do not use the standard {status, success, message, data} wrapper. Success bodies are {success, data} and the handler's own 400s are {success: false, message}; only errors that fall through to the global error middleware get the standard error envelope.

Authorization

bearerAuth
headerAuthorizationBearer <JWT>

Access token returned by sign-in. Send it as Authorization: Bearer <token>.

Response Body

The caller's rooms (the messages array is trimmed to one item here)

application/json
  1. response
success*boolean
data*array<>
Example Request
curl -X GET 'http://localhost:4000/api/v1/chat/rooms'
Example Response
{  "success": true,  "data": [    {      "_id": "6660a7d49b1d4a0012ab3550",      "name": "Amaka Eze",      "isPrivate": true,      "createdBy": {        "_id": "665f1c2e9b1d4a0012ab34c4",        "firstName": "Amaka",        "lastName": "Eze",        "avatar": "https://res.cloudinary.com/example/image/upload/v1717500000/homelinkhub/media/amaka.jpg"      },      "participants": [        {          "_id": "665f1c2e9b1d4a0012ab34c4",          "firstName": "Amaka",          "lastName": "Eze",          "avatar": "https://res.cloudinary.com/example/image/upload/v1717500000/homelinkhub/media/amaka.jpg"        },        {          "_id": "665f1c2e9b1d4a0012ab34c1",          "firstName": "Chinedu",          "lastName": "Okafor",          "avatar": "https://res.cloudinary.com/example/image/upload/v1717500000/homelinkhub/media/chinedu.jpg"        }      ],      "referencedProperty": {        "_id": "665f1c2e9b1d4a0012ab34cd",        "title": "3-Bedroom Flat, Lekki Phase 1",        "pricing": {          "rentPrice": 4500000,          "salePrice": null        },        "media": {          "images": [            {              "url": "https://res.cloudinary.com/example/image/upload/v1717500000/homelinkhub/media/living-room.jpg",              "metadata": {                "address": "14 Admiralty Way, Lekki Phase 1, Lagos",                "coordinates": [                  3.4723,                  6.4474                ],                "tag": "Living room"              },              "_id": "6660a7d49b1d4a0012ab3570"            }          ],          "videos": []        }      },      "messages": [        {          "senderId": "665f1c2e9b1d4a0012ab34c4",          "content": "Good afternoon, is the flat still available for inspection this Saturday?",          "messageType": "TEXT",          "readBy": [],          "deletedAt": null,          "editedAt": null,          "replyToId": null,          "_id": "6660a7d49b1d4a0012ab3551",          "createdAt": "2026-06-05T14:02:10.107Z",          "updatedAt": "2026-06-05T14:02:10.107Z"        }      ],      "lastMessage": "Good afternoon, is the flat still available for inspection this Saturday?",      "lastMessageAt": "2026-06-05T14:02:10.107Z",      "lastMessageSenderId": {        "_id": "665f1c2e9b1d4a0012ab34c4",        "firstName": "Amaka",        "lastName": "Eze",        "avatar": "https://res.cloudinary.com/example/image/upload/v1717500000/homelinkhub/media/amaka.jpg"      },      "deletedAt": null,      "createdAt": "2026-06-04T09:15:22.481Z",      "updatedAt": "2026-06-05T14:02:10.107Z",      "__v": 0    }  ]}