Skip to content
Hoody.com

The script templates API lets you list, preview, generate, and manage script templates on a Hoody container. Use it to discover the templates that ship with the platform, render a script from a template by supplying the variables it asks for, save the rendered script to the container’s scripts directory, and maintain your own library of custom templates stored under _hoody/templates/.

All endpoints run on the container’s exec host.

Use these endpoints to discover what templates are available, and to inspect a single template’s source, metadata, and rendered code before generating from it.

List available templates, optionally filtered by category or source. By default, both built-in and custom templates are returned.

NameInTypeRequiredDescription
categoryquerystringNoFilter templates to a single metadata category (e.g. api, utility). Omit to list all categories.
includeBuiltinquerybooleanNoInclude built-in templates in the result set. Default true. Accepts true/false/1/0.
includeCustomquerybooleanNoInclude user-supplied templates (from _hoody/templates/) in the result set. Default true.
Terminal window
curl -X GET "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/list?includeBuiltin=true&includeCustom=true" \
-H "Authorization: Bearer $HOODY_TOKEN"
{
"count": 2,
"templates": [
{
"name": "fetch-items",
"category": "api",
"description": "Fetch a list of items from an HTTP API and write the results to a file.",
"tags": ["http", "fetch"],
"params": ["url", "destination"],
"type": "builtin"
},
{
"name": "my-template",
"category": "custom",
"description": "Custom template for a recurring task.",
"tags": ["custom"],
"params": ["name"],
"type": "custom"
}
]
}

Read a template’s source and metadata, optionally with its params substituted by the supplied variables. Use this to confirm what a template will produce before calling templates/generate.

NameInTypeRequiredDescription
namequerystringYesTemplate name, as templates/generate and templates/preview take it.
variablesquerystringNoJSON-encoded variables to substitute into the template’s params.
Terminal window
curl -X GET "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/preview?name=fetch-items&variables=%7B%22url%22%3A%22https%3A%2F%2Fapi.example.com%2Fitems%22%7D" \
-H "Authorization: Bearer $HOODY_TOKEN"
{
"template": {
"name": "fetch-items",
"metadata": {
"category": "api",
"tags": ["http", "fetch"],
"description": "Fetch a list of items from an HTTP API and write the results to a file.",
"params": ["url", "destination"]
},
"code": "export default async function() {\n const items = await fetch('https://api.example.com/items').then(r => r.json());\n console.log(items);\n}",
"originalCode": "export default async function({url}) {\n const items = await fetch(url).then(r => r.json());\n console.log(items);\n}",
"substituted": true
}
}

Render a script from a template by supplying its variables. When saveFile is true, the rendered script is written to outputPath under the call’s scope, and the response carries the resolved path.

NameInTypeRequiredDescription
execIdquerystringNoOptional execution scope. When provided, relative paths resolve under default/{execId}/ unless subdomain is also set. Query value takes precedence over body. Lowercase alphanumeric, no hyphens.
exec_idquerystringNoAlias for execId (snake_case). Lowercase alphanumeric, no hyphens.
subdomainquerystringNoOptional subdomain namespace used with execId for path resolution.
FieldTypeRequiredDescription
namestringYesTemplate name: a built-in one or a custom template’s (see templates/list).
variablesobjectNoValues for the template’s params, substituted into its code.
outputPathstringNoWhere to save the script when saveFile is true. Resolves under the call’s scope as <subdomain|default>/<execId>/<outputPath>.
saveFilebooleanNoWhen true, write the generated script to outputPath (required then). When false (the default), only return the code. Default false.
execIdstringNoOptional execution scope in request body. Query execId/exec_id takes precedence when both are provided. Lowercase alphanumeric, no hyphens.
exec_idstringNoAlias for execId (snake_case). Lowercase alphanumeric, no hyphens.
subdomainstringNoOptional subdomain namespace used with execId for path resolution.
Terminal window
curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/generate" \
-H "Authorization: Bearer $HOODY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "fetch-items",
"variables": {
"url": "https://api.example.com/items"
},
"outputPath": "fetch-items.ts",
"saveFile": true
}'
{
"generated": true,
"template": "fetch-items",
"code": "export default async function() {\n const items = await fetch('https://api.example.com/items').then(r => r.json());\n console.log(items);\n}",
"saved": true,
"path": "fetch-items.ts",
"resolvedPath": "default/1/fetch-items.ts",
"variables": {
"url": "https://api.example.com/items"
}
}

Maintain your own library of templates under _hoody/templates/. Use these endpoints to create, update, and delete custom templates. The full template name pattern is letters, digits, dots, hyphens, and underscores, up to 64 characters, starting with a letter or digit, and never containing ...

Create a new custom template. The template is stored with a generated metadata header and is available to templates/list, templates/preview, and templates/generate once the call succeeds.

FieldTypeRequiredDescription
namestringYesTemplate name. Must match the pattern ^(?!.*\\.\\.)[A-Za-z0-9][A-Za-z0-9._-]{0,63}$. A name already taken by a built-in template is refused with a 409.
codestringYesTemplate source. Stored after a generated metadata header. A non-string is refused with a 400.
metadataobjectNoTemplate metadata. An omitted member takes its default; a member of the wrong type, or a metadata value that is not an object, is refused with a 400.

metadata sub-fields:

FieldTypeRequiredDefaultDescription
categorystringNocustomCategory used to group templates.
tagsarray of stringsNo(none)Tags used to filter templates.
descriptionstringNoCustom templateHuman-readable description.
paramsarray of stringsNo(none)Names of the variables templates/generate must be given to fill this template.
versionstringNo1.0.0Template version.
authorstringNoUserTemplate author.
Terminal window
curl -X POST "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/create-custom" \
-H "Authorization: Bearer $HOODY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-template",
"code": "export default async function({name}: { name: string }) {\n console.log(`Hello, ${name}!`);\n}",
"metadata": {
"category": "utility",
"description": "Greet a user by name.",
"params": ["name"],
"tags": ["greeting"]
}
}'
{
"created": true,
"name": "my-template",
"path": "default/my-template.ts",
"metadata": {
"name": "my-template",
"category": "utility",
"tags": ["greeting"],
"description": "Greet a user by name.",
"params": ["name"],
"version": "1.0.0",
"author": "User"
}
}

PUT /api/v1/exec/templates/update-custom/{name}

Section titled “PUT /api/v1/exec/templates/update-custom/{name}”

Update an existing custom template’s source and/or metadata. The new metadata is merged with the existing one.

NameInTypeRequiredDescription
namepathstringYesTemplate name.
FieldTypeRequiredDescription
codestringNoNew template source. Replaces the existing code.
metadataobjectNoMetadata fields to update. Merged with the existing metadata.
Terminal window
curl -X PUT "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/update-custom/my-template" \
-H "Authorization: Bearer $HOODY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"code": "export default async function({name}: { name: string }) {\n console.log(`Hello, ${name}! Updated.`);\n}",
"metadata": {
"description": "Greet a user by name (updated)."
}
}'
{
"updated": true,
"name": "my-template",
"metadata": {
"name": "my-template",
"category": "utility",
"tags": ["greeting"],
"description": "Greet a user by name (updated).",
"params": ["name"],
"version": "1.0.0",
"author": "User"
}
}

DELETE /api/v1/exec/templates/delete-custom/{name}

Section titled “DELETE /api/v1/exec/templates/delete-custom/{name}”

Delete a custom template. The template file is removed from _hoody/templates/.

NameInTypeRequiredDescription
namepathstringYesTemplate name.
Terminal window
curl -X DELETE "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/delete-custom/my-template" \
-H "Authorization: Bearer $HOODY_TOKEN"
{
"deleted": true,
"name": "my-template"
}