Skip to content

Use these endpoints to list built-in and custom script templates, preview a template with variable substitution, generate code from a template, and create, update, or delete custom templates stored under _hoody/templates/.

GET /api/v1/exec/templates/list

Returns the set of available script templates. By default, both built-in and user-supplied templates are included. Results can be filtered by metadata category.

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": 2,
"templates": [
{
"name": "fetch-json",
"metadata": {
"category": "api",
"tags": ["http", "fetch"],
"description": "Fetch a JSON resource and print the body.",
"params": ["url"],
"version": "1.0.0",
"author": "hoody"
}
},
{
"name": "log-timestamp",
"metadata": {
"category": "utility",
"tags": ["log"],
"description": "Print a timestamped log line.",
"params": ["message"],
"version": "1.0.0",
"author": "hoody"
}
}
]
}
const result = await client.exec.templates.list({
category: "api",
includeBuiltin: true,
includeCustom: true,
});

GET /api/v1/exec/templates/preview

Renders a template by name, returning both the original source and the code with the supplied variables substituted. Useful for inspecting what a generation call will produce before writing it to disk.

NameInTypeRequiredDescription
namequerystringYesName query parameter
variablesquerystringNoVariables query parameter
{
"template": {
"name": "fetch-json",
"metadata": {
"category": "api",
"tags": ["http", "fetch"],
"description": "Fetch a JSON resource and print the body.",
"params": ["url"],
"version": "1.0.0",
"author": "hoody"
},
"code": "const res = await fetch('https://api.example.com/items');\nconsole.log(await res.json());",
"originalCode": "const res = await fetch('{{url}}');\nconsole.log(await res.json());",
"substituted": true
}
}
const result = await client.exec.templates.preview({
name: "fetch-json",
variables: "{\"url\":\"https://api.example.com/items\"}",
});

POST /api/v1/exec/templates/create-custom

Persists a new custom template under _hoody/templates/. The request body is required but its schema is intentionally open-ended; the server validates the structural fields internally.

This endpoint accepts a JSON payload. No specific fields are documented in the spec.

{
"created": true,
"name": "fetch-json",
"path": "/workspace/_hoody/templates/fetch-json.js",
"metadata": {
"name": "fetch-json",
"category": "api",
"tags": ["http", "fetch"],
"description": "Fetch a JSON resource and print the body.",
"params": ["url"],
"version": "1.0.0",
"author": "hoody"
}
}
const result = await client.exec.templates.createCustom({
data: {
/* template payload */
},
});

POST /api/v1/exec/templates/generate

Generates code from a named template, substituting the provided variables. Optionally writes the generated file to outputPath when saveFile is true.

NameTypeRequiredDescription
namestringYesName
variablesobjectNoVariables
outputPathstringNoOutput Path
saveFilebooleanNoSave File. Default false
{
"generated": true,
"template": "fetch-json",
"code": "const res = await fetch('https://api.example.com/items');\nconsole.log(await res.json());",
"saved": false,
"path": null,
"variables": {
"url": "https://api.example.com/items"
}
}
const result = await client.exec.templates.generate({
data: {
name: "fetch-json",
variables: { url: "https://api.example.com/items" },
outputPath: "scripts/fetch.js",
saveFile: false,
},
});

PUT /api/v1/exec/templates/update-custom/:name

Patches an existing custom template. The :name path segment identifies the template. The request body can supply new code and/or a metadata patch that is merged with the existing metadata.

NameInTypeRequiredDescription
namepathstringYesName parameter
NameTypeRequiredDescription
codestringNoCode
metadataobjectNoMetadata
{
"updated": true,
"name": "fetch-json",
"metadata": {
"category": "api",
"tags": ["http", "fetch", "retry"],
"description": "Fetch a JSON resource and print the body.",
"params": ["url", "retries"],
"version": "1.1.0",
"author": "hoody"
}
}
const result = await client.exec.templates.updateCustom({
name: "fetch-json",
data: {
code: "const res = await fetch('{{url}}');\nconsole.log(await res.json());",
metadata: { version: "1.1.0", tags: ["http", "fetch", "retry"] },
},
});

DELETE /api/v1/exec/templates/delete-custom/:name

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

NameInTypeRequiredDescription
namepathstringYesName parameter
{
"deleted": true,
"name": "fetch-json"
}
const result = await client.exec.templates.deleteCustom({
name: "fetch-json",
});