KosmoKrator

documents

API Template IO Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the API Template IO KosmoKrator integration.

5 functions 3 read 2 write API key auth

Lua Namespace

Agents call this integration through app.integrations.apitemplateio.*. Use lua_read_doc("integrations.apitemplateio") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

API Template IO — Lua API Reference

create_pdf

Generate a PDF document from a template.

Parameters

NameTypeRequiredDescription
template_idstringyesThe template ID (e.g., "tpl_abc123")
dataobjectyesKey-value pairs to merge into the template
output_htmlbooleannoIf true, returns the rendered HTML alongside the PDF URL
expireintegernoMinutes until the generated file URL expires
metastringnoOptional metadata string for the generation request

Example

local result = app.integrations.apitemplateio.create_pdf({
  template_id = "tpl_abc123",
  data = {
    company_name = "Acme Corp",
    amount = "$500.00",
    invoice_number = "INV-001",
    due_date = "2026-04-30"
  }
})

print("PDF URL: " .. result.download_url)
print("Transaction ID: " .. result.transaction_id)

create_image

Generate an image (PNG or JPEG) from a template.

Parameters

NameTypeRequiredDescription
template_idstringyesThe template ID (e.g., "tpl_xyz789")
dataobjectyesKey-value pairs to merge into the template
output_formatstringnoImage format: "png" (default) or "jpeg"
output_htmlbooleannoIf true, returns the rendered HTML alongside the image URL
expireintegernoMinutes until the generated file URL expires
metastringnoOptional metadata string for the generation request

Example

local result = app.integrations.apitemplateio.create_image({
  template_id = "tpl_xyz789",
  data = {
    title = "Summer Sale",
    discount = "30% Off",
    tagline = "Limited time offer!"
  },
  output_format = "png"
})

print("Image URL: " .. result.download_url)

list_templates

List available templates with pagination.

Parameters

NameTypeRequiredDescription
limitintegernoNumber of templates per page (default: 50, max: 100)
offsetintegernoNumber of templates to skip for pagination (default: 0)
filterstringnoOptional filter expression to narrow results

Example

-- First page
local result = app.integrations.apitemplateio.list_templates({
  limit = 10,
  offset = 0
})

for _, tpl in ipairs(result.templates) do
  print(tpl.id .. ": " .. tpl.name)
end

-- Next page
local page2 = app.integrations.apitemplateio.list_templates({
  limit = 10,
  offset = 10
})

get_template

Get details for a specific template by ID.

Parameters

NameTypeRequiredDescription
template_idstringyesThe template ID to retrieve (e.g., "tpl_abc123")

Example

local result = app.integrations.apitemplateio.get_template({
  template_id = "tpl_abc123"
})

print("Template: " .. result.name)
print("Format: " .. result.format)
print("Modified: " .. result.modified_at)

get_current_user

Get the authenticated user’s account information, including usage and subscription details.

Parameters

This tool takes no parameters.

Example

local result = app.integrations.apitemplateio.get_current_user({})

print("Account: " .. result.email)
print("Plan: " .. result.plan)
print("API calls used: " .. result.api_calls_used .. " / " .. result.api_calls_limit)

Multi-Account Usage

If you have multiple API Template IO accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.apitemplateio.create_pdf({...})

-- Explicit default (portable across setups)
app.integrations.apitemplateio.default.create_pdf({...})

-- Named accounts
app.integrations.apitemplateio.production.create_pdf({...})
app.integrations.apitemplateio.staging.create_pdf({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# API Template IO — Lua API Reference

## create_pdf

Generate a PDF document from a template.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `template_id` | string | yes | The template ID (e.g., `"tpl_abc123"`) |
| `data` | object | yes | Key-value pairs to merge into the template |
| `output_html` | boolean | no | If true, returns the rendered HTML alongside the PDF URL |
| `expire` | integer | no | Minutes until the generated file URL expires |
| `meta` | string | no | Optional metadata string for the generation request |

### Example

```lua
local result = app.integrations.apitemplateio.create_pdf({
  template_id = "tpl_abc123",
  data = {
    company_name = "Acme Corp",
    amount = "$500.00",
    invoice_number = "INV-001",
    due_date = "2026-04-30"
  }
})

print("PDF URL: " .. result.download_url)
print("Transaction ID: " .. result.transaction_id)
```

---

## create_image

Generate an image (PNG or JPEG) from a template.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `template_id` | string | yes | The template ID (e.g., `"tpl_xyz789"`) |
| `data` | object | yes | Key-value pairs to merge into the template |
| `output_format` | string | no | Image format: `"png"` (default) or `"jpeg"` |
| `output_html` | boolean | no | If true, returns the rendered HTML alongside the image URL |
| `expire` | integer | no | Minutes until the generated file URL expires |
| `meta` | string | no | Optional metadata string for the generation request |

### Example

```lua
local result = app.integrations.apitemplateio.create_image({
  template_id = "tpl_xyz789",
  data = {
    title = "Summer Sale",
    discount = "30% Off",
    tagline = "Limited time offer!"
  },
  output_format = "png"
})

print("Image URL: " .. result.download_url)
```

---

## list_templates

List available templates with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of templates per page (default: 50, max: 100) |
| `offset` | integer | no | Number of templates to skip for pagination (default: 0) |
| `filter` | string | no | Optional filter expression to narrow results |

### Example

```lua
-- First page
local result = app.integrations.apitemplateio.list_templates({
  limit = 10,
  offset = 0
})

for _, tpl in ipairs(result.templates) do
  print(tpl.id .. ": " .. tpl.name)
end

-- Next page
local page2 = app.integrations.apitemplateio.list_templates({
  limit = 10,
  offset = 10
})
```

---

## get_template

Get details for a specific template by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `template_id` | string | yes | The template ID to retrieve (e.g., `"tpl_abc123"`) |

### Example

```lua
local result = app.integrations.apitemplateio.get_template({
  template_id = "tpl_abc123"
})

print("Template: " .. result.name)
print("Format: " .. result.format)
print("Modified: " .. result.modified_at)
```

---

## get_current_user

Get the authenticated user's account information, including usage and subscription details.

### Parameters

This tool takes no parameters.

### Example

```lua
local result = app.integrations.apitemplateio.get_current_user({})

print("Account: " .. result.email)
print("Plan: " .. result.plan)
print("API calls used: " .. result.api_calls_used .. " / " .. result.api_calls_limit)
```

---

## Multi-Account Usage

If you have multiple API Template IO accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.apitemplateio.create_pdf({...})

-- Explicit default (portable across setups)
app.integrations.apitemplateio.default.create_pdf({...})

-- Named accounts
app.integrations.apitemplateio.production.create_pdf({...})
app.integrations.apitemplateio.staging.create_pdf({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.apitemplateio.apitemplateio_create_pdf({
  template_id = "example_template_id",
  data = "example_data",
  output_html = true,
  expire = 1,
  meta = "example_meta"
})
print(result)

Functions

apitemplateio_create_pdf

Generate a PDF document from an API Template IO template. Provide a template ID and the data to merge into the template.

Operation
Write write
Full name
apitemplateio.apitemplateio_create_pdf
ParameterTypeRequiredDescription
template_id string yes The template ID to use for PDF generation (e.g., "tpl_abc123").
data object yes Key-value pairs to merge into the template placeholders.
output_html boolean no If true, returns the rendered HTML in addition to the PDF URL.
expire integer no Number of minutes after which the generated file URL expires (default: no expiry).
meta string no Optional metadata string to attach to the generation request.

apitemplateio_create_image

Generate an image (PNG or JPEG) from an API Template IO template. Provide a template ID, data, and the desired output format.

Operation
Write write
Full name
apitemplateio.apitemplateio_create_image
ParameterTypeRequiredDescription
template_id string yes The template ID to use for image generation (e.g., "tpl_abc123").
data object yes Key-value pairs to merge into the template placeholders.
output_format string no The image format to generate: "png" or "jpeg". Defaults to "png".
output_html boolean no If true, returns the rendered HTML in addition to the image URL.
expire integer no Number of minutes after which the generated file URL expires (default: no expiry).
meta string no Optional metadata string to attach to the generation request.

apitemplateio_list_templates

List available templates in API Template IO. Returns a paginated list of template IDs, names, and metadata.

Operation
Read read
Full name
apitemplateio.apitemplateio_list_templates
ParameterTypeRequiredDescription
limit integer no Number of templates to return per page (default: 50, max: 100).
offset integer no Offset for pagination — number of templates to skip (default: 0).
filter string no Optional filter expression to narrow down templates.

apitemplateio_get_template

Get details for a specific API Template IO template by ID. Returns the template definition, schema, and configuration.

Operation
Read read
Full name
apitemplateio.apitemplateio_get_template
ParameterTypeRequiredDescription
template_id string yes The template ID to retrieve (e.g., "tpl_abc123").

apitemplateio_get_current_user

Get the current authenticated user's account information from API Template IO, including usage and subscription details.

Operation
Read read
Full name
apitemplateio.apitemplateio_get_current_user
ParameterTypeRequiredDescription
No parameters.