Skip to content

List, preview, generate, and manage custom script templates. The templates API lets you discover available code generation templates, render them with variables, create user-supplied templates from _hoody/templates/, and update or delete those custom entries.

GET /api/v1/exec/templates/list

Returns all available script templates, including built-in and user-supplied entries. Use the category filter to narrow the result set to a single metadata category such as api or utility.

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": "api-fetch",
"metadata": {
"category": "api",
"tags": ["http", "fetch"]
}
},
{
"name": "utility-log",
"metadata": {
"category": "utility",
"tags": ["logging"]
}
}
]
}
const { count, templates } = await client.exec.templates.list({
category: "api",
includeBuiltin: true,
includeCustom: true,
});
Terminal window
curl -X GET "https://api.hoody.com/api/v1/exec/templates/list?category=api&includeBuiltin=true&includeCustom=true" \
-H "Authorization: Bearer <token>"

GET /api/v1/exec/templates/preview

Render a template with the supplied variables and return the substituted code alongside the original source. Useful for inspecting what a generation will produce before committing to writing a file.

NameInTypeRequiredDescription
namequerystringYesName query parameter
variablesquerystringNoVariables query parameter
{
"template": {
"name": "api-fetch",
"metadata": {
"category": "api",
"tags": ["http", "fetch"]
},
"code": "const url = 'https://api.example.com';\nfetch(url).then(r => r.json());",
"originalCode": "const url = '{{baseUrl}}';\nfetch(url).then(r => r.json());",
"substituted": true
}
}
const { template } = await client.exec.templates.preview({
name: "api-fetch",
variables: "baseUrl=https://api.example.com",
});
Terminal window
curl -X GET "https://api.hoody.com/api/v1/exec/templates/preview?name=api-fetch&variables=baseUrl%3Dhttps%3A%2F%2Fapi.example.com" \
-H "Authorization: Bearer <token>"

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

Persist a new user-supplied template under _hoody/templates/. The endpoint accepts a request payload describing the template code and its metadata.

This endpoint accepts a JSON request body. No specific body fields are defined in the schema.

{
"created": true,
"name": "my-custom-fetch",
"path": "_hoody/templates/my-custom-fetch.js",
"metadata": {
"name": "my-custom-fetch",
"category": "api",
"tags": ["http", "custom"],
"description": "Fetch helper for internal APIs",
"params": ["baseUrl", "method"],
"version": "1.0.0",
"author": "dev@hoody.com"
}
}
const result = await client.exec.templates.createCustom({
data: {},
});
Terminal window
curl -X POST "https://api.hoody.com/api/v1/exec/templates/create-custom" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{}'

POST /api/v1/exec/templates/generate

Render a template with variables and optionally write the result to disk. Returns the generated code, the file path if saved, and the variable map that was applied.

FieldTypeRequiredDescription
namestringYesName of the template to generate.
variablesobjectNoMap of template variables used during substitution.
outputPathstringNoDestination path where generated code is written when saveFile is true.
saveFilebooleanNoWhen true, writes the rendered code to outputPath. Default false.
{
"generated": true,
"template": "api-fetch",
"code": "const url = 'https://api.example.com';\nfetch(url).then(r => r.json());",
"saved": true,
"path": "_hoody/generated/api-fetch.js",
"variables": {
"baseUrl": "https://api.example.com"
}
}
const result = await client.exec.templates.generate({
data: {
name: "api-fetch",
variables: { baseUrl: "https://api.example.com" },
outputPath: "_hoody/generated/api-fetch.js",
saveFile: true,
},
});
Terminal window
curl -X POST "https://api.hoody.com/api/v1/exec/templates/generate" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "api-fetch",
"variables": { "baseUrl": "https://api.example.com" },
"outputPath": "_hoody/generated/api-fetch.js",
"saveFile": true
}'

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

Patch the source code and/or metadata of an existing custom template. The supplied metadata object is merged with existing metadata rather than replacing it.

NameInTypeRequiredDescription
namepathstringYesName of the custom template to update.
FieldTypeRequiredDescription
codestringNoReplacement source code for the template.
metadataobjectNoMetadata fields to merge into the existing template metadata.
{
"updated": true,
"name": "my-custom-fetch",
"metadata": {
"name": "my-custom-fetch",
"category": "api",
"tags": ["http", "custom", "internal"],
"description": "Fetch helper for internal APIs (updated)",
"params": ["baseUrl", "method"],
"version": "1.1.0",
"author": "dev@hoody.com"
}
}
const result = await client.exec.templates.updateCustom({
name: "my-custom-fetch",
data: {
code: "fetch('{{baseUrl}}', { method: '{{method}}' }).then(r => r.json());",
metadata: {
tags: ["http", "custom", "internal"],
version: "1.1.0",
params: ["baseUrl", "method"],
},
},
});
Terminal window
curl -X PUT "https://api.hoody.com/api/v1/exec/templates/update-custom/my-custom-fetch" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"code": "fetch(\"{{baseUrl}}\", { method: \"{{method}}\" }).then(r => r.json());",
"metadata": {
"tags": ["http", "custom", "internal"],
"version": "1.1.0",
"params": ["baseUrl", "method"]
}
}'

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

Remove a user-supplied template from _hoody/templates/. Built-in templates cannot be deleted.

NameInTypeRequiredDescription
namepathstringYesName of the custom template to delete.
{
"deleted": true,
"name": "my-custom-fetch"
}
const result = await client.exec.templates.deleteCustom({
name: "my-custom-fetch",
});
Terminal window
curl -X DELETE "https://api.hoody.com/api/v1/exec/templates/delete-custom/my-custom-fetch" \
-H "Authorization: Bearer <token>"