productivity
Lemlist Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Lemlist KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.lemlist.*.
Use lua_read_doc("integrations.lemlist") 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
Lemlist workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.lemlist.campaigns({status = "example_status", limit = 1, offset = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("lemlist"))' --json
kosmo integrations:lua --eval 'print(docs.read("lemlist.campaigns"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local lemlist = app.integrations.lemlist
local result = lemlist.campaigns({status = "example_status", limit = 1, offset = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.lemlist, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.lemlist.default.* or app.integrations.lemlist.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Lemlist, 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.
Lemlist — Lua API Reference
list_campaigns
List all outreach campaigns in Lemlist.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | no | Filter by status: "active", "draft", "paused", "completed" |
limit | integer | no | Maximum number of campaigns to return |
offset | integer | no | Number of campaigns to skip for pagination |
Examples
-- List all campaigns
local result = app.integrations.lemlist.list_campaigns({})
for _, campaign in ipairs(result) do
print(campaign.name .. " (" .. campaign._id .. ") - " .. campaign.status)
end
-- Filter active campaigns
local result = app.integrations.lemlist.list_campaigns({
status = "active"
})
get_campaign
Get details of a specific campaign by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
campaign_id | string | yes | The ID of the campaign to retrieve |
Examples
local result = app.integrations.lemlist.get_campaign({
campaign_id = "cam_abc123"
})
print("Campaign: " .. result.name)
print("Status: " .. result.status)
print("Leads count: " .. result.leadsCount)
list_leads
List leads in a specific campaign.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
campaign_id | string | yes | The ID of the campaign |
status | string | no | Filter by lead status: "interested", "notInterested", "bounced", "sent", "replied", "autoreplied", "clicked", "opened" |
limit | integer | no | Maximum number of leads to return |
offset | integer | no | Number of leads to skip for pagination |
Examples
-- List all leads in a campaign
local result = app.integrations.lemlist.list_leads({
campaign_id = "cam_abc123"
})
for _, lead in ipairs(result) do
print(lead.email .. " - " .. lead.status)
end
-- Filter leads who replied
local result = app.integrations.lemlist.list_leads({
campaign_id = "cam_abc123",
status = "replied"
})
add_lead
Add a lead to a campaign. The lead will be queued for outreach according to the campaign schedule.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
campaign_id | string | yes | The ID of the campaign to add the lead to |
email | string | yes | The lead’s email address |
firstName | string | no | The lead’s first name |
lastName | string | no | The lead’s last name |
companyName | string | no | The lead’s company name |
phone | string | no | The lead’s phone number |
linkedinUrl | string | no | The lead’s LinkedIn profile URL |
variables | object | no | Custom variables for campaign templates (key-value pairs) |
Examples
-- Add a simple lead
local result = app.integrations.lemlist.add_lead({
campaign_id = "cam_abc123",
email = "john@example.com"
})
-- Add a lead with full details
local result = app.integrations.lemlist.add_lead({
campaign_id = "cam_abc123",
email = "jane@acme.com",
firstName = "Jane",
lastName = "Smith",
companyName = "Acme Inc",
phone = "+1234567890"
})
-- Add a lead with custom variables for personalization
local result = app.integrations.lemlist.add_lead({
campaign_id = "cam_abc123",
email = "bob@startup.io",
firstName = "Bob",
variables = {
industry = "SaaS",
meeting_link = "https://cal.com/bob/30min"
}
})
list_teams
List all teams in the Lemlist account.
Parameters
None.
Examples
local result = app.integrations.lemlist.list_teams({})
for _, team in ipairs(result) do
print(team.name .. " - " .. #team.members .. " members")
end
list_subaccounts
List all sub-accounts in the Lemlist account.
Parameters
None.
Examples
local result = app.integrations.lemlist.list_subaccounts({})
for _, sub in ipairs(result) do
print(sub.name .. " - " .. sub.status)
end
get_current_user
Get the profile of the currently authenticated Lemlist user.
Parameters
None.
Examples
local result = app.integrations.lemlist.get_current_user({})
print("Logged in as: " .. result.email)
print("Plan: " .. result.plan)
print("Team: " .. result.teamName)
Multi-Account Usage
If you have multiple Lemlist accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.lemlist.function_name({...})
-- Explicit default (portable across setups)
app.integrations.lemlist.default.function_name({...})
-- Named accounts
app.integrations.lemlist.agency.function_name({...})
app.integrations.lemlist.personal.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Lemlist — Lua API Reference
## list_campaigns
List all outreach campaigns in Lemlist.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `status` | string | no | Filter by status: `"active"`, `"draft"`, `"paused"`, `"completed"` |
| `limit` | integer | no | Maximum number of campaigns to return |
| `offset` | integer | no | Number of campaigns to skip for pagination |
### Examples
```lua
-- List all campaigns
local result = app.integrations.lemlist.list_campaigns({})
for _, campaign in ipairs(result) do
print(campaign.name .. " (" .. campaign._id .. ") - " .. campaign.status)
end
-- Filter active campaigns
local result = app.integrations.lemlist.list_campaigns({
status = "active"
})
```
---
## get_campaign
Get details of a specific campaign by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `campaign_id` | string | yes | The ID of the campaign to retrieve |
### Examples
```lua
local result = app.integrations.lemlist.get_campaign({
campaign_id = "cam_abc123"
})
print("Campaign: " .. result.name)
print("Status: " .. result.status)
print("Leads count: " .. result.leadsCount)
```
---
## list_leads
List leads in a specific campaign.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `campaign_id` | string | yes | The ID of the campaign |
| `status` | string | no | Filter by lead status: `"interested"`, `"notInterested"`, `"bounced"`, `"sent"`, `"replied"`, `"autoreplied"`, `"clicked"`, `"opened"` |
| `limit` | integer | no | Maximum number of leads to return |
| `offset` | integer | no | Number of leads to skip for pagination |
### Examples
```lua
-- List all leads in a campaign
local result = app.integrations.lemlist.list_leads({
campaign_id = "cam_abc123"
})
for _, lead in ipairs(result) do
print(lead.email .. " - " .. lead.status)
end
-- Filter leads who replied
local result = app.integrations.lemlist.list_leads({
campaign_id = "cam_abc123",
status = "replied"
})
```
---
## add_lead
Add a lead to a campaign. The lead will be queued for outreach according to the campaign schedule.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `campaign_id` | string | yes | The ID of the campaign to add the lead to |
| `email` | string | yes | The lead's email address |
| `firstName` | string | no | The lead's first name |
| `lastName` | string | no | The lead's last name |
| `companyName` | string | no | The lead's company name |
| `phone` | string | no | The lead's phone number |
| `linkedinUrl` | string | no | The lead's LinkedIn profile URL |
| `variables` | object | no | Custom variables for campaign templates (key-value pairs) |
### Examples
```lua
-- Add a simple lead
local result = app.integrations.lemlist.add_lead({
campaign_id = "cam_abc123",
email = "john@example.com"
})
-- Add a lead with full details
local result = app.integrations.lemlist.add_lead({
campaign_id = "cam_abc123",
email = "jane@acme.com",
firstName = "Jane",
lastName = "Smith",
companyName = "Acme Inc",
phone = "+1234567890"
})
-- Add a lead with custom variables for personalization
local result = app.integrations.lemlist.add_lead({
campaign_id = "cam_abc123",
email = "bob@startup.io",
firstName = "Bob",
variables = {
industry = "SaaS",
meeting_link = "https://cal.com/bob/30min"
}
})
```
---
## list_teams
List all teams in the Lemlist account.
### Parameters
None.
### Examples
```lua
local result = app.integrations.lemlist.list_teams({})
for _, team in ipairs(result) do
print(team.name .. " - " .. #team.members .. " members")
end
```
---
## list_subaccounts
List all sub-accounts in the Lemlist account.
### Parameters
None.
### Examples
```lua
local result = app.integrations.lemlist.list_subaccounts({})
for _, sub in ipairs(result) do
print(sub.name .. " - " .. sub.status)
end
```
---
## get_current_user
Get the profile of the currently authenticated Lemlist user.
### Parameters
None.
### Examples
```lua
local result = app.integrations.lemlist.get_current_user({})
print("Logged in as: " .. result.email)
print("Plan: " .. result.plan)
print("Team: " .. result.teamName)
```
---
## Multi-Account Usage
If you have multiple Lemlist accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.lemlist.function_name({...})
-- Explicit default (portable across setups)
app.integrations.lemlist.default.function_name({...})
-- Named accounts
app.integrations.lemlist.agency.function_name({...})
app.integrations.lemlist.personal.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.lemlist.campaigns({status = "example_status", limit = 1, offset = 1})
print(result) Functions
campaigns Read
List all outreach campaigns in Lemlist. Returns campaign IDs, names, statuses, and other metadata.
- Lua path
app.integrations.lemlist.campaigns- Full name
lemlist.lemlist_list_campaigns
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | no | Filter by campaign status (e.g. "active", "draft", "paused", "completed"). |
limit | integer | no | Maximum number of campaigns to return. |
offset | integer | no | Number of campaigns to skip for pagination. |
get_campaign Read
Get details of a specific Lemlist campaign by ID. Returns the full campaign configuration and statistics.
- Lua path
app.integrations.lemlist.get_campaign- Full name
lemlist.lemlist_get_campaign
| Parameter | Type | Required | Description |
|---|---|---|---|
campaign_id | string | yes | The ID of the campaign to retrieve. |
leads Read
List leads in a specific Lemlist campaign. Returns lead contact information, email status, and campaign progress.
- Lua path
app.integrations.lemlist.leads- Full name
lemlist.lemlist_list_leads
| Parameter | Type | Required | Description |
|---|---|---|---|
campaign_id | string | yes | The ID of the campaign to list leads for. |
status | string | no | Filter by lead status (e.g. "interested", "notInterested", "bounced", "sent", "replied"). |
limit | integer | no | Maximum number of leads to return. |
offset | integer | no | Number of leads to skip for pagination. |
add_lead Write
Add a lead to a Lemlist campaign. The lead will be queued for outreach according to the campaign schedule.
- Lua path
app.integrations.lemlist.add_lead- Full name
lemlist.lemlist_add_lead
| Parameter | Type | Required | Description |
|---|---|---|---|
campaign_id | string | yes | The ID of the campaign to add the lead to. |
email | string | yes | The lead's email address. |
firstName | string | no | The lead's first name. |
lastName | string | no | The lead's last name. |
companyName | string | no | The lead's company name. |
phone | string | no | The lead's phone number. |
linkedinUrl | string | no | The lead's LinkedIn profile URL. |
variables | object | no | Custom variables to use in campaign templates (key-value pairs). |
teams Read
List all teams in the Lemlist account. Returns team names, member lists, and configuration.
- Lua path
app.integrations.lemlist.teams- Full name
lemlist.lemlist_list_teams
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
subaccounts Read
List all sub-accounts in Lemlist. Returns sub-account names, statuses, and usage details.
- Lua path
app.integrations.lemlist.subaccounts- Full name
lemlist.lemlist_list_subaccounts
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_current_user Read
Get the profile of the currently authenticated Lemlist user. Returns name, email, plan, and account details.
- Lua path
app.integrations.lemlist.get_current_user- Full name
lemlist.lemlist_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||