KosmoKrator

payments

Chargebee Lua API for KosmoKrator Agents

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

7 functions 7 read 0 write Bearer token auth

Lua Namespace

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

Chargebee — Lua API Reference

list_subscriptions

List subscriptions from Chargebee with optional filtering and pagination.

Parameters

NameTypeRequiredDescription
limitintegernoNumber of subscriptions per page (max 100, default 10)
pagestringnoPagination cursor from a previous response
statestringnoFilter by state: active, cancelled, non_renewing, paused, in_trial, future

Example

local result = app.integrations.chargebee.list_subscriptions({
  state = "active",
  limit = 25
})

for _, sub in ipairs(result.subscriptions) do
  print(sub.id .. " — " .. sub.plan_id .. " — " .. sub.status)
end

-- Paginate with next_page
if result.next_page then
  local page2 = app.integrations.chargebee.list_subscriptions({
    state = "active",
    limit = 25,
    page = result.next_page
  })
end

get_subscription

Retrieve details of a single subscription.

Parameters

NameTypeRequiredDescription
idstringyesThe subscription ID

Example

local result = app.integrations.chargebee.get_subscription({
  id = "AzI6dGl0bGU9IkpvaG4gRG9lIgtleSI6IkRvZS"
})

local sub = result.subscription
print("Plan: " .. sub.plan_id)
print("Status: " .. sub.status)
print("Customer: " .. (result.customer and result.customer.email or "N/A"))

list_customers

List customers with pagination.

Parameters

NameTypeRequiredDescription
limitintegernoNumber of customers per page (max 100, default 10)
pagestringnoPagination cursor from a previous response

Example

local result = app.integrations.chargebee.list_customers({
  limit = 50
})

for _, cust in ipairs(result.customers) do
  print(cust.id .. " — " .. (cust.email or "no email") .. " — " .. (cust.first_name or ""))
end

get_customer

Retrieve details of a single customer.

Parameters

NameTypeRequiredDescription
idstringyesThe customer ID

Example

local result = app.integrations.chargebee.get_customer({
  id = "customer_xyz"
})

local cust = result.customer
print(cust.email .. " — " .. (cust.company or "no company"))

list_invoices

List invoices with optional filtering and pagination.

Parameters

NameTypeRequiredDescription
limitintegernoNumber of invoices per page (max 100, default 10)
pagestringnoPagination cursor from a previous response
statusstringnoFilter by status: paid, posted, payment_due, not_paid, voided, pending

Example

local result = app.integrations.chargebee.list_invoices({
  status = "paid",
  limit = 50
})

for _, inv in ipairs(result.invoices) do
  print(inv.id .. " — " .. inv.total .. " " .. inv.currency_code .. " — " .. inv.status)
end

get_invoice

Retrieve details of a single invoice.

Parameters

NameTypeRequiredDescription
idstringyesThe invoice ID

Example

local result = app.integrations.chargebee.get_invoice({
  id = "INV-123"
})

local inv = result.invoice
print("Total: " .. inv.total .. " " .. inv.currency_code)
print("Line items: " .. #inv.line_items)

get_current_user

Retrieve the current authenticated user information.

Parameters

None.

Example

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

print("User: " .. (result.user and result.user.email or "N/A"))

Multi-Account Usage

If you have multiple Chargebee sites configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.chargebee.list_subscriptions({state = "active"})

-- Explicit default (portable across setups)
app.integrations.chargebee.default.list_subscriptions({state = "active"})

-- Named accounts
app.integrations.chargebee.production.list_subscriptions({state = "active"})
app.integrations.chargebee.staging.list_subscriptions({state = "active"})

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

Raw agent markdown
# Chargebee — Lua API Reference

## list_subscriptions

List subscriptions from Chargebee with optional filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of subscriptions per page (max 100, default 10) |
| `page` | string | no | Pagination cursor from a previous response |
| `state` | string | no | Filter by state: `active`, `cancelled`, `non_renewing`, `paused`, `in_trial`, `future` |

### Example

```lua
local result = app.integrations.chargebee.list_subscriptions({
  state = "active",
  limit = 25
})

for _, sub in ipairs(result.subscriptions) do
  print(sub.id .. " — " .. sub.plan_id .. " — " .. sub.status)
end

-- Paginate with next_page
if result.next_page then
  local page2 = app.integrations.chargebee.list_subscriptions({
    state = "active",
    limit = 25,
    page = result.next_page
  })
end
```

---

## get_subscription

Retrieve details of a single subscription.

### Parameters

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

### Example

```lua
local result = app.integrations.chargebee.get_subscription({
  id = "AzI6dGl0bGU9IkpvaG4gRG9lIgtleSI6IkRvZS"
})

local sub = result.subscription
print("Plan: " .. sub.plan_id)
print("Status: " .. sub.status)
print("Customer: " .. (result.customer and result.customer.email or "N/A"))
```

---

## list_customers

List customers with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of customers per page (max 100, default 10) |
| `page` | string | no | Pagination cursor from a previous response |

### Example

```lua
local result = app.integrations.chargebee.list_customers({
  limit = 50
})

for _, cust in ipairs(result.customers) do
  print(cust.id .. " — " .. (cust.email or "no email") .. " — " .. (cust.first_name or ""))
end
```

---

## get_customer

Retrieve details of a single customer.

### Parameters

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

### Example

```lua
local result = app.integrations.chargebee.get_customer({
  id = "customer_xyz"
})

local cust = result.customer
print(cust.email .. " — " .. (cust.company or "no company"))
```

---

## list_invoices

List invoices with optional filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of invoices per page (max 100, default 10) |
| `page` | string | no | Pagination cursor from a previous response |
| `status` | string | no | Filter by status: `paid`, `posted`, `payment_due`, `not_paid`, `voided`, `pending` |

### Example

```lua
local result = app.integrations.chargebee.list_invoices({
  status = "paid",
  limit = 50
})

for _, inv in ipairs(result.invoices) do
  print(inv.id .. " — " .. inv.total .. " " .. inv.currency_code .. " — " .. inv.status)
end
```

---

## get_invoice

Retrieve details of a single invoice.

### Parameters

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

### Example

```lua
local result = app.integrations.chargebee.get_invoice({
  id = "INV-123"
})

local inv = result.invoice
print("Total: " .. inv.total .. " " .. inv.currency_code)
print("Line items: " .. #inv.line_items)
```

---

## get_current_user

Retrieve the current authenticated user information.

### Parameters

None.

### Example

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

print("User: " .. (result.user and result.user.email or "N/A"))
```

---

## Multi-Account Usage

If you have multiple Chargebee sites configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.chargebee.list_subscriptions({state = "active"})

-- Explicit default (portable across setups)
app.integrations.chargebee.default.list_subscriptions({state = "active"})

-- Named accounts
app.integrations.chargebee.production.list_subscriptions({state = "active"})
app.integrations.chargebee.staging.list_subscriptions({state = "active"})
```

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

Metadata-Derived Lua Example

local result = app.integrations.chargebee.chargebee_list_subscriptions({
  limit = 1,
  page = "example_page",
  state = "example_state"
})
print(result)

Functions

chargebee_list_subscriptions

List subscriptions from Chargebee. Supports filtering by state (active, cancelled, non_renewing, paused, in_trial, future) and pagination. Returns subscription details including plan, status, and billing period.

Operation
Read read
Full name
chargebee.chargebee_list_subscriptions
ParameterTypeRequiredDescription
limit integer no Number of subscriptions to return per page (max 100, default 10).
page string no Pagination cursor — pass the value from a previous response to get the next page.
state string no Filter by subscription state: active, cancelled, non_renewing, paused, in_trial, future.

chargebee_get_subscription

Retrieve detailed information about a specific Chargebee subscription by its ID, including plan details, billing period, status, and associated customer.

Operation
Read read
Full name
chargebee.chargebee_get_subscription
ParameterTypeRequiredDescription
id string yes The subscription ID.

chargebee_list_customers

List customers from Chargebee with pagination. Returns customer details including email, name, company, and billing address.

Operation
Read read
Full name
chargebee.chargebee_list_customers
ParameterTypeRequiredDescription
limit integer no Number of customers to return per page (max 100, default 10).
page string no Pagination cursor — pass the value from a previous response to get the next page.

chargebee_get_customer

Retrieve detailed information about a specific Chargebee customer by their ID, including contact details, billing address, and payment method.

Operation
Read read
Full name
chargebee.chargebee_get_customer
ParameterTypeRequiredDescription
id string yes The customer ID.

chargebee_list_invoices

List invoices from Chargebee. Supports filtering by status (paid, posted, payment_due, not_paid, voided, pending) and pagination.

Operation
Read read
Full name
chargebee.chargebee_list_invoices
ParameterTypeRequiredDescription
limit integer no Number of invoices to return per page (max 100, default 10).
page string no Pagination cursor — pass the value from a previous response to get the next page.
status string no Filter by invoice status: paid, posted, payment_due, not_paid, voided, pending.

chargebee_get_invoice

Retrieve detailed information about a specific Chargebee invoice by its ID, including line items, totals, tax, and payment status.

Operation
Read read
Full name
chargebee.chargebee_get_invoice
ParameterTypeRequiredDescription
id string yes The invoice ID.

chargebee_get_current_user

Retrieve the current authenticated user information from Chargebee. Use this to verify credentials are working and check user details.

Operation
Read read
Full name
chargebee.chargebee_get_current_user
ParameterTypeRequiredDescription
No parameters.