productivity
Loops Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Loops KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.loops.*.
Use lua_read_doc("integrations.loops") 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
Loops workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.loops.create_contact({}))' --json kosmo integrations:lua --eval 'print(docs.read("loops"))' --json
kosmo integrations:lua --eval 'print(docs.read("loops.create_contact"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local loops = app.integrations.loops
local result = loops.create_contact({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.loops, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.loops.default.* or app.integrations.loops.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Loops, 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.
Loops - Lua API Reference
Namespace: app.integrations.loops
The Loops API lets agents manage contacts, send events, send transactional email, read mailing lists and contact properties, manage suppression status, and inspect sending configuration.
Contacts
app.integrations.loops.create_contact({
email = "reader@example.test",
firstName = "Ada",
lastName = "Lovelace",
userId = "user_123",
properties = {
planName = "Pro"
}
})
app.integrations.loops.update_contact({
email = "reader@example.test",
subscribed = false
})
local contacts = app.integrations.loops.find_contact({
email = "reader@example.test"
})
app.integrations.loops.delete_contact({
userId = "user_123"
})
For find_contact, delete_contact, and suppression tools, provide exactly one
of email or userId.
Contact Properties And Lists
app.integrations.loops.create_contact_property({
name = "planName",
type = "string"
})
local properties = app.integrations.loops.list_contact_properties({})
local lists = app.integrations.loops.list_mailing_lists({})
Property names must be camelCase. Supported property types are string,
number, boolean, and date.
Events
app.integrations.loops.send_event({
email = "reader@example.test",
eventName = "trial_started",
eventProperties = {
plan = "Pro"
}
})
Events can identify contacts by email or userId and can include
eventProperties.
Transactional Email
app.integrations.loops.send_transactional_email({
email = "reader@example.test",
transactionalId = "clw6rbuwp01rmeiyndm80155l",
addToAudience = true,
dataVariables = {
loginUrl = "https://example.test/login"
},
idempotency_key = "550e8400-e29b-41d4-a716-446655440000"
})
local emails = app.integrations.loops.list_transactional_emails({
perPage = 20
})
Attachments can be sent with attachments, each containing filename,
contentType, and base64 data.
Suppression And Configuration
local status = app.integrations.loops.check_contact_suppression({
email = "reader@example.test"
})
app.integrations.loops.remove_contact_suppression({
email = "reader@example.test"
})
local key = app.integrations.loops.test_api_key({})
local ips = app.integrations.loops.list_dedicated_sending_ips({})
Suppression removal is quota-limited by Loops. Dedicated sending IPs are only for rare allowlisting workflows and may change over time.
Multi-Account Usage
app.integrations.loops.create_contact({ email = "reader@example.test" })
app.integrations.loops.default.create_contact({ email = "reader@example.test" })
app.integrations.loops.marketing.create_contact({ email = "reader@example.test" })
All account namespaces expose the same tools; only credentials and API base URL differ.
Raw agent markdown
# Loops - Lua API Reference
Namespace: `app.integrations.loops`
The Loops API lets agents manage contacts, send events, send transactional
email, read mailing lists and contact properties, manage suppression status, and
inspect sending configuration.
## Contacts
```lua
app.integrations.loops.create_contact({
email = "reader@example.test",
firstName = "Ada",
lastName = "Lovelace",
userId = "user_123",
properties = {
planName = "Pro"
}
})
app.integrations.loops.update_contact({
email = "reader@example.test",
subscribed = false
})
local contacts = app.integrations.loops.find_contact({
email = "reader@example.test"
})
app.integrations.loops.delete_contact({
userId = "user_123"
})
```
For `find_contact`, `delete_contact`, and suppression tools, provide exactly one
of `email` or `userId`.
## Contact Properties And Lists
```lua
app.integrations.loops.create_contact_property({
name = "planName",
type = "string"
})
local properties = app.integrations.loops.list_contact_properties({})
local lists = app.integrations.loops.list_mailing_lists({})
```
Property names must be camelCase. Supported property types are `string`,
`number`, `boolean`, and `date`.
## Events
```lua
app.integrations.loops.send_event({
email = "reader@example.test",
eventName = "trial_started",
eventProperties = {
plan = "Pro"
}
})
```
Events can identify contacts by `email` or `userId` and can include
`eventProperties`.
## Transactional Email
```lua
app.integrations.loops.send_transactional_email({
email = "reader@example.test",
transactionalId = "clw6rbuwp01rmeiyndm80155l",
addToAudience = true,
dataVariables = {
loginUrl = "https://example.test/login"
},
idempotency_key = "550e8400-e29b-41d4-a716-446655440000"
})
local emails = app.integrations.loops.list_transactional_emails({
perPage = 20
})
```
Attachments can be sent with `attachments`, each containing `filename`,
`contentType`, and base64 `data`.
## Suppression And Configuration
```lua
local status = app.integrations.loops.check_contact_suppression({
email = "reader@example.test"
})
app.integrations.loops.remove_contact_suppression({
email = "reader@example.test"
})
local key = app.integrations.loops.test_api_key({})
local ips = app.integrations.loops.list_dedicated_sending_ips({})
```
Suppression removal is quota-limited by Loops. Dedicated sending IPs are only for
rare allowlisting workflows and may change over time.
## Multi-Account Usage
```lua
app.integrations.loops.create_contact({ email = "reader@example.test" })
app.integrations.loops.default.create_contact({ email = "reader@example.test" })
app.integrations.loops.marketing.create_contact({ email = "reader@example.test" })
```
All account namespaces expose the same tools; only credentials and API base URL
differ. local result = app.integrations.loops.create_contact({})
print(result) Functions
create_contact Write
Create a Loops contact.
- Lua path
app.integrations.loops.create_contact- Full name
loops.loops_create_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_contact Write
Update or create a Loops contact.
- Lua path
app.integrations.loops.update_contact- Full name
loops.loops_update_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
find_contact Read
Find a Loops contact by email or userId.
- Lua path
app.integrations.loops.find_contact- Full name
loops.loops_find_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_contact Write
Delete a Loops contact.
- Lua path
app.integrations.loops.delete_contact- Full name
loops.loops_delete_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
check_contact_suppression Read
Check whether a contact is suppressed.
- Lua path
app.integrations.loops.check_contact_suppression- Full name
loops.loops_check_contact_suppression
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
remove_contact_suppression Write
Remove a contact from the suppression list.
- Lua path
app.integrations.loops.remove_contact_suppression- Full name
loops.loops_remove_contact_suppression
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_contact_property Write
Create a Loops contact property.
- Lua path
app.integrations.loops.create_contact_property- Full name
loops.loops_create_contact_property
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_contact_properties Read
List Loops contact properties.
- Lua path
app.integrations.loops.list_contact_properties- Full name
loops.loops_list_contact_properties
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_mailing_lists Read
List Loops mailing lists.
- Lua path
app.integrations.loops.list_mailing_lists- Full name
loops.loops_list_mailing_lists
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
send_event Write
Send a Loops event.
- Lua path
app.integrations.loops.send_event- Full name
loops.loops_send_event
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
send_transactional_email Write
Send a Loops transactional email.
- Lua path
app.integrations.loops.send_transactional_email- Full name
loops.loops_send_transactional_email
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_transactional_emails Read
List Loops transactional emails.
- Lua path
app.integrations.loops.list_transactional_emails- Full name
loops.loops_list_transactional_emails
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
test_api_key Read
Test the configured Loops API key.
- Lua path
app.integrations.loops.test_api_key- Full name
loops.loops_test_api_key
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_dedicated_sending_ips Read
List dedicated sending IP addresses.
- Lua path
app.integrations.loops.list_dedicated_sending_ips- Full name
loops.loops_list_dedicated_sending_ips
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||