Skip to main content

Overview

The Building Floor Plan API provides comprehensive device management for building infrastructure including PCs, servers, network equipment, and security cameras. Features include interactive positioning on floor plans, encrypted credential storage, and detailed device tracking.

Get All Devices

Retrieve all devices for the interactive floor plan with optional filtering.
GET /api/plano-edificio/devices

Required Permissions

  • ver-plano-edificio

Query Parameters

tipos
array
Filter by device types. Available types:
  • pc - Personal Computer
  • puesto_cecoco - CECOCO Workstation
  • puesto_video - Video Workstation
  • router - Router
  • switch - Network Switch
  • camara_interna - Internal Camera
  • servidor - Server
  • servidor_cecoco - CECOCO Server
  • servidor_nebula - Nebula Server
  • grabador_nebula - Nebula Recorder
  • nvr - Network Video Recorder
  • access_point - Wireless Access Point
oficina
string
Filter by office name (partial match supported)
piso
string
Filter by floor level
activo
boolean
Filter by active status (“true” or “false”)

Response

success
boolean
Indicates if the request was successful
data
array
Array of device objects
total
integer
Total number of devices returned

Device Object Fields

id
integer
Unique device identifier
tipo
string
Device type code (e.g., “pc”, “router”, “servidor”)
nombre
string
Device name
ip
string
IP address
mac
string
MAC address
marca
string
Device brand/manufacturer
modelo
string
Device model
serie
string
Serial number
oficina
string
Office location
piso
string
Floor level
posicion_x
decimal
X coordinate on floor plan (0-100, percentage-based)
posicion_y
decimal
Y coordinate on floor plan (0-100, percentage-based)
sistema_operativo
string
Operating system (required for PCs and servers)
puertos
integer
Number of ports (required for routers, switches, access points)
observaciones
text
Additional notes
activo
boolean
Device active status
tiene_credenciales
boolean
Indicates if device has stored credentials
icono
string
FontAwesome icon class for the device type
color
string
Hex color code for the device type
tipo_label
string
Human-readable device type label
created_at
string
Creation timestamp (format: d/m/Y H:i)
updated_at
string
Last update timestamp (format: d/m/Y H:i)

Example Request

curl -X GET "https://your-domain.com/api/plano-edificio/devices?tipos[]=servidor&tipos[]=router&activo=true" \
  -H "Cookie: your-session-cookie"

Example Response

{
  "success": true,
  "data": [
    {
      "id": 1,
      "tipo": "servidor",
      "nombre": "SRV-CECOCO-01",
      "ip": "192.168.1.10",
      "mac": "00:1A:2B:3C:4D:5E",
      "marca": "Dell",
      "modelo": "PowerEdge R740",
      "serie": "ABC123456",
      "oficina": "CECOCO Principal",
      "piso": "2",
      "posicion_x": 45.5000,
      "posicion_y": 30.2500,
      "sistema_operativo": "Windows Server 2019",
      "puertos": null,
      "observaciones": "Servidor principal de aplicaciones",
      "activo": true,
      "tiene_credenciales": true,
      "icono": "fas fa-server",
      "color": "#6f42c1",
      "tipo_label": "Servidor",
      "created_at": "04/03/2026 10:30",
      "updated_at": "04/03/2026 14:15"
    }
  ],
  "total": 1
}

Get Single Device

Retrieve detailed information for a specific device.
GET /api/plano-edificio/devices/{id}

Required Permissions

  • ver-plano-edificio
  • credenciales-plano-edificio (optional, for viewing credentials)

Path Parameters

id
integer
required
The device ID

Response

Same as device object in Get All Devices, with additional fields:
username
string
Device username (only visible with credenciales-plano-edificio permission)
password
string
Device password - automatically decrypted (only visible with credenciales-plano-edificio permission)
created_by
string
Name of user who created the device
updated_by
string
Name of user who last updated the device

Example Request

curl -X GET "https://your-domain.com/api/plano-edificio/devices/1" \
  -H "Cookie: your-session-cookie"

Create Device

Create a new device in the building floor plan.
POST /api/plano-edificio/devices

Required Permissions

  • crear-plano-edificio
  • credenciales-plano-edificio (optional, for storing credentials)

Request Body

tipo
string
required
Device type. Must be one of: pc, puesto_cecoco, puesto_video, router, switch, camara_interna, servidor, servidor_cecoco, servidor_nebula, grabador_nebula, nvr, access_point
nombre
string
required
Device name (max 200 characters)
ip
string
Valid IP address
mac
string
MAC address in format: XX:XX:XX:XX:XX:XX or XX-XX-XX-XX-XX-XX
marca
string
Brand/manufacturer (max 100 characters)
modelo
string
Model name (max 100 characters)
serie
string
Serial number (max 100 characters)
oficina
string
required
Office location (max 200 characters)
piso
string
Floor level (max 50 characters)
posicion_x
decimal
X coordinate on floor plan (0-100)
posicion_y
decimal
Y coordinate on floor plan (0-100)
sistema_operativo
string
Operating system (max 100 characters). Required for types: pc, servidor, servidor_cecoco, servidor_nebula
puertos
integer
Number of ports (1-48). Required for types: router, switch, access_point
username
string
Device access username (max 255 characters). Requires credenciales-plano-edificio permission.
password
string
Device access password (max 2048 characters). Automatically encrypted before storage. Requires credenciales-plano-edificio permission.
observaciones
text
Additional notes (max 1000 characters)
activo
boolean
default:"true"
Device active status

Example Request

curl -X POST "https://your-domain.com/api/plano-edificio/devices" \
  -H "Content-Type: application/json" \
  -H "Cookie: your-session-cookie" \
  -d '{
    "tipo": "servidor",
    "nombre": "SRV-CECOCO-02",
    "ip": "192.168.1.11",
    "mac": "00:1A:2B:3C:4D:5F",
    "marca": "HP",
    "modelo": "ProLiant DL380",
    "serie": "DEF789012",
    "oficina": "CECOCO Principal",
    "piso": "2",
    "posicion_x": 50.0,
    "posicion_y": 35.5,
    "sistema_operativo": "Windows Server 2022",
    "username": "admin",
    "password": "SecurePass123!",
    "observaciones": "Servidor de respaldo",
    "activo": true
  }'

Response

{
  "success": true,
  "message": "Dispositivo creado correctamente",
  "data": {
    "id": 2,
    "tipo": "servidor",
    "nombre": "SRV-CECOCO-02",
    // ... other fields
  }
}
Passwords are automatically encrypted using Laravel’s Crypt::encryptString() before storage. You cannot retrieve the plain text password later without the credenciales-plano-edificio permission.

Update Device

Update an existing device.
PUT /api/plano-edificio/devices/{id}

Required Permissions

  • editar-plano-edificio
  • credenciales-plano-edificio (optional, for updating credentials)

Path Parameters

id
integer
required
The device ID to update

Request Body

Same parameters as Create Device. All fields can be updated.

Example Request

curl -X PUT "https://your-domain.com/api/plano-edificio/devices/1" \
  -H "Content-Type: application/json" \
  -H "Cookie: your-session-cookie" \
  -d '{
    "tipo": "servidor",
    "nombre": "SRV-CECOCO-01-Updated",
    "ip": "192.168.1.10",
    "sistema_operativo": "Windows Server 2022",
    "activo": true
  }'

Response

{
  "success": true,
  "message": "Dispositivo actualizado correctamente",
  "data": {
    // updated device object
  }
}

Update Device Position

Update only the position coordinates of a device on the floor plan.
PUT /api/plano-edificio/devices/{id}/position

Required Permissions

  • posicionar-plano-edificio

Path Parameters

id
integer
required
The device ID

Request Body

posicion_x
decimal
required
X coordinate (0-100)
posicion_y
decimal
required
Y coordinate (0-100)

Example Request

curl -X PUT "https://your-domain.com/api/plano-edificio/devices/1/position" \
  -H "Content-Type: application/json" \
  -H "Cookie: your-session-cookie" \
  -d '{
    "posicion_x": 55.25,
    "posicion_y": 42.80
  }'

Response

{
  "success": true,
  "message": "Posición actualizada correctamente",
  "data": {
    // device object with updated position
  }
}
This endpoint is optimized for interactive drag-and-drop functionality. It only updates the position fields and the updated_by timestamp, making it faster than a full device update.

Delete Device

Delete a device from the system.
DELETE /api/plano-edificio/devices/{id}

Required Permissions

  • borrar-plano-edificio

Path Parameters

id
integer
required
The device ID to delete

Response

{
  "success": true,
  "message": "Dispositivo eliminado correctamente"
}

Example Request

curl -X DELETE "https://your-domain.com/api/plano-edificio/devices/1" \
  -H "Cookie: your-session-cookie"
Devices use soft deletes, so they are not permanently removed from the database. They can be restored if needed.

Get Device Credentials

Retrieve the stored credentials for a device.
GET /api/plano-edificio/devices/{id}/credentials

Required Permissions

  • credenciales-plano-edificio

Path Parameters

id
integer
required
The device ID

Response

success
boolean
Indicates if credentials were retrieved
data
object
Object containing username and decrypted password

Example Request

curl -X GET "https://your-domain.com/api/plano-edificio/devices/1/credentials" \
  -H "Cookie: your-session-cookie"

Success Response

{
  "success": true,
  "data": {
    "username": "admin",
    "password": "SecurePass123!"
  }
}

Error Response (No Credentials)

{
  "success": false,
  "message": "El dispositivo no tiene credenciales almacenadas"
}
This endpoint automatically decrypts stored passwords using Laravel’s Crypt::decryptString(). Access is restricted to users with the credenciales-plano-edificio permission.

Export Devices to Excel

Export devices to an Excel file with optional filtering.
GET /api/plano-edificio/export

Required Permissions

  • exportar-plano-edificio

Query Parameters

tipos
array
Filter by device types
oficina
string
Filter by office
piso
string
Filter by floor
activo
boolean
Filter by active status

Response

Downloads an Excel file named DispositivosEdificio_{timestamp}.xlsx.
Credentials are only included in the export if the user has the credenciales-plano-edificio permission. Otherwise, those columns will be empty.

Example Request

curl -X GET "https://your-domain.com/api/plano-edificio/export?tipos[]=servidor&activo=true" \
  -H "Cookie: your-session-cookie" \
  -o devices_export.xlsx

Device Types Reference

TypeLabelIconRequired Fields
pcPCfas fa-desktopsistema_operativo
puesto_cecocoPuesto CECOCOfas fa-headset-
puesto_videoPuesto de Videofas fa-video-
routerRouterfas fa-wifipuertos
switchSwitchfas fa-network-wiredpuertos
camara_internaCámara Internafas fa-video-
servidorServidorfas fa-serversistema_operativo
servidor_cecocoServidor CECOCOfas fa-serversistema_operativo
servidor_nebulaServidor Nebulafas fa-cloudsistema_operativo
grabador_nebulaGrabador Nebulafas fa-record-vinyl-
nvrNVRfas fa-hdd-
access_pointAccess Pointfas fa-broadcast-towerpuertos

Operating Systems

Supported operating systems for PCs and servers:
  • Windows 10
  • Windows 11
  • Windows Server 2012 R2
  • Windows Server 2019
  • Windows Server 2022
  • Ubuntu 20.04
  • Ubuntu 22.04
  • CentOS 7
  • CentOS 8
  • Debian 10
  • Debian 11
  • Otro (Other)

Error Codes

422
Validation Error
Validation failed. Common errors:
  • Invalid device type
  • Missing required fields based on device type
  • Invalid IP or MAC format
  • Position coordinates out of range (0-100)
  • Ports out of range (1-48)
403
Forbidden
Missing required permission for the operation
404
Not Found
Device not found or device has no credentials
500
Server Error
Database transaction failed:
{
  "success": false,
  "message": "Error al crear dispositivo: {error details}"
}

Security Features

Password Encryption

All device passwords are automatically encrypted before storage using Laravel’s encryption:
public function setPasswordAttribute($value)
{
    if ($value !== null && $value !== '') {
        $this->attributes['password'] = Crypt::encryptString($value);
    }
}

Permission-Based Access

The API implements granular permissions:
  • ver-plano-edificio - View devices
  • crear-plano-edificio - Create devices
  • editar-plano-edificio - Update devices
  • posicionar-plano-edificio - Update device positions
  • borrar-plano-edificio - Delete devices
  • credenciales-plano-edificio - View/edit credentials
  • exportar-plano-edificio - Export to Excel

Audit Trail

All devices track:
  • created_by - User who created the device
  • updated_by - User who last modified the device
  • created_at - Creation timestamp
  • updated_at - Last modification timestamp
  • Soft deletes for recovery

Interactive Floor Plan

The floor plan uses a percentage-based coordinate system (0-100) for both X and Y axes:
  • posicion_x: Horizontal position (0 = left edge, 100 = right edge)
  • posicion_y: Vertical position (0 = top edge, 100 = bottom edge)
This allows the floor plan to be responsive and scale to different screen sizes while maintaining relative device positions.

Example: Positioning Devices

// Center of floor plan
const centerDevice = {
  posicion_x: 50.0,
  posicion_y: 50.0
};

// Top-left corner
const topLeftDevice = {
  posicion_x: 10.0,
  posicion_y: 10.0
};

// Bottom-right corner
const bottomRightDevice = {
  posicion_x: 90.0,
  posicion_y: 90.0
};

Build docs developers (and LLMs) love