KosmoKrator

email

Mailjet Lua API for KosmoKrator Agents

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

9 functions 7 read 2 write API key auth

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.

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

NameTypeRequiredDescription
from_emailstringyesSender email address (must be verified in Mailjet)
from_namestringnoSender display name
to_emailstringyes*Recipient email address (use to_emails for multiple)
to_emailsarrayyes*Array of recipient email addresses
subjectstringyesEmail subject line
htmlstringnoHTML body of the email
textstringnoPlain-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 = "[email protected]",
  from_name = "Acme Inc",
  to_email = "[email protected]",
  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 = "[email protected]",
  to_emails = {"[email protected]", "[email protected]"},
  subject = "Monthly newsletter",
  html = "<p>Here is your monthly update.</p>"
})

list_contacts

List contacts in the Mailjet account.

Parameters

NameTypeRequiredDescription
limitintegernoMax contacts to return (default: 100)
offsetintegernoPagination 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

NameTypeRequiredDescription
idstringyesContact ID or email address

Examples

local result = app.integrations.mailjet.get_contact({
  id = "[email protected]"
})
print(result.Data[1].Email)

create_contact

Create a new contact in Mailjet.

Parameters

NameTypeRequiredDescription
emailstringyesEmail address of the new contact

Examples

local result = app.integrations.mailjet.create_contact({
  email = "[email protected]"
})
print("Created contact: " .. result.Data[1].Email)

list_campaigns

List email campaigns in the Mailjet account.

Parameters

NameTypeRequiredDescription
limitintegernoMax campaigns to return (default: 100)
offsetintegernoPagination 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

NameTypeRequiredDescription
idstringyesCampaign 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

NameTypeRequiredDescription
limitintegernoMax templates to return (default: 100)
offsetintegernoPagination 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

NameTypeRequiredDescription
from_tsstringnoStart timestamp (ISO 8601 or Unix epoch)
to_tsstringnoEnd timestamp (ISO 8601 or Unix epoch)
limitintegernoMax stat records to return (default: 100)
offsetintegernoPagination 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 = "[email protected]",
  from_name = "Acme Inc",
  to_email = "[email protected]",
  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 = "[email protected]",
  to_emails = {"[email protected]", "[email protected]"},
  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 = "[email protected]"
})
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 = "[email protected]"
})
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.

Metadata-Derived Lua Example

local result = app.integrations.mailjet.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

mailjet_send_email

Send an email via Mailjet. Specify sender, one or more recipients, subject, and HTML body.

Operation
Write write
Full name
mailjet.mailjet_send_email
ParameterTypeRequiredDescription
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).

mailjet_list_contacts

List contacts in the Mailjet account. Returns paginated contact data including email addresses and metadata.

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

mailjet_get_contact

Get details for a single Mailjet contact by ID or email address.

Operation
Read read
Full name
mailjet.mailjet_get_contact
ParameterTypeRequiredDescription
id string yes The contact ID or email address.

mailjet_create_contact

Create a new contact in Mailjet. Provide the email address to add.

Operation
Write write
Full name
mailjet.mailjet_create_contact
ParameterTypeRequiredDescription
email string yes The email address of the new contact.

mailjet_list_campaigns

List email campaigns in the Mailjet account. Returns campaign IDs, subjects, and status.

Operation
Read read
Full name
mailjet.mailjet_list_campaigns
ParameterTypeRequiredDescription
limit integer no Maximum number of campaigns to return (default: 100).
offset integer no Offset for pagination (default: 0).

mailjet_get_campaign

Get details for a single Mailjet email campaign by ID.

Operation
Read read
Full name
mailjet.mailjet_get_campaign
ParameterTypeRequiredDescription
id string yes The campaign ID.

mailjet_list_templates

List email templates available in the Mailjet account.

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

mailjet_get_stats

Get email statistics from the Mailjet statcounters endpoint. Returns send, delivery, open, click, and bounce counts.

Operation
Read read
Full name
mailjet.mailjet_get_stats
ParameterTypeRequiredDescription
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).

mailjet_get_current_user

Get the authenticated Mailjet user profile information.

Operation
Read read
Full name
mailjet.mailjet_get_current_user
ParameterTypeRequiredDescription
No parameters.