productivity
Mailjet Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Mailjet KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.mailjet.*.
Use lua_read_doc("integrations.mailjet") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Mailjet workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.mailjet.send_email({from_email = "example_from_email", from_name = "example_from_name", to_email = "example_to_email", to_emails = "example_to_emails", subject = "example_subject", html = "example_html", text = "example_text"}))' --json kosmo integrations:lua --eval 'print(docs.read("mailjet"))' --json
kosmo integrations:lua --eval 'print(docs.read("mailjet.send_email"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local mailjet = app.integrations.mailjet
local result = mailjet.send_email({from_email = "example_from_email", from_name = "example_from_name", to_email = "example_to_email", to_emails = "example_to_emails", subject = "example_subject", html = "example_html", text = "example_text"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.mailjet, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.mailjet.default.* or app.integrations.mailjet.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Mailjet, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Mailjet — Lua API Reference
send_email
Send an email via Mailjet.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
from_email | string | yes | Sender email address (must be verified in Mailjet) |
from_name | string | no | Sender display name |
to_email | string | yes* | Recipient email address (use to_emails for multiple) |
to_emails | array | yes* | Array of recipient email addresses |
subject | string | yes | Email subject line |
html | string | no | HTML body of the email |
text | string | no | Plain-text body of the email |
* Use either to_email (single) or to_emails (multiple), not both.
Examples
-- Send a simple email
local result = app.integrations.mailjet.send_email({
from_email = "hello@example.com",
from_name = "Acme Inc",
to_email = "customer@example.org",
subject = "Welcome!",
html = "<h1>Welcome to Acme</h1><p>Thanks for signing up!</p>"
})
-- Send to multiple recipients
local result = app.integrations.mailjet.send_email({
from_email = "news@example.com",
to_emails = {"alice@example.org", "bob@example.org"},
subject = "Monthly newsletter",
html = "<p>Here is your monthly update.</p>"
})
list_contacts
List contacts in the Mailjet account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Max contacts to return (default: 100) |
offset | integer | no | Pagination offset (default: 0) |
Examples
local result = app.integrations.mailjet.list_contacts({
limit = 50,
offset = 0
})
for _, contact in ipairs(result.Data) do
print(contact.Email)
end
get_contact
Get details for a single contact by ID or email.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | Contact ID or email address |
Examples
local result = app.integrations.mailjet.get_contact({
id = "user@example.com"
})
print(result.Data[1].Email)
create_contact
Create a new contact in Mailjet.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email | string | yes | Email address of the new contact |
Examples
local result = app.integrations.mailjet.create_contact({
email = "newuser@example.com"
})
print("Created contact: " .. result.Data[1].Email)
list_campaigns
List email campaigns in the Mailjet account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Max campaigns to return (default: 100) |
offset | integer | no | Pagination offset (default: 0) |
Examples
local result = app.integrations.mailjet.list_campaigns({
limit = 20
})
for _, campaign in ipairs(result.Data) do
print(campaign.ID .. ": " .. campaign.Subject)
end
get_campaign
Get details for a single campaign by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | Campaign ID |
Examples
local result = app.integrations.mailjet.get_campaign({
id = "12345"
})
print(result.Data[1].Subject)
list_templates
List email templates available in the Mailjet account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Max templates to return (default: 100) |
offset | integer | no | Pagination offset (default: 0) |
Examples
local result = app.integrations.mailjet.list_templates({})
for _, tpl in ipairs(result.Data) do
print(tpl.ID .. ": " .. tpl.Name)
end
get_stats
Get email statistics from the Mailjet statcounters endpoint.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
from_ts | string | no | Start timestamp (ISO 8601 or Unix epoch) |
to_ts | string | no | End timestamp (ISO 8601 or Unix epoch) |
limit | integer | no | Max stat records to return (default: 100) |
offset | integer | no | Pagination offset (default: 0) |
Examples
local result = app.integrations.mailjet.get_stats({
from_ts = "2026-01-01T00:00:00Z",
to_ts = "2026-01-31T23:59:59Z"
})
for _, stat in ipairs(result.Data) do
print("Sent: " .. stat.MessageSentCount .. ", Opened: " .. stat.MessageOpenedCount)
end
get_current_user
Get the authenticated Mailjet user profile information.
Parameters
None.
Examples
local result = app.integrations.mailjet.get_current_user({})
print(result.Data[1].Email)
Multi-Account Usage
If you have multiple Mailjet accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.mailjet.send_email({...})
-- Explicit default (portable across setups)
app.integrations.mailjet.default.send_email({...})
-- Named accounts
app.integrations.mailjet.marketing.send_email({...})
app.integrations.mailjet.transactional.send_email({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Mailjet — Lua API Reference
## send_email
Send an email via Mailjet.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `from_email` | string | yes | Sender email address (must be verified in Mailjet) |
| `from_name` | string | no | Sender display name |
| `to_email` | string | yes* | Recipient email address (use `to_emails` for multiple) |
| `to_emails` | array | yes* | Array of recipient email addresses |
| `subject` | string | yes | Email subject line |
| `html` | string | no | HTML body of the email |
| `text` | string | no | Plain-text body of the email |
\* Use either `to_email` (single) or `to_emails` (multiple), not both.
### Examples
```lua
-- Send a simple email
local result = app.integrations.mailjet.send_email({
from_email = "hello@example.com",
from_name = "Acme Inc",
to_email = "customer@example.org",
subject = "Welcome!",
html = "<h1>Welcome to Acme</h1><p>Thanks for signing up!</p>"
})
-- Send to multiple recipients
local result = app.integrations.mailjet.send_email({
from_email = "news@example.com",
to_emails = {"alice@example.org", "bob@example.org"},
subject = "Monthly newsletter",
html = "<p>Here is your monthly update.</p>"
})
```
---
## list_contacts
List contacts in the Mailjet account.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max contacts to return (default: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |
### Examples
```lua
local result = app.integrations.mailjet.list_contacts({
limit = 50,
offset = 0
})
for _, contact in ipairs(result.Data) do
print(contact.Email)
end
```
---
## get_contact
Get details for a single contact by ID or email.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Contact ID or email address |
### Examples
```lua
local result = app.integrations.mailjet.get_contact({
id = "user@example.com"
})
print(result.Data[1].Email)
```
---
## create_contact
Create a new contact in Mailjet.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | Email address of the new contact |
### Examples
```lua
local result = app.integrations.mailjet.create_contact({
email = "newuser@example.com"
})
print("Created contact: " .. result.Data[1].Email)
```
---
## list_campaigns
List email campaigns in the Mailjet account.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max campaigns to return (default: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |
### Examples
```lua
local result = app.integrations.mailjet.list_campaigns({
limit = 20
})
for _, campaign in ipairs(result.Data) do
print(campaign.ID .. ": " .. campaign.Subject)
end
```
---
## get_campaign
Get details for a single campaign by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Campaign ID |
### Examples
```lua
local result = app.integrations.mailjet.get_campaign({
id = "12345"
})
print(result.Data[1].Subject)
```
---
## list_templates
List email templates available in the Mailjet account.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max templates to return (default: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |
### Examples
```lua
local result = app.integrations.mailjet.list_templates({})
for _, tpl in ipairs(result.Data) do
print(tpl.ID .. ": " .. tpl.Name)
end
```
---
## get_stats
Get email statistics from the Mailjet statcounters endpoint.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `from_ts` | string | no | Start timestamp (ISO 8601 or Unix epoch) |
| `to_ts` | string | no | End timestamp (ISO 8601 or Unix epoch) |
| `limit` | integer | no | Max stat records to return (default: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |
### Examples
```lua
local result = app.integrations.mailjet.get_stats({
from_ts = "2026-01-01T00:00:00Z",
to_ts = "2026-01-31T23:59:59Z"
})
for _, stat in ipairs(result.Data) do
print("Sent: " .. stat.MessageSentCount .. ", Opened: " .. stat.MessageOpenedCount)
end
```
---
## get_current_user
Get the authenticated Mailjet user profile information.
### Parameters
None.
### Examples
```lua
local result = app.integrations.mailjet.get_current_user({})
print(result.Data[1].Email)
```
---
## Multi-Account Usage
If you have multiple Mailjet accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.mailjet.send_email({...})
-- Explicit default (portable across setups)
app.integrations.mailjet.default.send_email({...})
-- Named accounts
app.integrations.mailjet.marketing.send_email({...})
app.integrations.mailjet.transactional.send_email({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.mailjet.send_email({from_email = "example_from_email", from_name = "example_from_name", to_email = "example_to_email", to_emails = "example_to_emails", subject = "example_subject", html = "example_html", text = "example_text"})
print(result) Functions
send_email Write
Send an email via Mailjet. Specify sender, one or more recipients, subject, and HTML body.
- Lua path
app.integrations.mailjet.send_email- Full name
mailjet.mailjet_send_email
| Parameter | Type | Required | Description |
|---|---|---|---|
from_email | string | yes | Sender email address (must be a verified sender in Mailjet). |
from_name | string | no | Sender display name. |
to_email | string | yes | Recipient email address. For multiple recipients, use to_emails instead. |
to_emails | array | no | Array of recipient email addresses. Use this OR to_email, not both. |
subject | string | yes | Email subject line. |
html | string | no | HTML body of the email. |
text | string | no | Plain-text body of the email (fallback when HTML is not supported). |
list_contacts Read
List contacts in the Mailjet account. Returns paginated contact data including email addresses and metadata.
- Lua path
app.integrations.mailjet.list_contacts- Full name
mailjet.mailjet_list_contacts
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of contacts to return (default: 100). |
offset | integer | no | Offset for pagination (default: 0). |
get_contact Read
Get details for a single Mailjet contact by ID or email address.
- Lua path
app.integrations.mailjet.get_contact- Full name
mailjet.mailjet_get_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The contact ID or email address. |
create_contact Write
Create a new contact in Mailjet. Provide the email address to add.
- Lua path
app.integrations.mailjet.create_contact- Full name
mailjet.mailjet_create_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | yes | The email address of the new contact. |
list_campaigns Read
List email campaigns in the Mailjet account. Returns campaign IDs, subjects, and status.
- Lua path
app.integrations.mailjet.list_campaigns- Full name
mailjet.mailjet_list_campaigns
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of campaigns to return (default: 100). |
offset | integer | no | Offset for pagination (default: 0). |
get_campaign Read
Get details for a single Mailjet email campaign by ID.
- Lua path
app.integrations.mailjet.get_campaign- Full name
mailjet.mailjet_get_campaign
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The campaign ID. |
list_templates Read
List email templates available in the Mailjet account.
- Lua path
app.integrations.mailjet.list_templates- Full name
mailjet.mailjet_list_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of templates to return (default: 100). |
offset | integer | no | Offset for pagination (default: 0). |
get_stats Read
Get email statistics from the Mailjet statcounters endpoint. Returns send, delivery, open, click, and bounce counts.
- Lua path
app.integrations.mailjet.get_stats- Full name
mailjet.mailjet_get_stats
| Parameter | Type | Required | Description |
|---|---|---|---|
from_ts | string | no | Start timestamp (ISO 8601 or Unix epoch) for the stats window. |
to_ts | string | no | End timestamp (ISO 8601 or Unix epoch) for the stats window. |
limit | integer | no | Maximum number of stat records to return (default: 100). |
offset | integer | no | Offset for pagination (default: 0). |
get_current_user Read
Get the authenticated Mailjet user profile information.
- Lua path
app.integrations.mailjet.get_current_user- Full name
mailjet.mailjet_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||