KosmoKrator

other

Sendy Lua API for KosmoKrator Agents

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

5 functions 2 read 3 write API key auth

Lua Namespace

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

Sendy — Lua API Reference

subscribe

Subscribe an email address to a Sendy mailing list.

Parameters

NameTypeRequiredDescription
liststringyesThe list ID to subscribe to
emailstringyesThe subscriber’s email address
namestringnoThe subscriber’s name

Response

On success, returns { list, email, message }. Common messages include "Subscribed successfully." and "Already subscribed.".

Examples

local result = app.integrations.sendy.subscribe({
  list = "abc123",
  email = "[email protected]",
  name = "John Doe"
})

print(result.message)

unsubscribe

Unsubscribe an email address from a Sendy mailing list.

Parameters

NameTypeRequiredDescription
liststringyesThe list ID to unsubscribe from
emailstringyesThe subscriber’s email address

Examples

local result = app.integrations.sendy.unsubscribe({
  list = "abc123",
  email = "[email protected]"
})

print(result.message)

list_subscribers

Get the total subscriber count for a Sendy list.

Parameters

NameTypeRequiredDescription
list_idstringyesThe list ID to query

Examples

local result = app.integrations.sendy.list_subscribers({
  list_id = "abc123"
})

print("Subscribers: " .. result.subscribers)

create_campaign

Create a new email campaign in Sendy. Can be saved as a draft or sent immediately.

Parameters

NameTypeRequiredDescription
from_namestringyesSender name
from_emailstringyesSender email address
reply_tostringyesReply-to email address
titlestringyesInternal campaign title (for reference)
subjectstringyesEmail subject line
html_textstringyesHTML content of the email
list_idsstringyesComma-separated list IDs to send to
plain_textstringnoPlain text version (auto-generated if omitted)
send_campaignintegerno1 to send immediately, 0 or omit to save as draft
brand_idstringnoBrand ID (required for multi-brand setups)
query_stringstringnoUTM query string appended to links

Examples

Save as draft

local result = app.integrations.sendy.create_campaign({
  from_name = "Acme Corp",
  from_email = "[email protected]",
  reply_to = "[email protected]",
  title = "April Newsletter",
  subject = "What's new at Acme",
  html_text = "<h1>Hello!</h1><p>Here's what's new...</p>",
  list_ids = "abc123,def456"
})

print("Campaign created: " .. (result.campaign_id or "draft"))

Send immediately

local result = app.integrations.sendy.create_campaign({
  from_name = "Acme Corp",
  from_email = "[email protected]",
  reply_to = "[email protected]",
  title = "Flash Sale!",
  subject = "50% off — today only",
  html_text = "<h1>Flash Sale!</h1><p>Get 50% off everything...</p>",
  list_ids = "abc123",
  send_campaign = 1
})

print(result.message)

get_current_user

Get the current brand/account information from Sendy. Useful for verifying credentials.

Parameters

None.

Examples

local result = app.integrations.sendy.get_current_user({})

print("Brand: " .. (result.message or "verified"))

Multi-Account Usage

If you have multiple Sendy instances configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.sendy.subscribe({...})

-- Explicit default (portable across setups)
app.integrations.sendy.default.subscribe({...})

-- Named accounts
app.integrations.sendy.marketing.subscribe({...})
app.integrations.sendy.internal.subscribe({...})

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

Raw agent markdown
# Sendy — Lua API Reference

## subscribe

Subscribe an email address to a Sendy mailing list.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `list` | string | yes | The list ID to subscribe to |
| `email` | string | yes | The subscriber's email address |
| `name` | string | no | The subscriber's name |

### Response

On success, returns `{ list, email, message }`. Common messages include `"Subscribed successfully."` and `"Already subscribed."`.

### Examples

```lua
local result = app.integrations.sendy.subscribe({
  list = "abc123",
  email = "[email protected]",
  name = "John Doe"
})

print(result.message)
```

---

## unsubscribe

Unsubscribe an email address from a Sendy mailing list.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `list` | string | yes | The list ID to unsubscribe from |
| `email` | string | yes | The subscriber's email address |

### Examples

```lua
local result = app.integrations.sendy.unsubscribe({
  list = "abc123",
  email = "[email protected]"
})

print(result.message)
```

---

## list_subscribers

Get the total subscriber count for a Sendy list.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `list_id` | string | yes | The list ID to query |

### Examples

```lua
local result = app.integrations.sendy.list_subscribers({
  list_id = "abc123"
})

print("Subscribers: " .. result.subscribers)
```

---

## create_campaign

Create a new email campaign in Sendy. Can be saved as a draft or sent immediately.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `from_name` | string | yes | Sender name |
| `from_email` | string | yes | Sender email address |
| `reply_to` | string | yes | Reply-to email address |
| `title` | string | yes | Internal campaign title (for reference) |
| `subject` | string | yes | Email subject line |
| `html_text` | string | yes | HTML content of the email |
| `list_ids` | string | yes | Comma-separated list IDs to send to |
| `plain_text` | string | no | Plain text version (auto-generated if omitted) |
| `send_campaign` | integer | no | `1` to send immediately, `0` or omit to save as draft |
| `brand_id` | string | no | Brand ID (required for multi-brand setups) |
| `query_string` | string | no | UTM query string appended to links |

### Examples

#### Save as draft

```lua
local result = app.integrations.sendy.create_campaign({
  from_name = "Acme Corp",
  from_email = "[email protected]",
  reply_to = "[email protected]",
  title = "April Newsletter",
  subject = "What's new at Acme",
  html_text = "<h1>Hello!</h1><p>Here's what's new...</p>",
  list_ids = "abc123,def456"
})

print("Campaign created: " .. (result.campaign_id or "draft"))
```

#### Send immediately

```lua
local result = app.integrations.sendy.create_campaign({
  from_name = "Acme Corp",
  from_email = "[email protected]",
  reply_to = "[email protected]",
  title = "Flash Sale!",
  subject = "50% off — today only",
  html_text = "<h1>Flash Sale!</h1><p>Get 50% off everything...</p>",
  list_ids = "abc123",
  send_campaign = 1
})

print(result.message)
```

---

## get_current_user

Get the current brand/account information from Sendy. Useful for verifying credentials.

### Parameters

None.

### Examples

```lua
local result = app.integrations.sendy.get_current_user({})

print("Brand: " .. (result.message or "verified"))
```

---

## Multi-Account Usage

If you have multiple Sendy instances configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.sendy.subscribe({...})

-- Explicit default (portable across setups)
app.integrations.sendy.default.subscribe({...})

-- Named accounts
app.integrations.sendy.marketing.subscribe({...})
app.integrations.sendy.internal.subscribe({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.sendy.sendy_subscribe({
  list = "example_list",
  email = "example_email",
  name = "example_name"
})
print(result)

Functions

sendy_subscribe

Subscribe an email address to a Sendy mailing list. Optionally provide a name and custom fields.

Operation
Write write
Full name
sendy.sendy_subscribe
ParameterTypeRequiredDescription
list string yes The list ID to subscribe to.
email string yes The subscriber's email address.
name string no The subscriber's name (optional).

sendy_unsubscribe

Unsubscribe an email address from a Sendy mailing list.

Operation
Write write
Full name
sendy.sendy_unsubscribe
ParameterTypeRequiredDescription
list string yes The list ID to unsubscribe from.
email string yes The subscriber's email address.

sendy_list_subscribers

Get the total number of subscribers for a Sendy mailing list.

Operation
Read read
Full name
sendy.sendy_list_subscribers
ParameterTypeRequiredDescription
list_id string yes The list ID to query subscriber count for.

sendy_create_campaign

Create a new email campaign in Sendy. You can create a draft or send immediately. Requires a list ID, subject, HTML content, and sender details.

Operation
Write write
Full name
sendy.sendy_create_campaign
ParameterTypeRequiredDescription
from_name string yes Sender name (e.g., "Acme Corp").
from_email string yes Sender email address (e.g., "[email protected]").
reply_to string yes Reply-to email address.
title string yes Internal campaign title (for your reference).
subject string yes Email subject line.
html_text string yes HTML content of the email.
list_ids string yes Comma-separated list IDs to send to.
plain_text string no Plain text version of the email. Auto-generated if omitted.
send_campaign integer no Set to 1 to send immediately, 0 or omit to save as draft.
brand_id string no Brand ID (required for multi-brand setups).
query_string string no UTM query string appended to links (e.g., "utm_source=sendy&utm_medium=email").

sendy_get_current_user

Get the current brand/account information from Sendy. Useful for verifying credentials and retrieving brand details.

Operation
Read read
Full name
sendy.sendy_get_current_user
ParameterTypeRequiredDescription
No parameters.