KosmoKrator

marketing

SparkPost Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API key auth

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.

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

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

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

NameTypeRequiredDescription
limitintegernoMaximum number of templates to return (default: 100)
offsetintegernoNumber 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

NameTypeRequiredDescription
idstringyesThe template ID
draftbooleannoSet 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

NameTypeRequiredDescription
contentobjectyesEmail content with from, subject, and optional html/text
recipientsarrayyesArray of recipient objects, each with address.email

Content Object

FieldTypeRequiredDescription
fromstring or objectyesSender email address (string) or object with email and name
subjectstringyesEmail subject line
htmlstringnoHTML body content
textstringnoPlain text body content

Recipient Format

Each recipient is an object with an address field:

{ address = { email = "[email protected]", name = "User Name" } }

Example — Simple email

local result = app.integrations["spark-post"].send_transmission({
  content = {
    from = "[email protected]",
    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 = "[email protected]" } },
    { address = { email = "[email protected]", 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 = "[email protected]", name = "Team Example" },
    subject = "Monthly Newsletter",
    html = "<p>Here is your newsletter.</p>"
  },
  recipients = {
    { address = { email = "[email protected]" } }
  }
})

list_webhooks

List webhooks configured in SparkPost.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of webhooks to return (default: 100)
offsetintegernoNumber 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 = "[email protected]", name = "User Name" } }
```

### Example — Simple email

```lua
local result = app.integrations["spark-post"].send_transmission({
  content = {
    from = "[email protected]",
    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 = "[email protected]" } },
    { address = { email = "[email protected]", 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 = "[email protected]", name = "Team Example" },
    subject = "Monthly Newsletter",
    html = "<p>Here is your newsletter.</p>"
  },
  recipients = {
    { address = { email = "[email protected]" } }
  }
})
```

---

## 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.

Metadata-Derived Lua Example

local result = app.integrations.spark_post.spark_post_list_sending_domains({
  limit = 1
})
print(result)

Functions

spark_post_list_sending_domains

List sending domains configured in SparkPost. Returns domain names along with verification and DKIM signing status.

Operation
Read read
Full name
spark-post.spark_post_list_sending_domains
ParameterTypeRequiredDescription
limit integer no Maximum number of sending domains to return (default: 100).

spark_post_get_sending_domain

Get details for a specific sending domain in SparkPost. Returns verification status, DKIM signing info, and SPF records.

Operation
Read read
Full name
spark-post.spark_post_get_sending_domain
ParameterTypeRequiredDescription
domain string yes The sending domain name to look up (e.g., "example.com").

spark_post_list_templates

List email templates in SparkPost. Returns template IDs, names, and published status.

Operation
Read read
Full name
spark-post.spark_post_list_templates
ParameterTypeRequiredDescription
limit integer no Maximum number of templates to return (default: 100).
offset integer no Number of templates to skip for pagination (default: 0).

spark_post_get_template

Get a specific email template by ID from SparkPost. Can retrieve the draft or published version.

Operation
Read read
Full name
spark-post.spark_post_get_template
ParameterTypeRequiredDescription
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).

spark_post_send_transmission

Send an email transmission via SparkPost. Provide sender address, subject, content (HTML and/or text), and a list of recipients.

Operation
Write write
Full name
spark-post.spark_post_send_transmission
ParameterTypeRequiredDescription
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": "[email protected]", "name": "User"}}]

spark_post_list_webhooks

List webhooks configured in SparkPost. Returns webhook IDs, target URLs, and subscribed event types.

Operation
Read read
Full name
spark-post.spark_post_list_webhooks
ParameterTypeRequiredDescription
limit integer no Maximum number of webhooks to return (default: 100).
offset integer no Number of webhooks to skip for pagination (default: 0).

spark_post_get_current_user

Get current SparkPost account information. Returns account status, subscription plan, and usage details.

Operation
Read read
Full name
spark-post.spark_post_get_current_user
ParameterTypeRequiredDescription
No parameters.