Skip to Content
HomeLink Hub
Chat

Create or fetch a chat room for a property

POST
/api/v1/chat/rooms

Access: Bearer token required.

Creates a conversation about a property, or returns the existing one. Rooms are unique per (createdBy, referencedProperty): the call is an atomic upsert, so if the caller already has a room for that property the existing room is returned unchanged (the name, participants and isPrivate sent are ignored) and the status is still 201. On first creation the participants are the caller plus the ids in participants. Unlike the Socket.IO chat:create_and_send event, this endpoint does not add the property's agent or landlord automatically, does not check that the property or the participant users exist, and sends no notification. After the upsert, each of the caller and the listed participants is sent a chat:rooms socket event on their personal room (user:<id>) carrying their full, refreshed room list. data is the room with createdBy, participants (firstName, lastName, avatar) and referencedProperty (title, media, pricing.rentPrice, pricing.salePrice) populated, and it includes the room's whole embedded messages array. Malformed ObjectIds in referencedProperty or participants are not validated and surface as a 500. name is required by the model but not enforced on this path.

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>.

Request Body

application/json
  1. body
referencedProperty*string

ObjectId of the property the conversation is about.

name?string

Room display name (the socket flow uses the creator's full name). Only applied when the room is first created.

participants?array<unknown>

Array of user ObjectId strings to add alongside the caller, normally the property's agent or landlord. Defaults to []. Only applied when the room is first created.

isPrivate?boolean

Defaults to true. Only applied when the room is first created.

Response Body

Room created, or the caller's existing room for this property returned

application/json
  1. response
success*boolean
data*
Example Request
curl -X POST 'http://localhost:4000/api/v1/chat/rooms' \  -H 'Content-Type: application/json' \  -d '{  "name": "Amaka Eze",  "participants": [    "665f1c2e9b1d4a0012ab34c1"  ],  "referencedProperty": "665f1c2e9b1d4a0012ab34cd"}'
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": [],    "lastMessage": null,    "lastMessageAt": null,    "lastMessageSenderId": null,    "deletedAt": null,    "createdAt": "2026-06-04T09:15:22.481Z",    "updatedAt": "2026-06-04T09:15:22.481Z",    "__v": 0  }}