Skip to content
Hoody.com

The Script Templates API lets you browse built-in and custom templates, preview them with substituted variables, generate scripts on the fly, and manage your own custom templates stored under _hoody/templates/. Use these endpoints when you want to scaffold new scripts from a known-good starting point or curate a private library of reusable templates for your container.

All template operations target the exec service in your container. Output scripts are written under /hoody/storage/hoody-exec/scripts; the outputPath you pass to generate is relative to that scripts root and must carry the host/exec scope itself (for example, default/1/fetch-items.ts).

Returns the catalog of templates available to this container. Built-in templates ship with the platform; custom templates are user-supplied files in _hoody/templates/. Use category to narrow the result to a single metadata bucket.

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.
{
"count": 3,
"templates": [
{
"name": "api-fetch-items",
"category": "api"
},
{
"name": "utility-format-date",
"category": "utility"
},
{
"name": "internal-sync",
"category": "internal"
}
]
}
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"

Renders a template with optional variable substitution without writing a script file. Use this to inspect what a template produces (code) versus the raw template body (originalCode) and whether placeholders have been resolved (substituted).

NameInTypeRequiredDescription
namequerystringYesName query parameter
variablesquerystringNoVariables query parameter
{
"template": {
"name": "api-fetch-items",
"metadata": {
"category": "api",
"tags": ["fetch", "items"],
"description": "Fetches items from a configured API endpoint",
"params": ["url", "method"]
},
"code": "// resolved code with variables substituted\nexport async function main() {\n const url = 'https://api.example.com/items';\n const method = 'GET';\n return await fetch(url, { method });\n}\n",
"originalCode": "// raw template with placeholders\nexport async function main() {\n const url = '{{url}}';\n const method = '{{method}}';\n return await fetch(url, { method });\n}\n",
"substituted": true
}
}
Terminal window
curl -X GET "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/preview?name=api-fetch-items&variables=%7B%22url%22%3A%22https%3A%2F%2Fapi.example.com%2Fitems%22%2C%22method%22%3A%22GET%22%7D" \
-H "Authorization: Bearer $HOODY_TOKEN"

Persists a new user-supplied template under _hoody/templates/. The response echoes the metadata recorded for the template and the resolved on-disk path.

The request body schema is open; no specific fields are documented by the server contract. Supply the template payload as a JSON object in the body.

{
"created": true,
"name": "internal-sync",
"path": "default/1/internal-sync.ts",
"metadata": {
"name": "internal-sync",
"category": "internal",
"tags": ["sync", "internal"],
"description": "Internal sync script template",
"params": ["batchSize", "dryRun"],
"version": "1.0.0",
"author": "team-platform"
}
}
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 '{}'

Expands a template with the supplied variables and returns the generated code. Set saveFile to true and provide outputPath to persist the result to disk under /hoody/storage/hoody-exec/scripts/.

NameTypeRequiredDescription
namestringYesName of the template to expand.
variablesobjectNoMap of placeholder name to value used during expansion.
outputPathstringNoDestination path relative to /hoody/storage/hoody-exec/scripts, including the host/exec scope (for example, default/1/fetch-items.ts). Required when saveFile is true.
saveFilebooleanNoWhen true, write the generated script to outputPath. Default false.
{
"generated": true,
"template": "api-fetch-items",
"code": "export async function main() {\n const url = 'https://api.example.com/items';\n const method = 'GET';\n return await fetch(url, { method });\n}\n",
"saved": true,
"path": "default/1/fetch-items.ts",
"variables": {
"url": "https://api.example.com/items",
"method": "GET"
}
}
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": "api-fetch-items",
"variables": {
"url": "https://api.example.com/items",
"method": "GET"
},
"outputPath": "default/1/fetch-items.ts",
"saveFile": true
}'

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

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

Patches an existing custom template. Pass only the fields you want to change; the server merges metadata with the existing record and replaces code when supplied.

NameInTypeRequiredDescription
namepathstringYesName parameter
NameTypeRequiredDescription
codestringNoNew source body for the template. Replaces the existing code on success.
metadataobjectNoPartial metadata patch; merged with the existing record.
{
"updated": true,
"name": "internal-sync",
"metadata": {
"name": "internal-sync",
"category": "internal",
"tags": ["sync", "internal", "v2"],
"description": "Internal sync script template (updated)",
"params": ["batchSize", "dryRun", "timeoutMs"],
"version": "1.1.0",
"author": "team-platform"
}
}
Terminal window
curl -X PUT "https://{projectId}-{containerId}-exec-1.{server}.containers.hoody.com/api/v1/exec/templates/update-custom/internal-sync" \
-H "Authorization: Bearer $HOODY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"code": "export async function main() {\n console.log(\"updated\");\n}\n",
"metadata": {
"version": "1.1.0",
"tags": ["sync", "internal", "v2"]
}
}'

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

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

Removes a user-supplied template from _hoody/templates/. Built-in templates cannot be deleted through this endpoint.

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