KosmoKrator

marketing

Customer.io Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write API key auth

Lua Namespace

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

Customer.io — Lua API Reference

identify_customer

Create or update a customer profile in Customer.io.

Parameters

NameTypeRequiredDescription
idstringyesUnique identifier for the customer (user ID, email, or external ID)
emailstringnoCustomer email address
namestringnoCustomer full name
attributesobjectnoAdditional custom attributes (key-value pairs)

Examples

Create a new customer

local result = app.integrations.customerio.identify_customer({
  id = "user_12345",
  email = "[email protected]",
  name = "Jane Doe",
  attributes = {
    plan = "premium",
    company = "Acme Corp"
  }
})

print(result.message)

Update an existing customer

local result = app.integrations.customerio.identify_customer({
  id = "user_12345",
  attributes = {
    plan = "enterprise",
    mrr = 299
  }
})

track_event

Track a custom event for a customer. Events can trigger campaign workflows and are used for segmentation.

Parameters

NameTypeRequiredDescription
idstringyesCustomer identifier (must match the ID used in identify)
namestringyesEvent name (e.g., "purchase", "signup")
dataobjectnoEvent data — key-value pairs with event details

Examples

Track a purchase event

local result = app.integrations.customerio.track_event({
  id = "user_12345",
  name = "purchase",
  data = {
    product = "Pro Plan",
    amount = 99.00,
    currency = "USD"
  }
})

print(result.message)

Track a simple event

local result = app.integrations.customerio.track_event({
  id = "user_12345",
  name = "logged_in"
})

list_segments

List all segments in the Customer.io workspace.

Parameters

None.

Example

local result = app.integrations.customerio.list_segments({})

for _, segment in ipairs(result.segments or {}) do
  print(segment.name .. " (ID: " .. segment.id .. ")")
end

list_campaigns

List all campaigns in the Customer.io workspace.

Parameters

None.

Example

local result = app.integrations.customerio.list_campaigns({})

for _, campaign in ipairs(result.campaigns or {}) do
  print(campaign.name .. " — Status: " .. tostring(campaign.active))
end

get_campaign

Get detailed information about a specific campaign.

Parameters

NameTypeRequiredDescription
idintegeryesThe campaign ID to retrieve

Example

local result = app.integrations.customerio.get_campaign({
  id = 42
})

print("Campaign: " .. result.name)
print("Active: " .. tostring(result.active))

list_newsletters

List all newsletters in the Customer.io workspace.

Parameters

None.

Example

local result = app.integrations.customerio.list_newsletters({})

for _, newsletter in ipairs(result.newsletters or {}) do
  print(newsletter.name .. " — Status: " .. tostring(newsletter.state))
end

get_current_user

Get the currently authenticated user and account information. Useful for verifying API credentials.

Parameters

None.

Example

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

print("Account: " .. result.email)

Multi-Account Usage

If you have multiple Customer.io accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.customerio.function_name({...})

-- Explicit default (portable across setups)
app.integrations.customerio.default.function_name({...})

-- Named accounts
app.integrations.customerio.production.function_name({...})
app.integrations.customerio.staging.function_name({...})

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

Raw agent markdown
# Customer.io — Lua API Reference

## identify_customer

Create or update a customer profile in Customer.io.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Unique identifier for the customer (user ID, email, or external ID) |
| `email` | string | no | Customer email address |
| `name` | string | no | Customer full name |
| `attributes` | object | no | Additional custom attributes (key-value pairs) |

### Examples

#### Create a new customer

```lua
local result = app.integrations.customerio.identify_customer({
  id = "user_12345",
  email = "[email protected]",
  name = "Jane Doe",
  attributes = {
    plan = "premium",
    company = "Acme Corp"
  }
})

print(result.message)
```

#### Update an existing customer

```lua
local result = app.integrations.customerio.identify_customer({
  id = "user_12345",
  attributes = {
    plan = "enterprise",
    mrr = 299
  }
})
```

---

## track_event

Track a custom event for a customer. Events can trigger campaign workflows and are used for segmentation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Customer identifier (must match the ID used in identify) |
| `name` | string | yes | Event name (e.g., `"purchase"`, `"signup"`) |
| `data` | object | no | Event data — key-value pairs with event details |

### Examples

#### Track a purchase event

```lua
local result = app.integrations.customerio.track_event({
  id = "user_12345",
  name = "purchase",
  data = {
    product = "Pro Plan",
    amount = 99.00,
    currency = "USD"
  }
})

print(result.message)
```

#### Track a simple event

```lua
local result = app.integrations.customerio.track_event({
  id = "user_12345",
  name = "logged_in"
})
```

---

## list_segments

List all segments in the Customer.io workspace.

### Parameters

None.

### Example

```lua
local result = app.integrations.customerio.list_segments({})

for _, segment in ipairs(result.segments or {}) do
  print(segment.name .. " (ID: " .. segment.id .. ")")
end
```

---

## list_campaigns

List all campaigns in the Customer.io workspace.

### Parameters

None.

### Example

```lua
local result = app.integrations.customerio.list_campaigns({})

for _, campaign in ipairs(result.campaigns or {}) do
  print(campaign.name .. " — Status: " .. tostring(campaign.active))
end
```

---

## get_campaign

Get detailed information about a specific campaign.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The campaign ID to retrieve |

### Example

```lua
local result = app.integrations.customerio.get_campaign({
  id = 42
})

print("Campaign: " .. result.name)
print("Active: " .. tostring(result.active))
```

---

## list_newsletters

List all newsletters in the Customer.io workspace.

### Parameters

None.

### Example

```lua
local result = app.integrations.customerio.list_newsletters({})

for _, newsletter in ipairs(result.newsletters or {}) do
  print(newsletter.name .. " — Status: " .. tostring(newsletter.state))
end
```

---

## get_current_user

Get the currently authenticated user and account information. Useful for verifying API credentials.

### Parameters

None.

### Example

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

print("Account: " .. result.email)
```

---

## Multi-Account Usage

If you have multiple Customer.io accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.customerio.function_name({...})

-- Explicit default (portable across setups)
app.integrations.customerio.default.function_name({...})

-- Named accounts
app.integrations.customerio.production.function_name({...})
app.integrations.customerio.staging.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.customerio.customerio_identify_customer({
  id = "example_id",
  email = "example_email",
  name = "example_name",
  attributes = "example_attributes"
})
print(result)

Functions

customerio_identify_customer

Create or update a customer profile in Customer.io. Use this to add new customers or update existing customer attributes like email, name, and custom properties.

Operation
Write write
Full name
customerio.customerio_identify_customer
ParameterTypeRequiredDescription
id string yes Unique identifier for the customer (e.g., user ID, email, or external ID).
email string no Customer email address.
name string no Customer full name.
attributes object no Additional custom attributes to set on the customer profile (e.g., {"plan": "premium", "company": "Acme"}).

customerio_track_event

Track a custom event for a customer in Customer.io. Events trigger campaign workflows and can be used to segment customers.

Operation
Write write
Full name
customerio.customerio_track_event
ParameterTypeRequiredDescription
id string yes Customer identifier (must match the ID used when identifying the customer).
name string yes Event name (e.g., "purchase", "signup", "plan_changed").
data object no Event data payload — key-value pairs with event details (e.g., {"product": "Pro Plan", "amount": 99}).

customerio_list_segments

List all segments in the Customer.io workspace. Segments are dynamic groups of customers defined by conditions.

Operation
Read read
Full name
customerio.customerio_list_segments
ParameterTypeRequiredDescription
No parameters.

customerio_list_campaigns

List all campaigns in the Customer.io workspace. Campaigns are automated message sequences triggered by events or segments.

Operation
Read read
Full name
customerio.customerio_list_campaigns
ParameterTypeRequiredDescription
No parameters.

customerio_get_campaign

Get detailed information about a specific campaign in Customer.io, including its triggers, actions, and performance metrics.

Operation
Read read
Full name
customerio.customerio_get_campaign
ParameterTypeRequiredDescription
id integer yes The campaign ID to retrieve.

customerio_list_newsletters

List all newsletters in the Customer.io workspace. Newsletters are one-time broadcast messages sent to segments.

Operation
Read read
Full name
customerio.customerio_list_newsletters
ParameterTypeRequiredDescription
No parameters.

customerio_get_current_user

Get the currently authenticated user and account information from Customer.io. Useful for verifying API credentials and checking workspace details.

Operation
Read read
Full name
customerio.customerio_get_current_user
ParameterTypeRequiredDescription
No parameters.