productivity
Gainsight Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Gainsight KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.gainsight.*.
Use lua_read_doc("integrations.gainsight") 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
Gainsight workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.gainsight.list_companies({page = 1, limit = 1, search = "example_search"}))' --json kosmo integrations:lua --eval 'print(docs.read("gainsight"))' --json
kosmo integrations:lua --eval 'print(docs.read("gainsight.list_companies"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local gainsight = app.integrations.gainsight
local result = gainsight.list_companies({page = 1, limit = 1, search = "example_search"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.gainsight, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.gainsight.default.* or app.integrations.gainsight.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Gainsight, 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.
Gainsight — Lua API Reference
list_companies
List companies from Gainsight.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (starting from 1) |
limit | integer | no | Maximum number of companies to return (default: 50) |
search | string | no | Search term to filter companies by name |
Response
Returns an object with:
| Field | Type | Description |
|---|---|---|
companies | array | Array of company objects |
count | integer | Number of companies returned |
totalRecords | integer | Total matching records (if available) |
Example
local result = app.integrations.gainsight.list_companies({
search = "Acme"
})
for _, company in ipairs(result.companies) do
print(company.name .. " — Health: " .. company.healthScore)
end
get_company
Get detailed information about a specific company.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
companyId | string | yes | The unique company identifier |
Example
local result = app.integrations.gainsight.get_company({
companyId = "1A2B3C4D"
})
print("Company: " .. result.name)
print("ARR: " .. result.arr)
print("Health Score: " .. result.healthScore)
print("Lifecycle Stage: " .. result.lifecycleStage)
list_users
List users in the Gainsight tenant.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (starting from 1) |
limit | integer | no | Maximum number of users to return (default: 50) |
role | string | no | Filter users by role (e.g., “Admin”, “CSM”, “Manager”) |
Response
Returns an object with:
| Field | Type | Description |
|---|---|---|
users | array | Array of user objects |
count | integer | Number of users returned |
totalRecords | integer | Total matching records (if available) |
Example
local result = app.integrations.gainsight.list_users({
role = "CSM"
})
for _, user in ipairs(result.users) do
print(user.name .. " — " .. user.email .. " — " .. user.role)
end
get_user
Get detailed information about a specific user.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId | string | yes | The unique user identifier |
Example
local result = app.integrations.gainsight.get_user({
userId = "5E6F7G8H"
})
print("Name: " .. result.name)
print("Email: " .. result.email)
print("Role: " .. result.role)
list_surveys
List surveys from Gainsight.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (starting from 1) |
limit | integer | no | Maximum number of surveys to return (default: 50) |
status | string | no | Filter surveys by status (e.g., “active”, “draft”, “closed”) |
Response
Returns an object with:
| Field | Type | Description |
|---|---|---|
surveys | array | Array of survey objects |
count | integer | Number of surveys returned |
totalRecords | integer | Total matching records (if available) |
Example
local result = app.integrations.gainsight.list_surveys({
status = "active"
})
for _, survey in ipairs(result.surveys) do
print(survey.name .. " — Responses: " .. survey.responseCount)
end
get_survey
Get detailed information about a specific survey.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
surveyId | string | yes | The unique survey identifier |
Example
local result = app.integrations.gainsight.get_survey({
surveyId = "9I0J1K2L"
})
print("Survey: " .. result.name)
print("Type: " .. result.type)
print("Status: " .. result.status)
print("Responses: " .. result.responseCount)
get_current_user
Get the currently authenticated Gainsight user profile.
Parameters
None.
Example
local result = app.integrations.gainsight.get_current_user({})
print("Logged in as: " .. result.name)
print("Email: " .. result.email)
print("Role: " .. result.role)
Multi-Account Usage
If you have multiple Gainsight accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.gainsight.list_companies({})
-- Explicit default (portable across setups)
app.integrations.gainsight.default.list_companies({})
-- Named accounts
app.integrations.gainsight.us_tenant.list_companies({})
app.integrations.gainsight.eu_tenant.list_companies({})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Gainsight — Lua API Reference
## list_companies
List companies from Gainsight.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (starting from 1) |
| `limit` | integer | no | Maximum number of companies to return (default: 50) |
| `search` | string | no | Search term to filter companies by name |
### Response
Returns an object with:
| Field | Type | Description |
|-------|------|-------------|
| `companies` | array | Array of company objects |
| `count` | integer | Number of companies returned |
| `totalRecords` | integer | Total matching records (if available) |
### Example
```lua
local result = app.integrations.gainsight.list_companies({
search = "Acme"
})
for _, company in ipairs(result.companies) do
print(company.name .. " — Health: " .. company.healthScore)
end
```
---
## get_company
Get detailed information about a specific company.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `companyId` | string | yes | The unique company identifier |
### Example
```lua
local result = app.integrations.gainsight.get_company({
companyId = "1A2B3C4D"
})
print("Company: " .. result.name)
print("ARR: " .. result.arr)
print("Health Score: " .. result.healthScore)
print("Lifecycle Stage: " .. result.lifecycleStage)
```
---
## list_users
List users in the Gainsight tenant.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (starting from 1) |
| `limit` | integer | no | Maximum number of users to return (default: 50) |
| `role` | string | no | Filter users by role (e.g., "Admin", "CSM", "Manager") |
### Response
Returns an object with:
| Field | Type | Description |
|-------|------|-------------|
| `users` | array | Array of user objects |
| `count` | integer | Number of users returned |
| `totalRecords` | integer | Total matching records (if available) |
### Example
```lua
local result = app.integrations.gainsight.list_users({
role = "CSM"
})
for _, user in ipairs(result.users) do
print(user.name .. " — " .. user.email .. " — " .. user.role)
end
```
---
## get_user
Get detailed information about a specific user.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `userId` | string | yes | The unique user identifier |
### Example
```lua
local result = app.integrations.gainsight.get_user({
userId = "5E6F7G8H"
})
print("Name: " .. result.name)
print("Email: " .. result.email)
print("Role: " .. result.role)
```
---
## list_surveys
List surveys from Gainsight.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number for pagination (starting from 1) |
| `limit` | integer | no | Maximum number of surveys to return (default: 50) |
| `status` | string | no | Filter surveys by status (e.g., "active", "draft", "closed") |
### Response
Returns an object with:
| Field | Type | Description |
|-------|------|-------------|
| `surveys` | array | Array of survey objects |
| `count` | integer | Number of surveys returned |
| `totalRecords` | integer | Total matching records (if available) |
### Example
```lua
local result = app.integrations.gainsight.list_surveys({
status = "active"
})
for _, survey in ipairs(result.surveys) do
print(survey.name .. " — Responses: " .. survey.responseCount)
end
```
---
## get_survey
Get detailed information about a specific survey.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `surveyId` | string | yes | The unique survey identifier |
### Example
```lua
local result = app.integrations.gainsight.get_survey({
surveyId = "9I0J1K2L"
})
print("Survey: " .. result.name)
print("Type: " .. result.type)
print("Status: " .. result.status)
print("Responses: " .. result.responseCount)
```
---
## get_current_user
Get the currently authenticated Gainsight user profile.
### Parameters
None.
### Example
```lua
local result = app.integrations.gainsight.get_current_user({})
print("Logged in as: " .. result.name)
print("Email: " .. result.email)
print("Role: " .. result.role)
```
---
## Multi-Account Usage
If you have multiple Gainsight accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.gainsight.list_companies({})
-- Explicit default (portable across setups)
app.integrations.gainsight.default.list_companies({})
-- Named accounts
app.integrations.gainsight.us_tenant.list_companies({})
app.integrations.gainsight.eu_tenant.list_companies({})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.gainsight.list_companies({page = 1, limit = 1, search = "example_search"})
print(result) Functions
list_companies Read
List companies from Gainsight. Returns company details including name, industry, ARR, health score, and lifecycle stage.
- Lua path
app.integrations.gainsight.list_companies- Full name
gainsight.gainsight_list_companies
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (starting from 1). |
limit | integer | no | Maximum number of companies to return (default: 50). |
search | string | no | Search term to filter companies by name. |
get_company Read
Get detailed information about a specific company in Gainsight, including health score, ARR, lifecycle stage, and CSM assignment.
- Lua path
app.integrations.gainsight.get_company- Full name
gainsight.gainsight_get_company
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId | string | yes | The unique company identifier (Gainsight Company ID). |
list_users Read
List users in the Gainsight tenant. Returns user details including name, email, role, and last active date.
- Lua path
app.integrations.gainsight.list_users- Full name
gainsight.gainsight_list_users
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (starting from 1). |
limit | integer | no | Maximum number of users to return (default: 50). |
role | string | no | Filter users by role (e.g., "Admin", "CSM", "Manager"). |
get_user Read
Get detailed information about a specific user in Gainsight, including role, assigned accounts, and activity data.
- Lua path
app.integrations.gainsight.get_user- Full name
gainsight.gainsight_get_user
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | yes | The unique user identifier (Gainsight User ID). |
list_surveys Read
List surveys from Gainsight. Returns survey details including name, type, status, response count, and creation date.
- Lua path
app.integrations.gainsight.list_surveys- Full name
gainsight.gainsight_list_surveys
| Parameter | Type | Required | Description |
|---|---|---|---|
page | integer | no | Page number for pagination (starting from 1). |
limit | integer | no | Maximum number of surveys to return (default: 50). |
status | string | no | Filter surveys by status (e.g., "active", "draft", "closed"). |
get_survey Read
Get detailed information about a specific survey in Gainsight, including questions, response statistics, and distribution settings.
- Lua path
app.integrations.gainsight.get_survey- Full name
gainsight.gainsight_get_survey
| Parameter | Type | Required | Description |
|---|---|---|---|
surveyId | string | yes | The unique survey identifier (Gainsight Survey ID). |
get_current_user Read
Get the currently authenticated Gainsight user profile. Useful for verifying credentials and understanding whose data is being accessed.
- Lua path
app.integrations.gainsight.get_current_user- Full name
gainsight.gainsight_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||