KosmoKrator

communication

Courier Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API key auth

Lua Namespace

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

Courier — Lua API Reference

send_message

Send a notification message through Courier.

Parameters

NameTypeRequiredDescription
messageobjectyesMessage payload — includes template, content, data, routing, etc.
recipientstringyesRecipient — a Courier user ID, email, or JSON recipient object.

Message Object

The message object can include:

FieldTypeDescription
templatestringTemplate ID to use (e.g., "ABCD1234")
contentobjectInline content with title and body blocks
dataobjectTemplate variables to merge into the message
routingobjectChannel routing overrides
channelsobjectPer-channel content overrides

Recipient Formats

Examples

-- Send using a template
local result = app.integrations.courier.send_message({
  message = {
    template = "ABCD1234",
    data = { name = "John", plan = "Pro" }
  },
  recipient = "[email protected]"
})
print("Request ID: " .. result.request_id)

-- Send inline content
local result = app.integrations.courier.send_message({
  message = {
    content = {
      title = "Welcome!",
      body = "Thanks for signing up."
    }
  },
  recipient = "[email protected]"
})

list_messages

List messages with optional filtering and cursor-based pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMax messages to return (default: 20, max: 200)
cursorstringnoPagination cursor from a previous response
statusstringnoFilter: “delivered”, “undelivered”, “opened”, “clicked”, “bounced”, “enqueued”

Example

local result = app.integrations.courier.list_messages({
  limit = 50,
  status = "delivered"
})
for _, msg in ipairs(result.results or {}) do
  print(msg.id .. " - " .. msg.status)
end

get_message

Get details of a specific message.

Parameters

NameTypeRequiredDescription
idstringyesThe message ID

Example

local result = app.integrations.courier.get_message({
  id = "msg_1234567890"
})
print("Status: " .. result.status)
print("To: " .. result.to)

list_recipients

List notification recipients with cursor-based pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMax recipients to return (default: 20, max: 200)
cursorstringnoPagination cursor from a previous response

Example

local result = app.integrations.courier.list_recipients({
  limit = 50
})
for _, r in ipairs(result.results or {}) do
  print(r.id .. " - " .. (r.email or "no email"))
end

get_recipient

Get details of a specific recipient.

Parameters

NameTypeRequiredDescription
idstringyesThe recipient ID

Example

local result = app.integrations.courier.get_recipient({
  id = "rcpt_1234567890"
})
print("Email: " .. (result.email or "N/A"))

list_templates

List notification templates with cursor-based pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMax templates to return (default: 20, max: 200)
cursorstringnoPagination cursor from a previous response

Example

local result = app.integrations.courier.list_templates({
  limit = 50
})
for _, t in ipairs(result.results or {}) do
  print(t.id .. " - " .. t.name)
end

get_current_user

Get the currently authenticated Courier user profile.

Parameters

None.

Example

local result = app.integrations.courier.get_current_user({})
print("User: " .. (result.user.name or "unknown"))

Multi-Account Usage

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

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

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

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

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

Raw agent markdown
# Courier — Lua API Reference

## send_message

Send a notification message through Courier.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `message` | object | yes | Message payload — includes template, content, data, routing, etc. |
| `recipient` | string | yes | Recipient — a Courier user ID, email, or JSON recipient object. |

### Message Object

The `message` object can include:

| Field | Type | Description |
|-------|------|-------------|
| `template` | string | Template ID to use (e.g., `"ABCD1234"`) |
| `content` | object | Inline content with `title` and `body` blocks |
| `data` | object | Template variables to merge into the message |
| `routing` | object | Channel routing overrides |
| `channels` | object | Per-channel content overrides |

### Recipient Formats

- Email: `"[email protected]"`
- User ID: `"user_123"`
- Object: `'{email: "[email protected]"}'`

### Examples

```lua
-- Send using a template
local result = app.integrations.courier.send_message({
  message = {
    template = "ABCD1234",
    data = { name = "John", plan = "Pro" }
  },
  recipient = "[email protected]"
})
print("Request ID: " .. result.request_id)

-- Send inline content
local result = app.integrations.courier.send_message({
  message = {
    content = {
      title = "Welcome!",
      body = "Thanks for signing up."
    }
  },
  recipient = "[email protected]"
})
```

---

## list_messages

List messages with optional filtering and cursor-based pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max messages to return (default: 20, max: 200) |
| `cursor` | string | no | Pagination cursor from a previous response |
| `status` | string | no | Filter: "delivered", "undelivered", "opened", "clicked", "bounced", "enqueued" |

### Example

```lua
local result = app.integrations.courier.list_messages({
  limit = 50,
  status = "delivered"
})
for _, msg in ipairs(result.results or {}) do
  print(msg.id .. " - " .. msg.status)
end
```

---

## get_message

Get details of a specific message.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The message ID |

### Example

```lua
local result = app.integrations.courier.get_message({
  id = "msg_1234567890"
})
print("Status: " .. result.status)
print("To: " .. result.to)
```

---

## list_recipients

List notification recipients with cursor-based pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max recipients to return (default: 20, max: 200) |
| `cursor` | string | no | Pagination cursor from a previous response |

### Example

```lua
local result = app.integrations.courier.list_recipients({
  limit = 50
})
for _, r in ipairs(result.results or {}) do
  print(r.id .. " - " .. (r.email or "no email"))
end
```

---

## get_recipient

Get details of a specific recipient.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The recipient ID |

### Example

```lua
local result = app.integrations.courier.get_recipient({
  id = "rcpt_1234567890"
})
print("Email: " .. (result.email or "N/A"))
```

---

## list_templates

List notification templates with cursor-based pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max templates to return (default: 20, max: 200) |
| `cursor` | string | no | Pagination cursor from a previous response |

### Example

```lua
local result = app.integrations.courier.list_templates({
  limit = 50
})
for _, t in ipairs(result.results or {}) do
  print(t.id .. " - " .. t.name)
end
```

---

## get_current_user

Get the currently authenticated Courier user profile.

### Parameters

None.

### Example

```lua
local result = app.integrations.courier.get_current_user({})
print("User: " .. (result.user.name or "unknown"))
```

---

## Multi-Account Usage

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

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

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

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

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

Metadata-Derived Lua Example

local result = app.integrations.courier.courier_send_message({
  message = "example_message",
  recipient = "example_recipient"
})
print(result)

Functions

courier_send_message

Send a notification message through Courier. Provide a message payload with content or template, and a recipient (user ID, email, or recipient object). Supports all Courier send options including channels, routing, and preferences.

Operation
Write write
Full name
courier.courier_send_message
ParameterTypeRequiredDescription
message object yes The message payload. Can include "template" (template ID), "content" (title/body blocks), "routing" (channel overrides), "data" (template variables), and other Courier send options. Pass as a JSON object.
recipient string yes The message recipient. Can be a Courier user ID, email address, or a JSON object with recipient details (e.g., {"email": "[email protected]"}).

courier_list_messages

List messages from Courier with optional filtering by status and cursor-based pagination. Returns message IDs, statuses, and metadata.

Operation
Read read
Full name
courier.courier_list_messages
ParameterTypeRequiredDescription
limit integer no Maximum number of messages to return (default: 20, max: 200).
cursor string no Pagination cursor — pass the cursor from a previous response to fetch the next page.
status string no Filter by message status. Possible values: "delivered", "undelivered", "opened", "clicked", "bounced", "enqueued".

courier_get_message

Get detailed information about a specific Courier message, including delivery status, content, and channel details.

Operation
Read read
Full name
courier.courier_get_message
ParameterTypeRequiredDescription
id string yes The message ID (e.g., "msg_1234567890").

courier_list_recipients

List notification recipients from Courier with cursor-based pagination. Returns recipient IDs, contact details, and preferences.

Operation
Read read
Full name
courier.courier_list_recipients
ParameterTypeRequiredDescription
limit integer no Maximum number of recipients to return (default: 20, max: 200).
cursor string no Pagination cursor — pass the cursor from a previous response to fetch the next page.

courier_get_recipient

Get detailed information about a specific Courier recipient, including contact preferences and channel profiles.

Operation
Read read
Full name
courier.courier_get_recipient
ParameterTypeRequiredDescription
id string yes The recipient ID (e.g., "rcpt_1234567890").

courier_list_templates

List notification templates from Courier with cursor-based pagination. Returns template IDs, names, and metadata.

Operation
Read read
Full name
courier.courier_list_templates
ParameterTypeRequiredDescription
limit integer no Maximum number of templates to return (default: 20, max: 200).
cursor string no Pagination cursor — pass the cursor from a previous response to fetch the next page.

courier_get_current_user

Get the currently authenticated Courier user profile. Use this to verify the API key and see account information.

Operation
Read read
Full name
courier.courier_get_current_user
ParameterTypeRequiredDescription
No parameters.