productivity
SparkPost Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the SparkPost KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.spark_post.*.
Use lua_read_doc("integrations.spark-post") 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
SparkPost workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.spark_post.list_sending_domains({limit = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("spark-post"))' --json
kosmo integrations:lua --eval 'print(docs.read("spark-post.list_sending_domains"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local spark_post = app.integrations.spark_post
local result = spark_post.list_sending_domains({limit = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.spark_post, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.spark_post.default.* or app.integrations.spark_post.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need SparkPost, 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.
SparkPost — Lua API Reference
list_sending_domains
List sending domains configured in SparkPost.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of domains to return (default: 100) |
Example
local result = app.integrations["spark-post"].list_sending_domains({
limit = 50
})
for _, domain in ipairs(result.results) do
print(domain.domain .. " — verified: " .. tostring(domain.status.verified))
end
get_sending_domain
Get details for a specific sending domain.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
domain | string | yes | The domain name (e.g., "example.com") |
Example
local result = app.integrations["spark-post"].get_sending_domain({
domain = "example.com"
})
print(result.results.domain)
print("DKIM verified: " .. tostring(result.results.status.dkim_status))
list_templates
List email templates in SparkPost.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of templates to return (default: 100) |
offset | integer | no | Number of templates to skip for pagination (default: 0) |
Example
local result = app.integrations["spark-post"].list_templates({
limit = 20,
offset = 0
})
for _, tpl in ipairs(result.results) do
print(tpl.id .. ": " .. (tpl.name or "unnamed"))
end
get_template
Get a specific email template by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The template ID |
draft | boolean | no | Set to true to retrieve the draft version (default: false) |
Example
local result = app.integrations["spark-post"].get_template({
id = "my-template-id",
draft = false
})
print(result.results.name)
print("Subject: " .. result.results.content.subject)
send_transmission
Send an email transmission via SparkPost.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
content | object | yes | Email content with from, subject, and optional html/text |
recipients | array | yes | Array of recipient objects, each with address.email |
Content Object
| Field | Type | Required | Description |
|---|---|---|---|
from | string or object | yes | Sender email address (string) or object with email and name |
subject | string | yes | Email subject line |
html | string | no | HTML body content |
text | string | no | Plain text body content |
Recipient Format
Each recipient is an object with an address field:
{ address = { email = "user@example.com", name = "User Name" } }
Example — Simple email
local result = app.integrations["spark-post"].send_transmission({
content = {
from = "noreply@example.com",
subject = "Hello from SparkPost",
html = "<h1>Welcome!</h1><p>This is a test email.</p>",
text = "Welcome! This is a test email."
},
recipients = {
{ address = { email = "alice@example.com" } },
{ address = { email = "bob@example.com", name = "Bob" } }
}
})
print("Accepted: " .. result.results.total_accepted_recipients)
print("Rejected: " .. result.results.total_rejected_recipients)
Example — Named sender
local result = app.integrations["spark-post"].send_transmission({
content = {
from = { email = "team@example.com", name = "Team Example" },
subject = "Monthly Newsletter",
html = "<p>Here is your newsletter.</p>"
},
recipients = {
{ address = { email = "subscriber@example.com" } }
}
})
list_webhooks
List webhooks configured in SparkPost.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of webhooks to return (default: 100) |
offset | integer | no | Number of webhooks to skip for pagination (default: 0) |
Example
local result = app.integrations["spark-post"].list_webhooks({
limit = 50
})
for _, hook in ipairs(result.results) do
print(hook.id .. " → " .. hook.target .. " (" .. #hook.events .. " events)")
end
get_current_user
Get the current SparkPost account information.
Parameters
None.
Example
local result = app.integrations["spark-post"].get_current_user({})
print("Account: " .. result.results.company_name)
print("Status: " .. result.results.status)
Multi-Account Usage
If you have multiple SparkPost accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations["spark-post"].list_sending_domains({})
-- Explicit default (portable across setups)
app.integrations["spark-post"].default.list_sending_domains({})
-- Named accounts
app.integrations["spark-post"].production.list_sending_domains({})
app.integrations["spark-post"].staging.list_sending_domains({})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# SparkPost — Lua API Reference
## list_sending_domains
List sending domains configured in SparkPost.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of domains to return (default: 100) |
### Example
```lua
local result = app.integrations["spark-post"].list_sending_domains({
limit = 50
})
for _, domain in ipairs(result.results) do
print(domain.domain .. " — verified: " .. tostring(domain.status.verified))
end
```
---
## get_sending_domain
Get details for a specific sending domain.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `domain` | string | yes | The domain name (e.g., `"example.com"`) |
### Example
```lua
local result = app.integrations["spark-post"].get_sending_domain({
domain = "example.com"
})
print(result.results.domain)
print("DKIM verified: " .. tostring(result.results.status.dkim_status))
```
---
## list_templates
List email templates in SparkPost.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of templates to return (default: 100) |
| `offset` | integer | no | Number of templates to skip for pagination (default: 0) |
### Example
```lua
local result = app.integrations["spark-post"].list_templates({
limit = 20,
offset = 0
})
for _, tpl in ipairs(result.results) do
print(tpl.id .. ": " .. (tpl.name or "unnamed"))
end
```
---
## get_template
Get a specific email template by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The template ID |
| `draft` | boolean | no | Set to `true` to retrieve the draft version (default: `false`) |
### Example
```lua
local result = app.integrations["spark-post"].get_template({
id = "my-template-id",
draft = false
})
print(result.results.name)
print("Subject: " .. result.results.content.subject)
```
---
## send_transmission
Send an email transmission via SparkPost.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content` | object | yes | Email content with `from`, `subject`, and optional `html`/`text` |
| `recipients` | array | yes | Array of recipient objects, each with `address.email` |
### Content Object
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `from` | string or object | yes | Sender email address (string) or object with `email` and `name` |
| `subject` | string | yes | Email subject line |
| `html` | string | no | HTML body content |
| `text` | string | no | Plain text body content |
### Recipient Format
Each recipient is an object with an `address` field:
```lua
{ address = { email = "user@example.com", name = "User Name" } }
```
### Example — Simple email
```lua
local result = app.integrations["spark-post"].send_transmission({
content = {
from = "noreply@example.com",
subject = "Hello from SparkPost",
html = "<h1>Welcome!</h1><p>This is a test email.</p>",
text = "Welcome! This is a test email."
},
recipients = {
{ address = { email = "alice@example.com" } },
{ address = { email = "bob@example.com", name = "Bob" } }
}
})
print("Accepted: " .. result.results.total_accepted_recipients)
print("Rejected: " .. result.results.total_rejected_recipients)
```
### Example — Named sender
```lua
local result = app.integrations["spark-post"].send_transmission({
content = {
from = { email = "team@example.com", name = "Team Example" },
subject = "Monthly Newsletter",
html = "<p>Here is your newsletter.</p>"
},
recipients = {
{ address = { email = "subscriber@example.com" } }
}
})
```
---
## list_webhooks
List webhooks configured in SparkPost.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of webhooks to return (default: 100) |
| `offset` | integer | no | Number of webhooks to skip for pagination (default: 0) |
### Example
```lua
local result = app.integrations["spark-post"].list_webhooks({
limit = 50
})
for _, hook in ipairs(result.results) do
print(hook.id .. " → " .. hook.target .. " (" .. #hook.events .. " events)")
end
```
---
## get_current_user
Get the current SparkPost account information.
### Parameters
None.
### Example
```lua
local result = app.integrations["spark-post"].get_current_user({})
print("Account: " .. result.results.company_name)
print("Status: " .. result.results.status)
```
---
## Multi-Account Usage
If you have multiple SparkPost accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations["spark-post"].list_sending_domains({})
-- Explicit default (portable across setups)
app.integrations["spark-post"].default.list_sending_domains({})
-- Named accounts
app.integrations["spark-post"].production.list_sending_domains({})
app.integrations["spark-post"].staging.list_sending_domains({})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.spark_post.list_sending_domains({limit = 1})
print(result) Functions
list_sending_domains Read
List sending domains configured in SparkPost. Returns domain names along with verification and DKIM signing status.
- Lua path
app.integrations.spark_post.list_sending_domains- Full name
spark-post.spark_post_list_sending_domains
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of sending domains to return (default: 100). |
get_sending_domain Read
Get details for a specific sending domain in SparkPost. Returns verification status, DKIM signing info, and SPF records.
- Lua path
app.integrations.spark_post.get_sending_domain- Full name
spark-post.spark_post_get_sending_domain
| Parameter | Type | Required | Description |
|---|---|---|---|
domain | string | yes | The sending domain name to look up (e.g., "example.com"). |
list_templates Read
List email templates in SparkPost. Returns template IDs, names, and published status.
- Lua path
app.integrations.spark_post.list_templates- Full name
spark-post.spark_post_list_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of templates to return (default: 100). |
offset | integer | no | Number of templates to skip for pagination (default: 0). |
get_template Read
Get a specific email template by ID from SparkPost. Can retrieve the draft or published version.
- Lua path
app.integrations.spark_post.get_template- Full name
spark-post.spark_post_get_template
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The template ID to retrieve. |
draft | boolean | no | Set to true to retrieve the draft version of the template. Defaults to false (published version). |
send_transmission Write
Send an email transmission via SparkPost. Provide sender address, subject, content (HTML and/or text), and a list of recipients.
- Lua path
app.integrations.spark_post.send_transmission- Full name
spark-post.spark_post_send_transmission
| Parameter | Type | Required | Description |
|---|---|---|---|
content | object | yes | Email content object. Must include "from" (email address or object with "email" and "name") and "subject". Optionally include "html" and/or "text" for the email body. |
recipients | array | yes | Array of recipient objects. Each must have an "address" object with an "email" field (and optional "name"). Example: [{"address": {"email": "user@example.com", "name": "User"}}] |
list_webhooks Read
List webhooks configured in SparkPost. Returns webhook IDs, target URLs, and subscribed event types.
- Lua path
app.integrations.spark_post.list_webhooks- Full name
spark-post.spark_post_list_webhooks
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of webhooks to return (default: 100). |
offset | integer | no | Number of webhooks to skip for pagination (default: 0). |
get_current_user Read
Get current SparkPost account information. Returns account status, subscription plan, and usage details.
- Lua path
app.integrations.spark_post.get_current_user- Full name
spark-post.spark_post_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||