For AI agents: the complete documentation index is available at /hclapi/llms.txt, the full documentation bundle is available at /hclapi/llms-full.txt, and this page is available as Markdown at /hclapi/docs/manifest/types.md.

Types and schema constraints

hclapi features a strongly typed schema and configuration system. Types are verified at boot time during manifest parsing and enforced at request ingress before pipeline execution.

Schema data types

Used inside schema and request field definitions (field "<name>" { type = <type> }):

SignatureJSON representationDescriptionExample
string"hello"Text strings (supports regex pattern and format)type = string
int4264-bit signed integertype = int
float3.1415964-bit floating-point numbertype = float
booltrue, falseBoolean truth valuetype = bool
anyAny primitive, array, or objectFree-form untyped payloadtype = any
list(<type>)["admin", "member"]Array of uniform elementstype = list(string)
map(<type>){"k1": "v1"}String-keyed dictionary with uniform valuestype = map(int)

Examples

schema "product" {
  field "sku" {
    type = string,
    required = true
  }
  field "price" {
    type = float,
    required = true,
    min = 0.01
  }
  field "tags" {
    type = list(string),
    default = []
  }
  field "metadata" {
    type = map(any)
  }
}

Scalar configuration types

hclapi provides specialized scalar types that parse human-readable strings into typed units at startup and fail fast on invalid syntax.

Duration

Backed by Go's time.Duration.

SuffixUnitExample
nsNanoseconds"500ns"
us, µsMicroseconds"100µs"
msMilliseconds"250ms"
sSeconds"30s"
mMinutes"15m"
hHours"1h30m"

Units can be combined (e.g. "1h30m", "2m45s").

Usage in manifests:

server {
  read_timeout = "30s"
  idle_timeout = "2m"
}

connection "postgres" "main" {
  pool {
    conn_max_lifetime = "1h"
    idle_timeout      = "10m"
  }
}

ByteSize

Backed by a 64-bit integer representing byte quantities. Both decimal (1,000-based) and binary (1,024-based) units are accepted case-insensitively.

SuffixStandardBytes
BByte1
KB, KKilobyte1,000
KiBKibibyte1,024
MB, MMegabyte1,000,000
MiBMebibyte1,048,576
GB, GGigabyte1,000,000,000
GiBGibibyte1,073,741,824
TB, TTerabyte1,000,000,000,000
TiBTebibyte1,099,511,627,776

Fractional quantities and raw integer bytes are both supported:

server {
  max_body_size = "25MB"    # 25,000,000 bytes
  max_body_size = "2.5MiB"  # 2,621,440 bytes
  max_body_size = "1048576" # 1,048,576 raw integer bytes
}

Compile-time diagnostics

Invalid type or scalar formats fail fast during hclapi serve boot:

server {
  read_timeout = "100years"
}
error: server: invalid read_timeout: invalid duration "100years": time: unknown unit "years" in duration "100years"
server {
  max_body_size = "10XB"
}
error: server: invalid max_body_size: invalid byte size "10XB": unknown unit "XB"