KosmoKrator

email

Loops Lua API for KosmoKrator Agents

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

6 functions 3 read 3 write API key auth

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.

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

list_contacts

List contacts from Loops with pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of contacts to return (default: 50, max: 50)
offsetintegernoNumber of contacts to skip for pagination (default: 0)

Examples

-- List first 50 contacts
local result = app.integrations.loops.list_contacts({})

-- Get next page
local result = app.integrations.loops.list_contacts({
  limit = 50,
  offset = 50
})

get_contact

Get a single contact by their unique ID.

Parameters

NameTypeRequiredDescription
contact_idstringyesThe unique contact ID

Examples

local result = app.integrations.loops.get_contact({
  contact_id = "abc123def456"
})

create_contact

Create a new contact in Loops.

Parameters

NameTypeRequiredDescription
emailstringyesThe contact’s email address
first_namestringnoThe contact’s first name
last_namestringnoThe contact’s last name

Examples

local result = app.integrations.loops.create_contact({
  email = "[email protected]",
  first_name = "Jane",
  last_name = "Doe"
})

update_contact

Update an existing contact in Loops.

Parameters

NameTypeRequiredDescription
contact_idstringyesThe unique contact ID to update
emailstringnoUpdated email address
first_namestringnoUpdated first name
last_namestringnoUpdated last name
propertiesobjectnoCustom properties as key-value pairs

Examples

-- Update a contact's name
local result = app.integrations.loops.update_contact({
  contact_id = "abc123def456",
  first_name = "Jane",
  last_name = "Smith"
})

-- Update with custom properties
local result = app.integrations.loops.update_contact({
  contact_id = "abc123def456",
  properties = {
    plan = "pro",
    company = "Acme Inc"
  }
})

send_event

Send a custom event for a contact. Events can trigger automations and loops.

Parameters

NameTypeRequiredDescription
emailstringyesThe contact’s email address
event_namestringyesThe event name (e.g., “signup”, “purchase”)
propertiesobjectnoEvent properties as key-value pairs

Examples

-- Send a signup event
local result = app.integrations.loops.send_event({
  email = "[email protected]",
  event_name = "signup"
})

-- Send a purchase event with properties
local result = app.integrations.loops.send_event({
  email = "[email protected]",
  event_name = "purchase",
  properties = {
    product = "Pro Plan",
    amount = 99.00
  }
})

get_current_user

Get the currently authenticated Loops user. Useful for verifying API connection.

Parameters

None.

Examples

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

Multi-Account Usage

If you have multiple Loops accounts configured, use account-specific namespaces:

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

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

-- Named accounts
app.integrations.loops.marketing.function_name({...})
app.integrations.loops.transactional.function_name({...})

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

Raw agent markdown
# Loops — Lua API Reference

## list_contacts

List contacts from Loops with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of contacts to return (default: 50, max: 50) |
| `offset` | integer | no | Number of contacts to skip for pagination (default: 0) |

### Examples

```lua
-- List first 50 contacts
local result = app.integrations.loops.list_contacts({})

-- Get next page
local result = app.integrations.loops.list_contacts({
  limit = 50,
  offset = 50
})
```

---

## get_contact

Get a single contact by their unique ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `contact_id` | string | yes | The unique contact ID |

### Examples

```lua
local result = app.integrations.loops.get_contact({
  contact_id = "abc123def456"
})
```

---

## create_contact

Create a new contact in Loops.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | The contact's email address |
| `first_name` | string | no | The contact's first name |
| `last_name` | string | no | The contact's last name |

### Examples

```lua
local result = app.integrations.loops.create_contact({
  email = "[email protected]",
  first_name = "Jane",
  last_name = "Doe"
})
```

---

## update_contact

Update an existing contact in Loops.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `contact_id` | string | yes | The unique contact ID to update |
| `email` | string | no | Updated email address |
| `first_name` | string | no | Updated first name |
| `last_name` | string | no | Updated last name |
| `properties` | object | no | Custom properties as key-value pairs |

### Examples

```lua
-- Update a contact's name
local result = app.integrations.loops.update_contact({
  contact_id = "abc123def456",
  first_name = "Jane",
  last_name = "Smith"
})

-- Update with custom properties
local result = app.integrations.loops.update_contact({
  contact_id = "abc123def456",
  properties = {
    plan = "pro",
    company = "Acme Inc"
  }
})
```

---

## send_event

Send a custom event for a contact. Events can trigger automations and loops.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | The contact's email address |
| `event_name` | string | yes | The event name (e.g., "signup", "purchase") |
| `properties` | object | no | Event properties as key-value pairs |

### Examples

```lua
-- Send a signup event
local result = app.integrations.loops.send_event({
  email = "[email protected]",
  event_name = "signup"
})

-- Send a purchase event with properties
local result = app.integrations.loops.send_event({
  email = "[email protected]",
  event_name = "purchase",
  properties = {
    product = "Pro Plan",
    amount = 99.00
  }
})
```

---

## get_current_user

Get the currently authenticated Loops user. Useful for verifying API connection.

### Parameters

None.

### Examples

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

---

## Multi-Account Usage

If you have multiple Loops accounts configured, use account-specific namespaces:

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

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

-- Named accounts
app.integrations.loops.marketing.function_name({...})
app.integrations.loops.transactional.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.loops.loops_list_contacts({
  limit = 1,
  offset = 1
})
print(result)

Functions

loops_list_contacts

List contacts from Loops with pagination. Returns contact records including email, name, and custom properties.

Operation
Read read
Full name
loops.loops_list_contacts
ParameterTypeRequiredDescription
limit integer no Maximum number of contacts to return (default: 50, max: 50).
offset integer no Number of contacts to skip for pagination (default: 0).

loops_get_contact

Get a single contact from Loops by their unique contact ID. Returns full contact details including email, name, and custom properties.

Operation
Read read
Full name
loops.loops_get_contact
ParameterTypeRequiredDescription
contact_id string yes The unique contact ID.

loops_create_contact

Create a new contact in Loops. Requires an email address. Optionally include first and last name.

Operation
Write write
Full name
loops.loops_create_contact
ParameterTypeRequiredDescription
email string yes The contact's email address.
first_name string no The contact's first name.
last_name string no The contact's last name.

loops_update_contact

Update an existing contact in Loops. Provide the contact ID and the fields to update (e.g., email, first_name, last_name, or custom properties).

Operation
Write write
Full name
loops.loops_update_contact
ParameterTypeRequiredDescription
contact_id string yes The unique contact ID to update.
email string no Updated email address.
first_name string no Updated first name.
last_name string no Updated last name.
properties object no Custom properties to update as key-value pairs.

loops_send_event

Send a custom event to Loops for a contact identified by email. Events can trigger automations and loops in your Loops account.

Operation
Write write
Full name
loops.loops_send_event
ParameterTypeRequiredDescription
email string yes The contact's email address.
event_name string yes The name of the event to send (e.g., "signup", "purchase", "trial_started").
properties object no Optional event properties as key-value pairs to attach additional data.

loops_get_current_user

Get the currently authenticated Loops user. Use this to verify the API connection and see account details.

Operation
Read read
Full name
loops.loops_get_current_user
ParameterTypeRequiredDescription
No parameters.