KosmoKrator

analytics

ChartMogul Lua API for KosmoKrator Agents

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

Lua Namespace

Agents call this integration through app.integrations.chartmogul.*. Use lua_read_doc("integrations.chartmogul") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic ChartMogul workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.chartmogul.list_customers({per_page = 1, cursor = "example_cursor", status = "example_status", email = "example_email", data_source_uuid = "example_data_source_uuid", external_id = "example_external_id", system = "example_system"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("chartmogul"))' --json
kosmo integrations:lua --eval 'print(docs.read("chartmogul.list_customers"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local chartmogul = app.integrations.chartmogul
local result = chartmogul.list_customers({per_page = 1, cursor = "example_cursor", status = "example_status", email = "example_email", data_source_uuid = "example_data_source_uuid", external_id = "example_external_id", system = "example_system"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.chartmogul, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.chartmogul.default.* or app.integrations.chartmogul.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need ChartMogul, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

ChartMogul

ChartMogul tools query subscription analytics data through the ChartMogul API.

Namespace

chartmogul

Authentication

ChartMogul uses HTTP Basic Auth. Configure api_key; the integration sends it as the Basic Auth username with an empty password, matching ChartMogul’s current API-key documentation.

Available Tools

  • chartmogul_list_customers - List customers with cursor pagination and filters.
  • chartmogul_get_customer - Retrieve one customer by ChartMogul customer UUID.
  • chartmogul_list_subscriptions - List subscriptions for a required customer_uuid.
  • chartmogul_list_plans - List billing plans with cursor pagination.
  • chartmogul_list_invoices - List API-created invoices with customer or external-ID filters.
  • chartmogul_get_metrics - Retrieve all key metrics for a date range.
  • chartmogul_get_current_user - Backward-compatible tool name that calls /v1/ping and returns pong data. ChartMogul’s public API does not expose a user-profile endpoint for this package.

Pagination

List endpoints use ChartMogul cursor pagination:

  • Pass per_page to control page size, up to 200.
  • If a response has has_more = true, pass the returned cursor into the next request.
  • Deprecated response fields such as page and current_page may appear, but new calls should use cursor.

Examples

local customers = chartmogul.chartmogul_list_customers({
  per_page = 50,
  status = "Active",
  system = "Stripe"
})
local subscriptions = chartmogul.chartmogul_list_subscriptions({
  customer_uuid = "cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  per_page = 100
})
local invoices = chartmogul.chartmogul_list_invoices({
  customer_uuid = "cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  external_id = "inv_0001"
})
local metrics = chartmogul.chartmogul_get_metrics({
  start_date = "2026-01-01",
  end_date = "2026-03-31",
  interval = "month",
  geo = "US,GB",
  plans = "Gold Monthly"
})

Responses are returned in ChartMogul’s upstream JSON shape.

Raw agent markdown
# ChartMogul

ChartMogul tools query subscription analytics data through the ChartMogul API.

## Namespace

`chartmogul`

## Authentication

ChartMogul uses HTTP Basic Auth. Configure `api_key`; the integration sends it
as the Basic Auth username with an empty password, matching ChartMogul's current
API-key documentation.

## Available Tools

- `chartmogul_list_customers` - List customers with cursor pagination and filters.
- `chartmogul_get_customer` - Retrieve one customer by ChartMogul customer UUID.
- `chartmogul_list_subscriptions` - List subscriptions for a required `customer_uuid`.
- `chartmogul_list_plans` - List billing plans with cursor pagination.
- `chartmogul_list_invoices` - List API-created invoices with customer or external-ID filters.
- `chartmogul_get_metrics` - Retrieve all key metrics for a date range.
- `chartmogul_get_current_user` - Backward-compatible tool name that calls `/v1/ping` and returns pong data. ChartMogul's public API does not expose a user-profile endpoint for this package.

## Pagination

List endpoints use ChartMogul cursor pagination:

- Pass `per_page` to control page size, up to 200.
- If a response has `has_more = true`, pass the returned `cursor` into the next
  request.
- Deprecated response fields such as `page` and `current_page` may appear, but
  new calls should use `cursor`.

## Examples

```lua
local customers = chartmogul.chartmogul_list_customers({
  per_page = 50,
  status = "Active",
  system = "Stripe"
})
```

```lua
local subscriptions = chartmogul.chartmogul_list_subscriptions({
  customer_uuid = "cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  per_page = 100
})
```

```lua
local invoices = chartmogul.chartmogul_list_invoices({
  customer_uuid = "cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  external_id = "inv_0001"
})
```

```lua
local metrics = chartmogul.chartmogul_get_metrics({
  start_date = "2026-01-01",
  end_date = "2026-03-31",
  interval = "month",
  geo = "US,GB",
  plans = "Gold Monthly"
})
```

Responses are returned in ChartMogul's upstream JSON shape.
Metadata-derived Lua example
local result = app.integrations.chartmogul.list_customers({per_page = 1, cursor = "example_cursor", status = "example_status", email = "example_email", data_source_uuid = "example_data_source_uuid", external_id = "example_external_id", system = "example_system"})
print(result)

Functions

list_customers Read

List customers from ChartMogul. Supports cursor pagination and filters including status, email, data source UUID, external ID, and billing system.

Lua path
app.integrations.chartmogul.list_customers
Full name
chartmogul.chartmogul_list_customers
ParameterTypeRequiredDescription
per_page integer no Number of results per page (default: 50, max: 200).
cursor string no Cursor from a previous response. Use only when has_more is true.
status string no Filter by customer status. Common values: "Active", "Cancelled", "Future".
email string no Filter by customer email address.
data_source_uuid string no Filter by ChartMogul data source UUID.
external_id string no Filter by customer external ID.
system string no Filter by billing system name, e.g. Stripe or Custom.
get_customer Read

Get details for a single ChartMogul customer by UUID. Returns full customer information including attributes, address, and custom fields.

Lua path
app.integrations.chartmogul.get_customer
Full name
chartmogul.chartmogul_get_customer
ParameterTypeRequiredDescription
id string yes The ChartMogul customer UUID.
list_customer_subscriptions Read

List subscriptions for a specific ChartMogul customer. The current API endpoint is /v1/customers/{CUSTOMER_UUID}/subscriptions and uses cursor pagination.

Lua path
app.integrations.chartmogul.list_customer_subscriptions
Full name
chartmogul.chartmogul_list_subscriptions
ParameterTypeRequiredDescription
per_page integer no Number of results per page (default: 50, max: 200).
cursor string no Cursor from a previous response. Use only when has_more is true.
customer_uuid string yes The ChartMogul customer UUID.
list_plans Read

List billing plans from ChartMogul. Supports cursor pagination and optional filtering by data source UUID.

Lua path
app.integrations.chartmogul.list_plans
Full name
chartmogul.chartmogul_list_plans
ParameterTypeRequiredDescription
per_page integer no Number of results per page (default: 50, max: 200).
cursor string no Cursor from a previous response. Use only when has_more is true.
data_source_uuid string no Filter by ChartMogul data source UUID.
list_invoices Read

List invoices from ChartMogul. Supports cursor pagination and filters by customer UUID or invoice external ID.

Lua path
app.integrations.chartmogul.list_invoices
Full name
chartmogul.chartmogul_list_invoices
ParameterTypeRequiredDescription
per_page integer no Number of results per page (default: 50, max: 200).
cursor string no Cursor from a previous response. Use only when has_more is true.
customer_uuid string no Filter invoices by customer UUID.
external_id string no Filter invoices by external ID.
get_metrics Read

Query subscription analytics metrics from ChartMogul. Returns key metrics like MRR, ARR, churn rate, customer count, and more. Specify a date range and interval for timeseries data.

Lua path
app.integrations.chartmogul.get_metrics
Full name
chartmogul.chartmogul_get_metrics
ParameterTypeRequiredDescription
start_date string yes Start date for the metrics period (ISO 8601, e.g. "2025-01-01").
end_date string yes End date for the metrics period (ISO 8601, e.g. "2025-01-31").
interval string no Interval for grouping results: "day", "week", "month", "quarter", or "year" (default: "month").
geo string no Comma-separated ISO country codes, e.g. US,GB,DE.
plans string no Comma-separated plan UUIDs, external IDs, or names.
filters string no ChartMogul advanced filter expression.
ping_api Read

Verify ChartMogul API credentials with the /v1/ping endpoint. Returns pong data when the API key is valid.

Lua path
app.integrations.chartmogul.ping_api
Full name
chartmogul.chartmogul_get_current_user
ParameterTypeRequiredDescription
No parameters.