How inputs reach your code
When you configure a container function block, you add one input row per parameter your code reads. Each row has:- A parameter name, such as
discount_rate. Your code looks the value up by this name. Names must start with a letter or underscore and contain only letters, digits, and underscores. - A term in the model that supplies the value. It can be any term: a manual input, a formula result, or an output of another container function.
- An optional “send as” unit. The platform converts the term’s value to this unit before your code sees it. If the units are dimensionally incompatible (USD into MWh, for example), the run fails instead of passing a wrong number.
AIRELABS_HOOK_INPUT_PATH:
hook-input.json
name and exactly one value field. The field name tells you the type.
Container functions don’t re-run automatically. When the value or unit of a mapped term changes, the block shows Needs re-run. Run it again to send the new values.
How outputs reach your model
Your code writes a JSON file toAIRELABS_HOOK_OUTPUT_PATH with a results array in the same format:
hook-output.json
error instead of a value. The platform shows that output as an error and propagates it downstream, while the other outputs still get their values. Use this for problems that affect one output, such as an invalid rate. For problems that make the whole run meaningless, exit with a non-zero code.
The container must write the output file and exit with code 0. A non-zero exit, a missing output file, or invalid JSON marks the whole run as failed. Only standard error is captured in the run logs, so print diagnostics there.
Value types
Inputs and results use the same types. Set exactly one value field per entry.- Numbers are decimal strings (
"0.08", not0.08), so no precision is lost on the way. Don’t use scientific notation or thousands separators. - Booleans are the strings
"true"and"false", not JSON booleans. - Timestamps are not supported. A
timestamportimestampArrayresult shows as the error#CONTAINER_ERR_UNSUPPORTED_TYPE. Return adateor astringinstead.
Units
A number’sunit is optional. On inputs, it is the “send as” unit if you set one, or the term’s own unit otherwise. On results, the platform matches the unit name against your organization’s units. If a result’s unit is not recognized, that output shows the error #CONTAINER_ERR_UNRESOLVED_UNIT instead of a number with a wrong unit.
Declaring your function’s interface
You can publish your function’s inputs and outputs with the image, so nobody has to retype them. Add an image label namedcom.airelabs.schema.v1.hook whose value is a JSON description of the interface:
unit. The tag picker shows how many inputs the image declares. Images without the label keep the free-form input list.
- Types:
CONTAINER_FUNCTION_VALUE_TYPE_followed byQUANTITY(a number),STRING,BOOL,DATE, or the array formsQUANTITY_ARRAY,STRING_ARRAY,BOOL_ARRAY,DATE_ARRAY. - Input fields:
name,type,required,unit,description. - Output fields:
name,type,unit,description,label,tags. - Limits: the label must be valid JSON with no unknown keys and at most 32 KB. The push still succeeds when the label is invalid. The reason shows on the Container Registry page and in the block configuration, which falls back to free-form inputs.
Environment variables
The platform sets these before your container starts:JSON schemas
Machine-readable schemas for the input and output files, for editor autocompletion and validation:- Input:
https://app.airelabs.com/schemas/v1/airelabs.v1.HookInput.jsonschema.strict.bundle.json - Output:
https://app.airelabs.com/schemas/v1/airelabs.v1.HookOutput.jsonschema.strict.bundle.json
