Skip to main content

Overview

Greenhouses are physical structures that belong to a tenant. Each greenhouse contains sensors, actuators, and sectors for monitoring and controlling environmental conditions.

Get All Greenhouses for Tenant

curl -X GET "https://api.invernaderos.com/api/v1/tenants/1/greenhouses" \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieve all greenhouses belonging to a specific tenant.

Path Parameters

tenantId
long
required
Unique identifier of the tenant

Response

id
long
Unique identifier of the greenhouse
code
string
Unique readable code (e.g., “GRH-00001”)
name
string
Greenhouse name
tenantId
long
ID of the tenant that owns this greenhouse
location
object
Geographic coordinates
lat
double
Latitude
lon
double
Longitude
areaM2
decimal
Area in square meters
timezone
string
Timezone (e.g., “Europe/Madrid”)
isActive
boolean
Whether the greenhouse is active
createdAt
timestamp
Creation timestamp (ISO 8601)
updatedAt
timestamp
Last update timestamp (ISO 8601)
[
  {
    "id": 1,
    "code": "GRH-00001",
    "name": "Invernadero Principal",
    "tenantId": 1,
    "location": {
      "lat": 36.8381,
      "lon": -2.4597
    },
    "areaM2": 1500.50,
    "timezone": "Europe/Madrid",
    "isActive": true,
    "createdAt": "2025-03-01T10:00:00Z",
    "updatedAt": "2025-03-01T10:00:00Z"
  }
]

Get Greenhouse by ID

curl -X GET "https://api.invernaderos.com/api/v1/tenants/1/greenhouses/1" \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieve a specific greenhouse belonging to a tenant.

Path Parameters

tenantId
long
required
Unique identifier of the tenant
greenhouseId
long
required
Unique identifier of the greenhouse

Response

{
  "id": 1,
  "code": "GRH-00001",
  "name": "Invernadero Principal",
  "tenantId": 1,
  "location": {
    "lat": 36.8381,
    "lon": -2.4597
  },
  "areaM2": 1500.50,
  "timezone": "Europe/Madrid",
  "isActive": true,
  "createdAt": "2025-03-01T10:00:00Z",
  "updatedAt": "2025-03-01T10:00:00Z"
}

Create Greenhouse

curl -X POST "https://api.invernaderos.com/api/v1/tenants/1/greenhouses" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Invernadero Principal",
    "location": {
      "lat": 36.8381,
      "lon": -2.4597
    },
    "areaM2": 1500.50,
    "timezone": "Europe/Madrid",
    "isActive": true
  }'
Create a new greenhouse for a tenant.

Path Parameters

tenantId
long
required
Unique identifier of the tenant

Request Body

name
string
required
Greenhouse name
location
object
Geographic coordinates
lat
double
Latitude
lon
double
Longitude
areaM2
decimal
Area in square meters
timezone
string
default:"Europe/Madrid"
Timezone identifier
isActive
boolean
default:"true"
Whether the greenhouse is active

Response

{
  "id": 2,
  "code": "GRH-00002",
  "name": "Invernadero Principal",
  "tenantId": 1,
  "location": {
    "lat": 36.8381,
    "lon": -2.4597
  },
  "areaM2": 1500.50,
  "timezone": "Europe/Madrid",
  "isActive": true,
  "createdAt": "2025-03-03T21:35:00Z",
  "updatedAt": "2025-03-03T21:35:00Z"
}

Update Greenhouse

curl -X PUT "https://api.invernaderos.com/api/v1/tenants/1/greenhouses/1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Invernadero Principal - Actualizado",
    "areaM2": 1600.00
  }'
Update an existing greenhouse. All fields are optional.

Path Parameters

tenantId
long
required
Unique identifier of the tenant
greenhouseId
long
required
Unique identifier of the greenhouse to update

Request Body

All fields are optional. Only provided fields will be updated.
name
string
Greenhouse name
location
object
Geographic coordinates
areaM2
decimal
Area in square meters
timezone
string
Timezone identifier
isActive
boolean
Whether the greenhouse is active

Response

{
  "id": 1,
  "code": "GRH-00001",
  "name": "Invernadero Principal - Actualizado",
  "tenantId": 1,
  "location": {
    "lat": 36.8381,
    "lon": -2.4597
  },
  "areaM2": 1600.00,
  "timezone": "Europe/Madrid",
  "isActive": true,
  "createdAt": "2025-03-01T10:00:00Z",
  "updatedAt": "2025-03-03T21:40:00Z"
}

Delete Greenhouse

curl -X DELETE "https://api.invernaderos.com/api/v1/tenants/1/greenhouses/1" \
  -H "Authorization: Bearer YOUR_TOKEN"
Delete a greenhouse from a tenant.

Path Parameters

tenantId
long
required
Unique identifier of the tenant
greenhouseId
long
required
Unique identifier of the greenhouse to delete

Response

# Successfully deleted

MQTT Topic Mapping

Each greenhouse is associated with an MQTT topic for receiving sensor data:

Topic Structure

GREENHOUSE/{tenantId}
Examples:
  • GREENHOUSE/SARA - Vivero Sara’s greenhouse data
  • GREENHOUSE/001 - Generic tenant with ID 001
  • GREENHOUSE/DEFAULT - Legacy format (backward compatible)

Data Flow

  1. Sensor devices publish data to the MQTT topic
  2. API receives messages via MQTT subscriber
  3. Data is cached in Redis (last 1000 messages, 24h TTL)
  4. Data is persisted in TimescaleDB time-series database
  5. WebSocket broadcast sends real-time updates to connected clients

Sensor Data Structure

Greenhouse sensor messages contain 22 fields:
  • TEMPERATURA INVERNADERO 01 - Temperature for greenhouse 1 (°C)
  • HUMEDAD INVERNADERO 01 - Humidity for greenhouse 1 (%)
  • TEMPERATURA INVERNADERO 02 - Temperature for greenhouse 2 (°C)
  • HUMEDAD INVERNADERO 02 - Humidity for greenhouse 2 (%)
  • TEMPERATURA INVERNADERO 03 - Temperature for greenhouse 3 (°C)
  • HUMEDAD INVERNADERO 03 - Humidity for greenhouse 3 (%)

Sectors and Devices

Each greenhouse can contain:
  • Sectors: Physical zones within the greenhouse for monitoring specific areas
  • Sensors: Temperature, humidity, soil moisture, light intensity, CO2 levels
  • Actuators: Irrigation systems, ventilation fans, heating/cooling units
These are managed through separate endpoints (see related resources below).

Build docs developers (and LLMs) love