KosmoKrator

email

Elastic Email Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Elastic Email KosmoKrator integration.

6 functions 4 read 2 write API key auth

Lua Namespace

Agents call this integration through app.integrations.elastic_email.*. Use lua_read_doc("integrations.elastic-email") 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.

Elastic Email — Lua API Reference

send_email

Send a transactional email via Elastic Email.

Parameters

NameTypeRequiredDescription
tostringyesRecipient email address. For multiple recipients, separate with semicolons.
subjectstringyesEmail subject line.
bodystringyesHTML body content of the email.
fromstringnoSender email address (must be verified in your account).
from_namestringnoDisplay name for the sender.
reply_tostringnoReply-to email address.
ccstringnoCC recipients, separated by semicolons.
bccstringnoBCC recipients, separated by semicolons.

Example

local result = app.integrations["elastic-email"].send_email({
  to = "[email protected]",
  subject = "Welcome!",
  body = "<h1>Welcome aboard!</h1><p>Thanks for signing up.</p>",
  from = "[email protected]",
  from_name = "My App"
})

print(result.message)

list_templates

List email templates available in your Elastic Email account.

Parameters

NameTypeRequiredDescription
limitintegernoMax templates to return (default: 100)
offsetintegernoPagination offset (default: 0)

Example

local result = app.integrations["elastic-email"].list_templates({
  limit = 20
})

for _, tpl in ipairs(result.data or {}) do
  print(tpl.name .. " (ID: " .. tpl.id .. ")")
end

get_template

Get details of a specific email template by its ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe template ID

Example

local result = app.integrations["elastic-email"].get_template({
  id = 123
})

print(result.name)
print(result.subject)

list_contacts

List contacts from your Elastic Email account.

Parameters

NameTypeRequiredDescription
limitintegernoMax contacts to return (default: 100)
offsetintegernoPagination offset (default: 0)

Example

local result = app.integrations["elastic-email"].list_contacts({
  limit = 50
})

for _, contact in ipairs(result.data or {}) do
  print(contact.email)
end

create_contact

Create or add a contact in Elastic Email. Optionally assign to an existing list.

Parameters

NameTypeRequiredDescription
emailstringyesContact email address
list_namestringnoName of the list to add the contact to
first_namestringnoContact first name
last_namestringnoContact last name

Example

local result = app.integrations["elastic-email"].create_contact({
  email = "[email protected]",
  list_name = "Newsletter",
  first_name = "Jane",
  last_name = "Doe"
})

print(result.message)

get_current_user

Get information about the currently authenticated Elastic Email user account.

Parameters

None.

Example

local result = app.integrations["elastic-email"].get_current_user({})

print("Account: " .. result.email)
print("Plan: " .. (result.plan or "unknown"))

Multi-Account Usage

If you have multiple Elastic Email accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations["elastic-email"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["elastic-email"].default.function_name({...})

-- Named accounts
app.integrations["elastic-email"].marketing.function_name({...})
app.integrations["elastic-email"].transactional.function_name({...})

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

Raw agent markdown
# Elastic Email — Lua API Reference

## send_email

Send a transactional email via Elastic Email.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `to` | string | yes | Recipient email address. For multiple recipients, separate with semicolons. |
| `subject` | string | yes | Email subject line. |
| `body` | string | yes | HTML body content of the email. |
| `from` | string | no | Sender email address (must be verified in your account). |
| `from_name` | string | no | Display name for the sender. |
| `reply_to` | string | no | Reply-to email address. |
| `cc` | string | no | CC recipients, separated by semicolons. |
| `bcc` | string | no | BCC recipients, separated by semicolons. |

### Example

```lua
local result = app.integrations["elastic-email"].send_email({
  to = "[email protected]",
  subject = "Welcome!",
  body = "<h1>Welcome aboard!</h1><p>Thanks for signing up.</p>",
  from = "[email protected]",
  from_name = "My App"
})

print(result.message)
```

---

## list_templates

List email templates available in your Elastic Email account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max templates to return (default: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |

### Example

```lua
local result = app.integrations["elastic-email"].list_templates({
  limit = 20
})

for _, tpl in ipairs(result.data or {}) do
  print(tpl.name .. " (ID: " .. tpl.id .. ")")
end
```

---

## get_template

Get details of a specific email template by its ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The template ID |

### Example

```lua
local result = app.integrations["elastic-email"].get_template({
  id = 123
})

print(result.name)
print(result.subject)
```

---

## list_contacts

List contacts from your Elastic Email account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max contacts to return (default: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |

### Example

```lua
local result = app.integrations["elastic-email"].list_contacts({
  limit = 50
})

for _, contact in ipairs(result.data or {}) do
  print(contact.email)
end
```

---

## create_contact

Create or add a contact in Elastic Email. Optionally assign to an existing list.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | Contact email address |
| `list_name` | string | no | Name of the list to add the contact to |
| `first_name` | string | no | Contact first name |
| `last_name` | string | no | Contact last name |

### Example

```lua
local result = app.integrations["elastic-email"].create_contact({
  email = "[email protected]",
  list_name = "Newsletter",
  first_name = "Jane",
  last_name = "Doe"
})

print(result.message)
```

---

## get_current_user

Get information about the currently authenticated Elastic Email user account.

### Parameters

None.

### Example

```lua
local result = app.integrations["elastic-email"].get_current_user({})

print("Account: " .. result.email)
print("Plan: " .. (result.plan or "unknown"))
```

---

## Multi-Account Usage

If you have multiple Elastic Email accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations["elastic-email"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["elastic-email"].default.function_name({...})

-- Named accounts
app.integrations["elastic-email"].marketing.function_name({...})
app.integrations["elastic-email"].transactional.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.elastic_email.elasticemail_send_email({
  to = "example_to",
  subject = "example_subject",
  body = "example_body",
  from = "example_from",
  from_name = "example_from_name",
  reply_to = "example_reply_to",
  cc = "example_cc",
  bcc = "example_bcc"
})
print(result)

Functions

elasticemail_send_email

Send a transactional email via Elastic Email. Provide the recipient address, subject, and HTML body.

Operation
Write write
Full name
elastic-email.elasticemail_send_email
ParameterTypeRequiredDescription
to string yes Recipient email address. For multiple recipients, separate with semicolons.
subject string yes Email subject line.
body string yes HTML body content of the email.
from string no Sender email address (must be a verified sender in your Elastic Email account).
from_name string no Display name for the sender.
reply_to string no Reply-to email address.
cc string no CC recipients, separated by semicolons.
bcc string no BCC recipients, separated by semicolons.

elasticemail_list_templates

List email templates available in your Elastic Email account.

Operation
Read read
Full name
elastic-email.elasticemail_list_templates
ParameterTypeRequiredDescription
limit integer no Maximum number of templates to return (default: 100).
offset integer no Offset for pagination (default: 0).

elasticemail_get_template

Get details of a specific email template by its ID from Elastic Email.

Operation
Read read
Full name
elastic-email.elasticemail_get_template
ParameterTypeRequiredDescription
id integer yes The template ID.

elasticemail_list_contacts

List contacts from your Elastic Email account.

Operation
Read read
Full name
elastic-email.elasticemail_list_contacts
ParameterTypeRequiredDescription
limit integer no Maximum number of contacts to return (default: 100).
offset integer no Offset for pagination (default: 0).

elasticemail_create_contact

Create or add a contact in Elastic Email. Optionally assign the contact to an existing list.

Operation
Write write
Full name
elastic-email.elasticemail_create_contact
ParameterTypeRequiredDescription
email string yes Contact email address.
list_name string no Name of the list to add the contact to. The list must already exist in your Elastic Email account.
first_name string no Contact first name.
last_name string no Contact last name.

elasticemail_get_current_user

Get information about the currently authenticated Elastic Email user account.

Operation
Read read
Full name
elastic-email.elasticemail_get_current_user
ParameterTypeRequiredDescription
No parameters.