KosmoKrator

marketing

Brevo Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write API key auth

Lua Namespace

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

Brevo — Lua API Reference

list_contacts

List contacts in your Brevo account with optional search and pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of contacts to return (default: 50, max: 1000)
offsetintegernoNumber of contacts to skip for pagination (default: 0)
searchstringnoSearch term to filter contacts by email or attributes

Example

local result = app.integrations.brevo.list_contacts({
  limit = 10,
  offset = 0,
  search = "john"
})

for _, contact in ipairs(result.contacts) do
  print(contact.email)
end

get_contact

Get details of a specific contact by email address.

Parameters

NameTypeRequiredDescription
emailstringyesThe email address of the contact to retrieve

Example

local result = app.integrations.brevo.get_contact({
  email = "[email protected]"
})

print(result.email)
print(result.attributes.FIRSTNAME)

create_contact

Create a new contact in Brevo.

Parameters

NameTypeRequiredDescription
emailstringyesThe email address for the new contact
attributesobjectnoContact attributes, e.g. {"FIRSTNAME": "John", "LASTNAME": "Doe"}
listIdsarraynoArray of list IDs (integers) to add the contact to, e.g. {2, 5}

Example

local result = app.integrations.brevo.create_contact({
  email = "[email protected]",
  attributes = {
    FIRSTNAME = "Jane",
    LASTNAME = "Doe"
  },
  listIds = {2, 5}
})

print("Created contact with ID: " .. result.id)

list_lists

List all contact lists in your Brevo account.

Parameters

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

Example

local result = app.integrations.brevo.list_lists({
  limit = 20,
  offset = 0
})

for _, list in ipairs(result.lists) do
  print(list.id .. ": " .. list.name .. " (" .. list.totalSubscribers .. " subscribers)")
end

get_list

Get details of a specific contact list by its ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe ID of the contact list to retrieve

Example

local result = app.integrations.brevo.get_list({
  id = 2
})

print(result.name .. ": " .. result.totalSubscribers .. " subscribers")

send_email

Send a transactional email via Brevo.

Parameters

NameTypeRequiredDescription
senderobjectyesSender with name and email keys
toarrayyesArray of recipient objects, each with email and optionally name
subjectstringyesThe email subject line
htmlContentstringnoHTML body of the email (required unless textContent provided)
textContentstringnoPlain text body of the email (required unless htmlContent provided)

Example

local result = app.integrations.brevo.send_email({
  sender = {
    name = "My App",
    email = "[email protected]"
  },
  to = {
    { email = "[email protected]", name = "John" }
  },
  subject = "Welcome!",
  htmlContent = "<h1>Hello!</h1><p>Welcome to our service.</p>",
  textContent = "Hello! Welcome to our service."
})

print("Message ID: " .. result.messageId)

get_account

Get information about the connected Brevo account.

Parameters

None.

Example

local result = app.integrations.brevo.get_account()

print("Account email: " .. result.email)
print("Plan: " .. result.plan.type)

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.brevo.work.function_name({...})
app.integrations.brevo.personal.function_name({...})

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

Raw agent markdown
# Brevo — Lua API Reference

## list_contacts

List contacts in your Brevo account with optional search and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of contacts to return (default: 50, max: 1000) |
| `offset` | integer | no | Number of contacts to skip for pagination (default: 0) |
| `search` | string | no | Search term to filter contacts by email or attributes |

### Example

```lua
local result = app.integrations.brevo.list_contacts({
  limit = 10,
  offset = 0,
  search = "john"
})

for _, contact in ipairs(result.contacts) do
  print(contact.email)
end
```

---

## get_contact

Get details of a specific contact by email address.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | The email address of the contact to retrieve |

### Example

```lua
local result = app.integrations.brevo.get_contact({
  email = "[email protected]"
})

print(result.email)
print(result.attributes.FIRSTNAME)
```

---

## create_contact

Create a new contact in Brevo.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | The email address for the new contact |
| `attributes` | object | no | Contact attributes, e.g. `{"FIRSTNAME": "John", "LASTNAME": "Doe"}` |
| `listIds` | array | no | Array of list IDs (integers) to add the contact to, e.g. `{2, 5}` |

### Example

```lua
local result = app.integrations.brevo.create_contact({
  email = "[email protected]",
  attributes = {
    FIRSTNAME = "Jane",
    LASTNAME = "Doe"
  },
  listIds = {2, 5}
})

print("Created contact with ID: " .. result.id)
```

---

## list_lists

List all contact lists in your Brevo account.

### Parameters

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

### Example

```lua
local result = app.integrations.brevo.list_lists({
  limit = 20,
  offset = 0
})

for _, list in ipairs(result.lists) do
  print(list.id .. ": " .. list.name .. " (" .. list.totalSubscribers .. " subscribers)")
end
```

---

## get_list

Get details of a specific contact list by its ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The ID of the contact list to retrieve |

### Example

```lua
local result = app.integrations.brevo.get_list({
  id = 2
})

print(result.name .. ": " .. result.totalSubscribers .. " subscribers")
```

---

## send_email

Send a transactional email via Brevo.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `sender` | object | yes | Sender with `name` and `email` keys |
| `to` | array | yes | Array of recipient objects, each with `email` and optionally `name` |
| `subject` | string | yes | The email subject line |
| `htmlContent` | string | no | HTML body of the email (required unless `textContent` provided) |
| `textContent` | string | no | Plain text body of the email (required unless `htmlContent` provided) |

### Example

```lua
local result = app.integrations.brevo.send_email({
  sender = {
    name = "My App",
    email = "[email protected]"
  },
  to = {
    { email = "[email protected]", name = "John" }
  },
  subject = "Welcome!",
  htmlContent = "<h1>Hello!</h1><p>Welcome to our service.</p>",
  textContent = "Hello! Welcome to our service."
})

print("Message ID: " .. result.messageId)
```

---

## get_account

Get information about the connected Brevo account.

### Parameters

None.

### Example

```lua
local result = app.integrations.brevo.get_account()

print("Account email: " .. result.email)
print("Plan: " .. result.plan.type)
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.brevo.work.function_name({...})
app.integrations.brevo.personal.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.brevo.brevo_list_contacts({
  limit = 1,
  offset = 1,
  search = "example_search"
})
print(result)

Functions

brevo_list_contacts

List contacts in your Brevo account. Supports pagination and filtering by email or search term.

Operation
Read read
Full name
brevo.brevo_list_contacts
ParameterTypeRequiredDescription
limit integer no Maximum number of contacts to return (default: 50, max: 1000).
offset integer no Number of contacts to skip for pagination (default: 0).
search string no Search term to filter contacts by email or attributes (e.g., "[email protected]").

brevo_get_contact

Get details of a specific contact in Brevo by their email address. Returns contact attributes, list memberships, and creation date.

Operation
Read read
Full name
brevo.brevo_get_contact
ParameterTypeRequiredDescription
email string yes The email address of the contact to retrieve (used as the contact identifier in Brevo).

brevo_create_contact

Create a new contact in Brevo. You can set attributes like first name and last name, and add the contact to one or more lists.

Operation
Write write
Full name
brevo.brevo_create_contact
ParameterTypeRequiredDescription
email string yes The email address for the new contact.
attributes object no Contact attributes such as {"FIRSTNAME": "John", "LASTNAME": "Doe"}. Keys must match attribute names in your Brevo account.
listIds array no Array of list IDs (integers) to add the contact to, e.g. [2, 5].

brevo_list_lists

List all contact lists in your Brevo account. Supports pagination with limit and offset.

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

brevo_get_list

Get details of a specific contact list in Brevo by its ID. Returns the list name, total subscribers, and other metadata.

Operation
Read read
Full name
brevo.brevo_get_list
ParameterTypeRequiredDescription
id integer yes The ID of the contact list to retrieve.

brevo_send_email

Send a transactional email via Brevo. Specify sender, recipients, subject, and HTML or text content.

Operation
Write write
Full name
brevo.brevo_send_email
ParameterTypeRequiredDescription
sender object yes Sender details as an object with "name" and "email" keys, e.g. {"name": "My App", "email": "[email protected]"}.
to array yes Array of recipient objects, each with "email" and optionally "name", e.g. [{"email": "[email protected]", "name": "John"}].
subject string yes The email subject line.
htmlContent string no HTML body of the email. Required unless textContent is provided.
textContent string no Plain text body of the email. Required unless htmlContent is provided.

brevo_get_account

Get information about the connected Brevo account, including email, plan details, and account statistics.

Operation
Read read
Full name
brevo.brevo_get_account
ParameterTypeRequiredDescription
No parameters.