productivity
ChurnZero Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the ChurnZero KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.churnzero.*.
Use lua_read_doc("integrations.churnzero") 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
ChurnZero workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.churnzero.set_attributes({entity = "example_entity", account_external_id = "example_account_external_id", contact_external_id = "example_contact_external_id", attributes = "example_attributes"}))' --json kosmo integrations:lua --eval 'print(docs.read("churnzero"))' --json
kosmo integrations:lua --eval 'print(docs.read("churnzero.set_attributes"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local churnzero = app.integrations.churnzero
local result = churnzero.set_attributes({entity = "example_entity", account_external_id = "example_account_external_id", contact_external_id = "example_contact_external_id", attributes = "example_attributes"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.churnzero, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.churnzero.default.* or app.integrations.churnzero.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need ChurnZero, use the narrower 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.
ChurnZero Lua API Reference
ChurnZero uses an action-based HTTP API at an /i endpoint. The integration adds the secret appKey automatically and exposes the documented action surface for attributes, events, and lifecycle writes.
ChurnZero does not expose a normal paginated REST read API through this package. Use your system of record for reads and push account/contact changes into ChurnZero.
set_attributes
Set one or more attributes on an account or contact. Each attribute is sent through a setAttribute action.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
entity | string | yes | account or contact |
account_external_id | string | yes | Account ID from your source system |
contact_external_id | string | contact only | Contact ID from your source system |
attributes | table | yes | Attribute name/value pairs |
Example
app.integrations.churnzero.set_attributes({
entity = "account",
account_external_id = "acct_123",
attributes = {
Name = "Example Account",
ARR = 12000
}
})
For contact attributes:
app.integrations.churnzero.set_attributes({
entity = "contact",
account_external_id = "acct_123",
contact_external_id = "user_456",
attributes = {
Email = "person@example.test",
Role = "Admin"
}
})
track_event
Track an event for an account and optionally a contact.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
account_external_id | string | yes | Account ID from your source system |
event_name | string | yes | Event name in ChurnZero |
contact_external_id | string | no | Contact ID from your source system |
description | string | no | Event description |
quantity | number | no | Numeric value for usage-style events |
custom_fields | table | no | Event custom fields |
Example
app.integrations.churnzero.track_event({
account_external_id = "acct_123",
contact_external_id = "user_456",
event_name = "Report Exported",
quantity = 1
})
increment_attribute
Increment a numeric account or contact attribute.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
entity | string | yes | account or contact |
account_external_id | string | yes | Account ID from your source system |
contact_external_id | string | contact only | Contact ID from your source system |
name | string | yes | Numeric attribute name |
value | number | yes | Amount to add; can be negative |
Example
app.integrations.churnzero.increment_attribute({
entity = "contact",
account_external_id = "acct_123",
contact_external_id = "user_456",
name = "Login Count",
value = 1
})
delete_contact
Delete a contact by external IDs. This is destructive.
app.integrations.churnzero.delete_contact({
account_external_id = "acct_123",
contact_external_id = "user_456"
})
delete_account
Delete an account by external ID. This is destructive and may affect related contacts and event history.
app.integrations.churnzero.delete_account({
account_external_id = "acct_123"
})
send_action
Send an advanced raw ChurnZero action. Do not include appKey; the integration adds it from credentials.
app.integrations.churnzero.send_action({
params = {
action = "trackEvent",
accountExternalId = "acct_123",
eventName = "Custom Action"
}
})
Notes
Attribute names must match fields configured in ChurnZero. Custom fields are not necessarily created on the fly. The HTTP API often returns a small status payload, so treat successful calls as write acknowledgements rather than fresh record reads.
Multi-Account Usage
app.integrations.churnzero.set_attributes({...})
app.integrations.churnzero.default.set_attributes({...})
app.integrations.churnzero.eu_team.track_event({...})Raw agent markdown
# ChurnZero Lua API Reference
ChurnZero uses an action-based HTTP API at an `/i` endpoint. The integration adds the secret `appKey` automatically and exposes the documented action surface for attributes, events, and lifecycle writes.
ChurnZero does not expose a normal paginated REST read API through this package. Use your system of record for reads and push account/contact changes into ChurnZero.
## set_attributes
Set one or more attributes on an account or contact. Each attribute is sent through a `setAttribute` action.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entity` | string | yes | `account` or `contact` |
| `account_external_id` | string | yes | Account ID from your source system |
| `contact_external_id` | string | contact only | Contact ID from your source system |
| `attributes` | table | yes | Attribute name/value pairs |
### Example
```lua
app.integrations.churnzero.set_attributes({
entity = "account",
account_external_id = "acct_123",
attributes = {
Name = "Example Account",
ARR = 12000
}
})
```
For contact attributes:
```lua
app.integrations.churnzero.set_attributes({
entity = "contact",
account_external_id = "acct_123",
contact_external_id = "user_456",
attributes = {
Email = "person@example.test",
Role = "Admin"
}
})
```
## track_event
Track an event for an account and optionally a contact.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `account_external_id` | string | yes | Account ID from your source system |
| `event_name` | string | yes | Event name in ChurnZero |
| `contact_external_id` | string | no | Contact ID from your source system |
| `description` | string | no | Event description |
| `quantity` | number | no | Numeric value for usage-style events |
| `custom_fields` | table | no | Event custom fields |
### Example
```lua
app.integrations.churnzero.track_event({
account_external_id = "acct_123",
contact_external_id = "user_456",
event_name = "Report Exported",
quantity = 1
})
```
## increment_attribute
Increment a numeric account or contact attribute.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entity` | string | yes | `account` or `contact` |
| `account_external_id` | string | yes | Account ID from your source system |
| `contact_external_id` | string | contact only | Contact ID from your source system |
| `name` | string | yes | Numeric attribute name |
| `value` | number | yes | Amount to add; can be negative |
### Example
```lua
app.integrations.churnzero.increment_attribute({
entity = "contact",
account_external_id = "acct_123",
contact_external_id = "user_456",
name = "Login Count",
value = 1
})
```
## delete_contact
Delete a contact by external IDs. This is destructive.
```lua
app.integrations.churnzero.delete_contact({
account_external_id = "acct_123",
contact_external_id = "user_456"
})
```
## delete_account
Delete an account by external ID. This is destructive and may affect related contacts and event history.
```lua
app.integrations.churnzero.delete_account({
account_external_id = "acct_123"
})
```
## send_action
Send an advanced raw ChurnZero action. Do not include `appKey`; the integration adds it from credentials.
```lua
app.integrations.churnzero.send_action({
params = {
action = "trackEvent",
accountExternalId = "acct_123",
eventName = "Custom Action"
}
})
```
## Notes
Attribute names must match fields configured in ChurnZero. Custom fields are not necessarily created on the fly. The HTTP API often returns a small status payload, so treat successful calls as write acknowledgements rather than fresh record reads.
## Multi-Account Usage
```lua
app.integrations.churnzero.set_attributes({...})
app.integrations.churnzero.default.set_attributes({...})
app.integrations.churnzero.eu_team.track_event({...})
``` local result = app.integrations.churnzero.set_attributes({entity = "example_entity", account_external_id = "example_account_external_id", contact_external_id = "example_contact_external_id", attributes = "example_attributes"})
print(result) Functions
set_attributes Write
Set one or more ChurnZero account or contact attributes. For contacts, provide both account_external_id and contact_external_id. Attribute names must already exist in ChurnZero where required.
- Lua path
app.integrations.churnzero.set_attributes- Full name
churnzero.churnzero_set_attributes
| Parameter | Type | Required | Description |
|---|---|---|---|
entity | string | yes | Whether to update an account or contact attribute. |
account_external_id | string | yes | Account identifier from your source system. |
contact_external_id | string | no | Contact identifier from your source system. Required when entity is contact. |
attributes | object | yes | Attribute name/value pairs to set in ChurnZero. |
track_event Write
Track a ChurnZero event for an account and optionally a contact. Event names are created by ChurnZero if they do not already exist.
- Lua path
app.integrations.churnzero.track_event- Full name
churnzero.churnzero_track_event
| Parameter | Type | Required | Description |
|---|---|---|---|
account_external_id | string | yes | Account identifier from your source system. |
event_name | string | yes | ChurnZero event name. |
contact_external_id | string | no | Contact identifier from your source system. |
description | string | no | Optional event description. |
quantity | number | no | Optional numeric quantity associated with the event. |
custom_fields | object | no | Optional custom field map for the event. |
increment_attribute Write
Increment a numeric ChurnZero account or contact attribute. Use a negative amount to decrement.
- Lua path
app.integrations.churnzero.increment_attribute- Full name
churnzero.churnzero_increment_attribute
| Parameter | Type | Required | Description |
|---|---|---|---|
entity | string | yes | Whether to increment an account or contact attribute. |
account_external_id | string | yes | Account identifier from your source system. |
contact_external_id | string | no | Contact identifier from your source system. Required when entity is contact. |
name | string | yes | Numeric attribute name configured in ChurnZero. |
value | number | yes | Amount to add to the current value. |
delete_contact Write
Delete a ChurnZero contact by account_external_id and contact_external_id. This action is destructive.
- Lua path
app.integrations.churnzero.delete_contact- Full name
churnzero.churnzero_delete_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
account_external_id | string | yes | Account identifier from your source system. |
contact_external_id | string | yes | Contact identifier from your source system. |
delete_account Write
Delete a ChurnZero account by account_external_id. This action is destructive and may affect related contacts.
- Lua path
app.integrations.churnzero.delete_account- Full name
churnzero.churnzero_delete_account
| Parameter | Type | Required | Description |
|---|---|---|---|
account_external_id | string | yes | Account identifier from your source system. |
send_action Write
Send an advanced raw ChurnZero HTTP API action. Do not include appKey; the integration adds credentials automatically.
- Lua path
app.integrations.churnzero.send_action- Full name
churnzero.churnzero_send_action
| Parameter | Type | Required | Description |
|---|---|---|---|
params | object | yes | ChurnZero action query parameters excluding appKey, for example action, accountExternalId, and eventName. |