Skip to main content

Overview

The Data Types catalog defines how to interpret and validate configuration values in the Invernaderos system. Each data type specifies validation rules, regex patterns, and display properties for settings configuration. Supported Types: INTEGER, LONG, DOUBLE, BOOLEAN, STRING, DATE, TIME, DATETIME, JSON

Get All Data Types

curl -X GET "https://api.invernaderos.com/api/v1/catalog/data-types" \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieves all data types ordered by display order.

Response

data
array
Array of data type objects
[
  {
    "id": 1,
    "name": "INTEGER",
    "description": "Whole number (32-bit)",
    "validationRegex": "^-?\\d+$",
    "exampleValue": "25",
    "displayOrder": 1,
    "isActive": true
  },
  {
    "id": 2,
    "name": "DOUBLE",
    "description": "Decimal number (64-bit)",
    "validationRegex": "^-?\\d+(\\.\\d+)?$",
    "exampleValue": "25.5",
    "displayOrder": 2,
    "isActive": true
  },
  {
    "id": 3,
    "name": "BOOLEAN",
    "description": "True/false value",
    "validationRegex": "^(true|false|1|0)$",
    "exampleValue": "true",
    "displayOrder": 3,
    "isActive": true
  }
]

Get Active Data Types

curl -X GET "https://api.invernaderos.com/api/v1/catalog/data-types/active" \
  -H "Authorization: Bearer YOUR_TOKEN"
Retrieves only active data types (where isActive = true).

Response

Same structure as “Get All Data Types”, but filtered to active types only.

Get Data Type by ID

curl -X GET "https://api.invernaderos.com/api/v1/catalog/data-types/1" \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

id
short
required
Data type ID

Response

{
  "id": 1,
  "name": "INTEGER",
  "description": "Whole number (32-bit)",
  "validationRegex": "^-?\\d+$",
  "exampleValue": "25",
  "displayOrder": 1,
  "isActive": true
}

Get Data Type by Name

curl -X GET "https://api.invernaderos.com/api/v1/catalog/data-types/name/INTEGER" \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

name
string
required
Data type name (case-insensitive, e.g., “INTEGER”, “BOOLEAN”)

Response

Same structure as “Get Data Type by ID”.

Validate Value

curl -X GET "https://api.invernaderos.com/api/v1/catalog/data-types/1/validate?value=25" \
  -H "Authorization: Bearer YOUR_TOKEN"
Validates whether a value is valid for a specific data type.

Path Parameters

id
short
required
Data type ID

Query Parameters

value
string
required
Value to validate

Response

{
  "dataTypeId": 1,
  "value": "25",
  "isValid": true
}

Validation Rules

Data TypeValidation LogicExamples
INTEGERMust parse as 32-bit integer25, -100, 0
LONGMust parse as 64-bit integer1234567890, -999
DOUBLEMust parse as decimal number25.5, -10.75, 0.0
BOOLEANMust be “true”, “false”, “1”, or “0”true, false, 1, 0
STRINGAny string is valid"hello", "123", ""
DATEMust parse as ISO-8601 date2025-03-15
TIMEMust parse as ISO-8601 time14:30:00, 09:15:30
DATETIMEMust parse as ISO-8601 datetime2025-03-15T14:30:00
JSONMust start with { or [ and end with } or ]{"key": "value"}, [1, 2, 3]
CustomUses validationRegex if definedRegex pattern dependent

Create Data Type

curl -X POST "https://api.invernaderos.com/api/v1/catalog/data-types" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "PERCENTAGE",
    "description": "Value between 0-100",
    "validationRegex": "^(100|[1-9]?[0-9])$",
    "exampleValue": "75",
    "displayOrder": 10,
    "isActive": true
  }'

Request Body

name
string
required
Type name (max 20 characters, will be converted to uppercase, must be unique)
description
string
Description of the data type
validationRegex
string
Regular expression for value validation (must be valid regex)
exampleValue
string
Example of a valid value
displayOrder
short
default:"0"
Sort order for UI display (minimum 0)
isActive
boolean
default:"true"
Whether the data type is active

Response

{
  "id": 10,
  "name": "PERCENTAGE",
  "description": "Value between 0-100",
  "validationRegex": "^(100|[1-9]?[0-9])$",
  "exampleValue": "75",
  "displayOrder": 10,
  "isActive": true
}

Update Data Type

curl -X PUT "https://api.invernaderos.com/api/v1/catalog/data-types/10" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Value between 0-100 with decimals",
    "validationRegex": "^(100|[1-9]?[0-9])(\\.[0-9]+)?$",
    "exampleValue": "75.5"
  }'

Path Parameters

id
short
required
Data type ID to update

Request Body

All fields are optional. Only provided fields will be updated.
name
string
New type name (max 20 characters, will be converted to uppercase)
description
string
New description
validationRegex
string
New validation regex (must be valid)
exampleValue
string
New example value
displayOrder
short
New display order (minimum 0)
isActive
boolean
New active status

Response

{
  "id": 10,
  "name": "PERCENTAGE",
  "description": "Value between 0-100 with decimals",
  "validationRegex": "^(100|[1-9]?[0-9])(\\.[0-9]+)?$",
  "exampleValue": "75.5",
  "displayOrder": 10,
  "isActive": true
}

Delete Data Type

curl -X DELETE "https://api.invernaderos.com/api/v1/catalog/data-types/10" \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

id
short
required
Data type ID to delete

Response

Data type deleted successfully (no body)
System Data Types (IDs 1-9) Cannot Be DeletedThe first 9 data types are core system types and are protected from deletion:
  • INTEGER, LONG, DOUBLE, BOOLEAN, STRING, DATE, TIME, DATETIME, JSON
Attempting to delete these will result in a 409 Conflict error.

Active/Inactive Filtering

Data types can be marked as inactive without deletion. This allows you to:
  • Soft delete deprecated types without losing historical data
  • Hide unused types from UI dropdowns
  • Preserve validation rules for existing configurations

Use Cases

GET /api/v1/catalog/data-types/active
Returns only types where isActive = true.Use this for: Populating dropdowns in configuration UIs.

Integration Examples

// Validate a setting value before saving
const validateSetting = async (dataTypeId, value) => {
  const response = await fetch(
    `https://api.invernaderos.com/api/v1/catalog/data-types/${dataTypeId}/validate?value=${encodeURIComponent(value)}`,
    {
      headers: { 'Authorization': `Bearer ${token}` }
    }
  );
  
  const result = await response.json();
  
  if (!result.isValid) {
    throw new Error(`Invalid value "${value}" for data type ${dataTypeId}`);
  }
  
  return true;
};

// Usage
await validateSetting(1, "25");        // Valid INTEGER
await validateSetting(1, "not-a-number"); // Throws error

Error Codes

Status CodeDescriptionResolution
200 OKRequest successful-
201 CreatedData type created successfully-
204 No ContentData type deleted successfully-
400 Bad RequestInvalid input (duplicate name, invalid regex, validation error)Check error message for details
404 Not FoundData type not found with specified ID or nameVerify the ID/name exists
409 ConflictCannot delete system data type (IDs 1-9)Use inactive status instead of deletion

Best Practices

When creating custom data types:
  1. Use descriptive names (e.g., PERCENTAGE, PHONE_NUMBER, EMAIL)
  2. Provide validation regex for strict input validation
  3. Include example values to guide users
  4. Set appropriate display order to group related types
Example:
{
  "name": "EMAIL",
  "description": "Valid email address",
  "validationRegex": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
  "exampleValue": "[email protected]",
  "displayOrder": 15,
  "isActive": true
}
  • Cache active data types on client side to reduce API calls
  • Validate on client first before sending to /validate endpoint
  • Use regex validation for custom types to maintain consistency
  • Batch validate multiple values if possible (client-side cache)
  • Prefer soft deletes (isActive = false) to preserve historical data
  • Only hard delete truly unused custom types
  • Never delete system types (IDs 1-9 are protected)
  • Document deprecation in the description field before deactivating

Build docs developers (and LLMs) love