Skip to content

Rooms API

Manage rooms within an organization — create, list, retrieve, update availability, and delete.

Authentication

All endpoints require a valid Bearer token in the Authorization header.

Endpoints

MethodPathDescription
POST/api/rooms/:orgId/createCreate a new room
GET/api/rooms/:orgId/listList all rooms
GET/api/rooms/:orgId/overviewGet rooms overview / stats
GET/api/rooms/:orgId/by-number/:roomNoGet room by room number
GET/api/rooms/:orgId/:roomIdGet room by ID
PUT/api/rooms/:orgId/:roomId/availableToggle room availability
PUT/api/rooms/:orgId/:roomId/updateUpdate room details
DELETE/api/rooms/:orgId/:roomId/deleteDelete a room

Path Parameters

ParameterTypeDescription
orgIdstringOrganization ID
roomIdstringRoom document ID
roomNostringRoom number (e.g. 101, A-201)

Create Room

POST /api/rooms/:orgId/create

Request Body

json
{
  "roomNumber": "301",
  "categoryId": "64f1b2c3d4e5f6a7b8c9d0e1",
  "floor": 3,
  "description": "Ocean-view deluxe room with balcony",
  "amenities": ["wifi", "minibar", "balcony", "air-conditioning"],
  "maxOccupancy": 3,
  "basePrice": 7500,
  "isAvailable": true
}

Success Response 201

json
{
  "success": true,
  "message": "Room created successfully",
  "data": {
    "_id": "64f1b2c3d4e5f6a7b8c9d0e2",
    "roomNumber": "301",
    "categoryId": {
      "_id": "64f1b2c3d4e5f6a7b8c9d0e1",
      "name": "Deluxe Suite"
    },
    "floor": 3,
    "description": "Ocean-view deluxe room with balcony",
    "amenities": ["wifi", "minibar", "balcony", "air-conditioning"],
    "maxOccupancy": 3,
    "basePrice": 7500,
    "isAvailable": true,
    "orgId": "64f1b2c3d4e5f6a7b8c9d0e0",
    "createdAt": "2026-02-20T10:00:00.000Z",
    "updatedAt": "2026-02-20T10:00:00.000Z"
  }
}

Error Response 400

json
{
  "success": false,
  "message": "Validation error",
  "errors": [
    "roomNumber is required",
    "categoryId is required"
  ]
}

Error Response 409

json
{
  "success": false,
  "message": "Room with number 301 already exists"
}

List Rooms

GET /api/rooms/:orgId/list

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber10Results per page
searchstringSearch by room number or description
categoryIdstringFilter by room category
floornumberFilter by floor number
availablebooleanFilter by availability (true/false)

Success Response 200

json
{
  "success": true,
  "data": [
    {
      "_id": "64f1b2c3d4e5f6a7b8c9d0e2",
      "roomNumber": "301",
      "categoryId": {
        "_id": "64f1b2c3d4e5f6a7b8c9d0e1",
        "name": "Deluxe Suite"
      },
      "floor": 3,
      "maxOccupancy": 3,
      "basePrice": 7500,
      "isAvailable": true
    }
  ],
  "pagination": {
    "total": 50,
    "page": 1,
    "limit": 10,
    "totalPages": 5
  }
}

Rooms Overview

GET /api/rooms/:orgId/overview

Returns aggregate statistics about the room inventory.

Success Response 200

json
{
  "success": true,
  "data": {
    "totalRooms": 50,
    "available": 32,
    "occupied": 15,
    "underMaintenance": 3,
    "byCategory": [
      { "category": "Deluxe Suite", "count": 15 },
      { "category": "Standard", "count": 20 },
      { "category": "Premium", "count": 15 }
    ],
    "byFloor": [
      { "floor": 1, "count": 12 },
      { "floor": 2, "count": 14 },
      { "floor": 3, "count": 12 },
      { "floor": 4, "count": 12 }
    ]
  }
}

Get Room by Number

GET /api/rooms/:orgId/by-number/:roomNo

Success Response 200

json
{
  "success": true,
  "data": {
    "_id": "64f1b2c3d4e5f6a7b8c9d0e2",
    "roomNumber": "301",
    "categoryId": {
      "_id": "64f1b2c3d4e5f6a7b8c9d0e1",
      "name": "Deluxe Suite"
    },
    "floor": 3,
    "description": "Ocean-view deluxe room with balcony",
    "amenities": ["wifi", "minibar", "balcony", "air-conditioning"],
    "maxOccupancy": 3,
    "basePrice": 7500,
    "isAvailable": true,
    "createdAt": "2026-02-20T10:00:00.000Z",
    "updatedAt": "2026-02-20T10:00:00.000Z"
  }
}

Error Response 404

json
{
  "success": false,
  "message": "Room not found"
}

Get Room by ID

GET /api/rooms/:orgId/:roomId

Success Response 200

Same structure as Get Room by Number.

Error Response 404

json
{
  "success": false,
  "message": "Room not found"
}

Toggle Room Availability

PUT /api/rooms/:orgId/:roomId/available

Request Body

json
{
  "isAvailable": false,
  "reason": "Under maintenance"
}

Success Response 200

json
{
  "success": true,
  "message": "Room availability updated",
  "data": {
    "_id": "64f1b2c3d4e5f6a7b8c9d0e2",
    "roomNumber": "301",
    "isAvailable": false,
    "updatedAt": "2026-02-21T08:30:00.000Z"
  }
}

Error Response 404

json
{
  "success": false,
  "message": "Room not found"
}

Update Room

PUT /api/rooms/:orgId/:roomId/update

Request Body

json
{
  "description": "Renovated ocean-view deluxe room with private balcony",
  "amenities": ["wifi", "minibar", "balcony", "air-conditioning", "smart-tv"],
  "maxOccupancy": 4,
  "basePrice": 8500
}

Success Response 200

json
{
  "success": true,
  "message": "Room updated successfully",
  "data": {
    "_id": "64f1b2c3d4e5f6a7b8c9d0e2",
    "roomNumber": "301",
    "description": "Renovated ocean-view deluxe room with private balcony",
    "amenities": ["wifi", "minibar", "balcony", "air-conditioning", "smart-tv"],
    "maxOccupancy": 4,
    "basePrice": 8500,
    "updatedAt": "2026-02-21T09:00:00.000Z"
  }
}

Error Response 404

json
{
  "success": false,
  "message": "Room not found"
}

Delete Room

DELETE /api/rooms/:orgId/:roomId/delete

Success Response 200

json
{
  "success": true,
  "message": "Room deleted successfully"
}

Error Response 404

json
{
  "success": false,
  "message": "Room not found"
}

Error Response 409

json
{
  "success": false,
  "message": "Cannot delete room with active bookings"
}

Released under the MIT License.