Skip to main content

List All Apartments

Returns all apartments with their relationships including tipoApartamento, torre.proyecto, pisoTorre, estadoInmueble, and parqueaderos.

Response Fields

success
boolean
Indicates if the request was successful
data
array
Array of apartment objects
{
  "success": true,
  "data": [
    {
      "id_apartamento": 1,
      "numero": "101",
      "id_tipo_apartamento": 1,
      "id_torre": 1,
      "id_piso_torre": 1,
      "id_estado_inmueble": 1,
      "valor_total": "250000000.00",
      "prima_altura": "5000000.00",
      "valor_politica": "0.00",
      "valor_final": "255000000.00",
      "tipoApartamento": {
        "id_tipo_apartamento": 1,
        "nombre": "2 Habitaciones"
      },
      "torre": {
        "nombre_torre": "Torre A",
        "proyecto": {
          "nombre": "Torre del Sol"
        }
      },
      "pisoTorre": {
        "nivel": 10
      },
      "estadoInmueble": {
        "nombre": "Disponible"
      },
      "parqueaderos": []
    }
  ]
}

Get Single Apartment

Retrieve detailed information about a specific apartment with all relationships.

Path Parameters

id
integer
required
The unique identifier of the apartment
{
  "success": true,
  "data": {
    "id_apartamento": 1,
    "numero": "101",
    "valor_total": "250000000.00",
    "tipoApartamento": {
      "nombre": "2 Habitaciones",
      "area_total": "85.50"
    },
    "torre": {
      "nombre_torre": "Torre A",
      "proyecto": {
        "nombre": "Torre del Sol",
        "ubicacion": {
          "direccion": "Calle 123 #45-67",
          "ciudad": {
            "nombre": "Bogotá"
          }
        }
      }
    },
    "pisoTorre": {
      "nivel": 10
    },
    "estadoInmueble": {
      "nombre": "Disponible"
    },
    "parqueaderos": [
      {
        "id_parqueadero": 1,
        "numero": "P-101",
        "tipo": "Vehiculo"
      }
    ]
  }
}

Create Apartment

Create a new apartment. The system validates that:
  • The floor belongs to the specified tower
  • The apartment number is unique within the tower

Request Body

numero
string
required
Apartment number (max 20 characters, must be unique per tower)
id_tipo_apartamento
integer
required
Apartment type ID (must exist in tipo_apartamento table)
id_torre
integer
required
Tower ID (must exist in torre table)
id_piso_torre
integer
required
Floor ID (must exist in piso_torre table and belong to the specified tower)
id_estado_inmueble
integer
required
Property status ID (must exist in estado_inmueble table)
valor_total
decimal
Total value (min: 0)
{
  "numero": "101",
  "id_tipo_apartamento": 1,
  "id_torre": 1,
  "id_piso_torre": 1,
  "id_estado_inmueble": 1,
  "valor_total": 250000000.00
}
{
  "success": true,
  "message": "Apartamento creado exitosamente",
  "data": {
    "id_apartamento": 1,
    "numero": "101",
    "valor_total": "250000000.00"
  }
}
{
  "success": false,
  "message": "El piso seleccionado no pertenece a la torre indicada"
}
{
  "success": false,
  "message": "Ya existe un apartamento con este número en la torre seleccionada"
}

Update Apartment

Update an existing apartment. Same validation rules as creation.

Path Parameters

id
integer
required
The unique identifier of the apartment to update

Request Body

Same as Create Apartment endpoint.

Delete Apartment

Delete an apartment. Cannot delete if the apartment has associated parking spaces.

Path Parameters

id
integer
required
The unique identifier of the apartment to delete
{
  "success": false,
  "message": "No se puede eliminar el apartamento porque tiene parqueaderos asociados"
}

Change Apartment Status

Update the status of an apartment (e.g., from “Disponible” to “Vendido”).

Path Parameters

id
integer
required
The apartment ID

Request Body

id_estado_inmueble
integer
required
New property status ID
{
  "id_estado_inmueble": 2
}
{
  "success": true,
  "message": "Estado del apartamento actualizado exitosamente",
  "data": {
    "id_apartamento": 1,
    "numero": "101",
    "estadoInmueble": {
      "nombre": "Vendido"
    }
  }
}

Filter Apartments

By Tower

Also available at: /api/torres/{id_torre}/apartamentos

By Floor

Also available at: /api/pisos/{id_piso_torre}/apartamentos

By Status

By Type

By Project

Also available at: /api/proyectos/{id_proyecto}/apartamentos

Search Apartments

Search apartments by number (case-insensitive).

Request Body

termino
string
required
Search term (min 1 character)

Get Apartment Summary

Get a comprehensive summary with parking breakdown.

Path Parameters

id
integer
required
The apartment ID
{
  "success": true,
  "data": {
    "id_apartamento": 1,
    "numero": "101",
    "tipo": "2 Habitaciones",
    "torre": "Torre A",
    "piso": 10,
    "proyecto": "Torre del Sol",
    "ubicacion": "Calle 123 #45-67, Bogotá",
    "estado": "Disponible",
    "valor_total": "250000000.00",
    "parqueaderos": {
      "total": 2,
      "vehiculos": 1,
      "motos": 1
    }
  }
}

Get Apartment Statistics by Project

Get aggregated statistics for all apartments in a project.

Path Parameters

id_proyecto
integer
required
The project ID
{
  "success": true,
  "data": {
    "total_apartamentos": 120,
    "valor_total_inventario": "30000000000.00",
    "valor_promedio": "250000000.00",
    "por_estado": [
      {
        "estado": "Disponible",
        "cantidad": 60,
        "valor_total": "15000000000.00"
      },
      {
        "estado": "Vendido",
        "cantidad": 45,
        "valor_total": "11250000000.00"
      },
      {
        "estado": "Reservado",
        "cantidad": 15,
        "valor_total": "3750000000.00"
      }
    ],
    "por_tipo": [
      {
        "tipo": "2 Habitaciones",
        "cantidad": 60,
        "valor_promedio": "220000000.00"
      },
      {
        "tipo": "3 Habitaciones",
        "cantidad": 50,
        "valor_promedio": "280000000.00"
      },
      {
        "tipo": "Penthouse",
        "cantidad": 10,
        "valor_promedio": "450000000.00"
      }
    ]
  }
}

Get Available Apartments by Project

Retrieve all available apartments in a project (status contains “disponible”).

Path Parameters

id_proyecto
integer
required
The project ID

Model Structure

Database Table: apartamentos

FieldTypeNullableDescription
id_apartamentoIntegerNoPrimary key
numeroString(20)NoApartment number
id_tipo_apartamentoIntegerNoForeign key to tipo_apartamento
id_torreIntegerNoForeign key to torre
id_piso_torreIntegerNoForeign key to piso_torre
id_estado_inmuebleIntegerNoForeign key to estado_inmueble
valor_totalDecimal(18,2)YesBase value
prima_alturaDecimal(18,2)YesHeight premium
valor_politicaDecimal(18,2)YesPolicy adjustment
valor_finalDecimal(18,2)YesFinal calculated price
documentoStringYesClient document if sold

Relationships

  • BelongsTo: tipoApartamento (TipoApartamento)
  • BelongsTo: torre (Torre)
  • BelongsTo: pisoTorre (PisoTorre)
  • BelongsTo: estadoInmueble (EstadoInmueble)
  • BelongsTo: cliente (Cliente) - via documento
  • HasMany: parqueaderos (Parqueadero)
  • HasMany: ventas (Venta)

Computed Attributes

  • valor_comercial: Returns valor_total + prima_altura + valor_politica

Build docs developers (and LLMs) love