productivity
Close CRM Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Close CRM KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.close.*.
Use lua_read_doc("integrations.close") 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
Close CRM workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.close.list_leads({query = "example_query", limit = 1, skip = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("close"))' --json
kosmo integrations:lua --eval 'print(docs.read("close.list_leads"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local close = app.integrations.close
local result = close.list_leads({query = "example_query", limit = 1, skip = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.close, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.close.default.* or app.integrations.close.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Close CRM, 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.
Close CRM Lua API Reference
Namespace: close
Close tools call the Close REST API at https://api.close.com/api/v1 using HTTP Basic auth with the API key as the username and an empty password. Outputs are normalized only where older list tools already wrapped Close pagination; newer endpoint tools return the Close JSON object or list response directly.
Common IDs
- Leads use IDs such as
lead_abc123. - Contacts use IDs such as
cont_abc123. - Opportunities use IDs such as
oppo_abc123. - Tasks use IDs such as
task_abc123. - Users use IDs such as
user_abc123.
Leads
local leads = app.integrations.close.list_leads({
query = "status:Potential",
limit = 25,
skip = 0,
})
local lead = app.integrations.close.get_lead({ id = "lead_example" })
local created = app.integrations.close.create_lead({
name = "Example Corp",
url = "https://example.test",
contacts = {
{
name = "Pat Example",
emails = {{ email = "pat@example.test", type = "office" }},
},
},
})
local updated = app.integrations.close.update_lead({
id = "lead_example",
status_id = "stat_example",
})
delete_lead permanently deletes the lead and associated Close child records:
app.integrations.close.delete_lead({ id = "lead_example" })
Contacts
local contacts = app.integrations.close.list_contacts({
lead_id = "lead_example",
limit = 25,
})
local contact = app.integrations.close.get_contact({ id = "cont_example" })
local created = app.integrations.close.create_contact({
lead_id = "lead_example",
name = "Sam Contact",
title = "VP Sales",
emails = {{ email = "sam@example.test", type = "office" }},
phones = {{ phone = "+15550101010", type = "office" }},
})
local updated = app.integrations.close.update_contact({
id = "cont_example",
title = "Head of Sales",
})
app.integrations.close.delete_contact({ id = "cont_example" })
Opportunities
local opportunities = app.integrations.close.list_opportunities({
lead_id = "lead_example",
status_id = "stat_example",
_limit = 25,
})
local opportunity = app.integrations.close.get_opportunity({ id = "oppo_example" })
local created = app.integrations.close.create_opportunity({
lead_id = "lead_example",
status_id = "stat_example",
note = "Initial deal",
value = 250000,
value_period = "one_time",
expected_close_date = "2026-06-30",
confidence = 60,
})
local updated = app.integrations.close.update_opportunity({
id = "oppo_example",
confidence = 75,
})
app.integrations.close.delete_opportunity({ id = "oppo_example" })
Tasks
Close task list filters accept fields such as lead_id, assigned_to, is_complete, _type, date filters, _limit, and _skip. Use _type = "all" when you want system task types in addition to lead tasks.
local tasks = app.integrations.close.list_tasks({
lead_id = "lead_example",
assigned_to = "user_example",
is_complete = false,
_type = "all",
})
local created = app.integrations.close.create_task({
text = "Follow up with buyer",
lead_id = "lead_example",
assignee_id = "user_example",
date = "2026-05-15",
})
local task = app.integrations.close.get_task({ id = "task_example" })
local updated = app.integrations.close.update_task({
id = "task_example",
is_complete = true,
})
app.integrations.close.delete_task({ id = "task_example" })
Activities And Notes
list_activities lists activity records across types. Note-specific tools map to /activity/note/.
local activities = app.integrations.close.list_activities({
lead_id = "lead_example",
type = "note",
limit = 25,
})
local notes = app.integrations.close.list_notes({
lead_id = "lead_example",
_limit = 25,
})
local note = app.integrations.close.create_note({
lead_id = "lead_example",
note = "Buyer asked for implementation timeline.",
})
local fetched = app.integrations.close.get_note({ id = "acti_example" })
local updated = app.integrations.close.update_note({
id = "acti_example",
note = "Updated implementation timeline note.",
})
app.integrations.close.delete_note({ id = "acti_example" })
Users
local me = app.integrations.close.get_current_user({})
local users = app.integrations.close.list_users({
_limit = 50,
})
local user = app.integrations.close.get_user({ id = "user_example" })
local availability = app.integrations.close.list_user_availability({})
Statuses And Pipelines
Lead statuses:
local statuses = app.integrations.close.list_lead_statuses({})
local created = app.integrations.close.create_lead_status({
label = "Qualified",
})
app.integrations.close.update_lead_status({
id = "stat_example",
label = "Qualified Inbound",
})
app.integrations.close.delete_lead_status({ id = "stat_example" })
Opportunity statuses:
local statuses = app.integrations.close.list_opportunity_statuses({})
local created = app.integrations.close.create_opportunity_status({
label = "Negotiation",
type = "active",
pipeline_id = "pipe_example",
})
app.integrations.close.update_opportunity_status({
id = "stat_example",
label = "Contracting",
})
app.integrations.close.delete_opportunity_status({ id = "stat_example" })
Pipelines:
local pipelines = app.integrations.close.list_pipelines({})
local pipeline = app.integrations.close.create_pipeline({
name = "Outbound Sales",
})
app.integrations.close.update_pipeline({
id = "pipe_example",
name = "Enterprise Sales",
})
app.integrations.close.delete_pipeline({ id = "pipe_example" })
Multi-Account
Hosts can expose account-scoped namespaces. The functions are the same; only the resolved Close credentials differ.
app.integrations.close.default.list_leads({ query = "Acme" })
app.integrations.close.enterprise.list_opportunities({ _limit = 10 })Raw agent markdown
# Close CRM Lua API Reference
Namespace: `close`
Close tools call the Close REST API at `https://api.close.com/api/v1` using HTTP Basic auth with the API key as the username and an empty password. Outputs are normalized only where older list tools already wrapped Close pagination; newer endpoint tools return the Close JSON object or list response directly.
## Common IDs
- Leads use IDs such as `lead_abc123`.
- Contacts use IDs such as `cont_abc123`.
- Opportunities use IDs such as `oppo_abc123`.
- Tasks use IDs such as `task_abc123`.
- Users use IDs such as `user_abc123`.
## Leads
```lua
local leads = app.integrations.close.list_leads({
query = "status:Potential",
limit = 25,
skip = 0,
})
local lead = app.integrations.close.get_lead({ id = "lead_example" })
local created = app.integrations.close.create_lead({
name = "Example Corp",
url = "https://example.test",
contacts = {
{
name = "Pat Example",
emails = {{ email = "pat@example.test", type = "office" }},
},
},
})
local updated = app.integrations.close.update_lead({
id = "lead_example",
status_id = "stat_example",
})
```
`delete_lead` permanently deletes the lead and associated Close child records:
```lua
app.integrations.close.delete_lead({ id = "lead_example" })
```
## Contacts
```lua
local contacts = app.integrations.close.list_contacts({
lead_id = "lead_example",
limit = 25,
})
local contact = app.integrations.close.get_contact({ id = "cont_example" })
local created = app.integrations.close.create_contact({
lead_id = "lead_example",
name = "Sam Contact",
title = "VP Sales",
emails = {{ email = "sam@example.test", type = "office" }},
phones = {{ phone = "+15550101010", type = "office" }},
})
local updated = app.integrations.close.update_contact({
id = "cont_example",
title = "Head of Sales",
})
app.integrations.close.delete_contact({ id = "cont_example" })
```
## Opportunities
```lua
local opportunities = app.integrations.close.list_opportunities({
lead_id = "lead_example",
status_id = "stat_example",
_limit = 25,
})
local opportunity = app.integrations.close.get_opportunity({ id = "oppo_example" })
local created = app.integrations.close.create_opportunity({
lead_id = "lead_example",
status_id = "stat_example",
note = "Initial deal",
value = 250000,
value_period = "one_time",
expected_close_date = "2026-06-30",
confidence = 60,
})
local updated = app.integrations.close.update_opportunity({
id = "oppo_example",
confidence = 75,
})
app.integrations.close.delete_opportunity({ id = "oppo_example" })
```
## Tasks
Close task list filters accept fields such as `lead_id`, `assigned_to`, `is_complete`, `_type`, date filters, `_limit`, and `_skip`. Use `_type = "all"` when you want system task types in addition to lead tasks.
```lua
local tasks = app.integrations.close.list_tasks({
lead_id = "lead_example",
assigned_to = "user_example",
is_complete = false,
_type = "all",
})
local created = app.integrations.close.create_task({
text = "Follow up with buyer",
lead_id = "lead_example",
assignee_id = "user_example",
date = "2026-05-15",
})
local task = app.integrations.close.get_task({ id = "task_example" })
local updated = app.integrations.close.update_task({
id = "task_example",
is_complete = true,
})
app.integrations.close.delete_task({ id = "task_example" })
```
## Activities And Notes
`list_activities` lists activity records across types. Note-specific tools map to `/activity/note/`.
```lua
local activities = app.integrations.close.list_activities({
lead_id = "lead_example",
type = "note",
limit = 25,
})
local notes = app.integrations.close.list_notes({
lead_id = "lead_example",
_limit = 25,
})
local note = app.integrations.close.create_note({
lead_id = "lead_example",
note = "Buyer asked for implementation timeline.",
})
local fetched = app.integrations.close.get_note({ id = "acti_example" })
local updated = app.integrations.close.update_note({
id = "acti_example",
note = "Updated implementation timeline note.",
})
app.integrations.close.delete_note({ id = "acti_example" })
```
## Users
```lua
local me = app.integrations.close.get_current_user({})
local users = app.integrations.close.list_users({
_limit = 50,
})
local user = app.integrations.close.get_user({ id = "user_example" })
local availability = app.integrations.close.list_user_availability({})
```
## Statuses And Pipelines
Lead statuses:
```lua
local statuses = app.integrations.close.list_lead_statuses({})
local created = app.integrations.close.create_lead_status({
label = "Qualified",
})
app.integrations.close.update_lead_status({
id = "stat_example",
label = "Qualified Inbound",
})
app.integrations.close.delete_lead_status({ id = "stat_example" })
```
Opportunity statuses:
```lua
local statuses = app.integrations.close.list_opportunity_statuses({})
local created = app.integrations.close.create_opportunity_status({
label = "Negotiation",
type = "active",
pipeline_id = "pipe_example",
})
app.integrations.close.update_opportunity_status({
id = "stat_example",
label = "Contracting",
})
app.integrations.close.delete_opportunity_status({ id = "stat_example" })
```
Pipelines:
```lua
local pipelines = app.integrations.close.list_pipelines({})
local pipeline = app.integrations.close.create_pipeline({
name = "Outbound Sales",
})
app.integrations.close.update_pipeline({
id = "pipe_example",
name = "Enterprise Sales",
})
app.integrations.close.delete_pipeline({ id = "pipe_example" })
```
## Multi-Account
Hosts can expose account-scoped namespaces. The functions are the same; only the resolved Close credentials differ.
```lua
app.integrations.close.default.list_leads({ query = "Acme" })
app.integrations.close.enterprise.list_opportunities({ _limit = 10 })
``` local result = app.integrations.close.list_leads({query = "example_query", limit = 1, skip = 1})
print(result) Functions
list_leads Read
Search and list leads in Close CRM. Use the query parameter with Close search syntax to filter leads by name, status, custom fields, dates, and more. Returns a paginated list of leads with their contacts and addresses.
- Lua path
app.integrations.close.list_leads- Full name
close.close_list_leads
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | no | Search query using Close syntax. Examples: "Acme", "status:Potential", "name:Acme AND status:Qualified". Omit to list all leads. |
limit | integer | no | Maximum number of leads to return (default: 25, max: 100). |
skip | integer | no | Number of records to skip for pagination. |
get_lead Read
Get full details for a single lead in Close CRM, including contacts, addresses, custom fields, and associated information.
- Lua path
app.integrations.close.get_lead- Full name
close.close_get_lead
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The lead ID (e.g., "lead_abc123XYZ"). |
create_lead Write
Create a new lead in Close CRM. Provide a company name and optionally add contacts with email addresses and phone numbers.
- Lua path
app.integrations.close.create_lead- Full name
close.close_create_lead
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Company or lead name. |
contacts | array | no | Array of contact objects. Each contact can have "name" (string), "emails" (array of objects with "email" and optional "type"), and "phones" (array of objects with "phone" and optional "type"). |
url | string | no | Company website URL. |
status_id | string | no | Status ID to assign (omit for default status). |
custom | object | no | Custom field values as an object (e.g., {"Industry": "SaaS"}). |
update_lead Write
Update an existing lead in Close CRM. Provide the lead ID and the fields to update (name, status, custom fields, URL, etc.).
- Lua path
app.integrations.close.update_lead- Full name
close.close_update_lead
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The lead ID to update (e.g., "lead_abc123XYZ"). |
name | string | no | New company or lead name. |
status_id | string | no | New status ID to assign. |
url | string | no | New company website URL. |
custom | object | no | Updated custom field values as an object (e.g., {"Industry": "SaaS"}). |
delete_lead Write
Permanently delete a lead from Close CRM. This removes the lead and all associated contacts, activities, and tasks.
- Lua path
app.integrations.close.delete_lead- Full name
close.close_delete_lead
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The lead ID to delete (e.g., "lead_abc123XYZ"). |
list_contacts Read
List contacts in Close CRM. Optionally filter by lead ID to get contacts for a specific lead. Supports pagination.
- Lua path
app.integrations.close.list_contacts- Full name
close.close_list_contacts
| Parameter | Type | Required | Description |
|---|---|---|---|
lead_id | string | no | Filter contacts by lead ID (e.g., "lead_abc123XYZ"). |
limit | integer | no | Maximum number of contacts to return (default: 25, max: 100). |
skip | integer | no | Number of records to skip for pagination. |
get_contact Read
Get a single contact.
- Lua path
app.integrations.close.get_contact- Full name
close.close_get_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_contact Write
Create a contact on a lead.
- Lua path
app.integrations.close.create_contact- Full name
close.close_create_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_contact Write
Update a contact.
- Lua path
app.integrations.close.update_contact- Full name
close.close_update_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_contact Write
Delete a contact.
- Lua path
app.integrations.close.delete_contact- Full name
close.close_delete_contact
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_opportunities Read
List or filter opportunities.
- Lua path
app.integrations.close.list_opportunities- Full name
close.close_list_opportunities
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_opportunity Read
Get a single opportunity.
- Lua path
app.integrations.close.get_opportunity- Full name
close.close_get_opportunity
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_opportunity Write
Create an opportunity.
- Lua path
app.integrations.close.create_opportunity- Full name
close.close_create_opportunity
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_opportunity Write
Update an opportunity.
- Lua path
app.integrations.close.update_opportunity- Full name
close.close_update_opportunity
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_opportunity Write
Delete an opportunity.
- Lua path
app.integrations.close.delete_opportunity- Full name
close.close_delete_opportunity
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_tasks Read
List or filter tasks.
- Lua path
app.integrations.close.list_tasks- Full name
close.close_list_tasks
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_task Write
Create a new task in Close CRM. Optionally associate it with a lead, assign it to a user, and set a due date.
- Lua path
app.integrations.close.create_task- Full name
close.close_create_task
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | yes | The task description or body text. |
lead_id | string | no | Associate this task with a lead (e.g., "lead_abc123XYZ"). |
assignee_id | string | no | User ID to assign the task to (e.g., "user_abc123XYZ"). |
date | string | no | Task date in YYYY-MM-DD format (e.g., "2026-04-15"). |
due_date | string | no | Deprecated alias for date, kept for older agents. |
is_complete | boolean | no | Whether the task is already completed (default: false). |
get_task Read
Get a single task.
- Lua path
app.integrations.close.get_task- Full name
close.close_get_task
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_task Write
Update a task.
- Lua path
app.integrations.close.update_task- Full name
close.close_update_task
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_task Write
Delete a task.
- Lua path
app.integrations.close.delete_task- Full name
close.close_delete_task
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_activities Read
List activities in Close CRM: emails, calls, notes, and other activity types. Filter by lead ID or activity type. Supports pagination.
- Lua path
app.integrations.close.list_activities- Full name
close.close_list_activities
| Parameter | Type | Required | Description |
|---|---|---|---|
lead_id | string | no | Filter activities by lead ID (e.g., "lead_abc123XYZ"). |
type | string | no | Activity type filter. Common values: "email", "call", "note", "sms", "meeting". |
limit | integer | no | Maximum number of activities to return (default: 25, max: 100). |
skip | integer | no | Number of records to skip for pagination. |
list_notes Read
List note activities.
- Lua path
app.integrations.close.list_notes- Full name
close.close_list_notes
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_note Read
Get a note activity.
- Lua path
app.integrations.close.get_note- Full name
close.close_get_note
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_note Write
Create a note activity.
- Lua path
app.integrations.close.create_note- Full name
close.close_create_note
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_note Write
Update a note activity.
- Lua path
app.integrations.close.update_note- Full name
close.close_update_note
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_note Write
Delete a note activity.
- Lua path
app.integrations.close.delete_note- Full name
close.close_delete_note
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_current_user Read
Get the profile of the currently authenticated Close CRM user: name, email, organization, and other account details.
- Lua path
app.integrations.close.get_current_user- Full name
close.close_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_users Read
List users in the organization.
- Lua path
app.integrations.close.list_users- Full name
close.close_list_users
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_user Read
Get a single user.
- Lua path
app.integrations.close.get_user- Full name
close.close_get_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_user_availability Read
List user availability statuses.
- Lua path
app.integrations.close.list_user_availability- Full name
close.close_list_user_availability
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_lead_statuses Read
List configured lead statuses.
- Lua path
app.integrations.close.list_lead_statuses- Full name
close.close_list_lead_statuses
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_lead_status Write
Create a lead status.
- Lua path
app.integrations.close.create_lead_status- Full name
close.close_create_lead_status
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_lead_status Write
Rename a lead status.
- Lua path
app.integrations.close.update_lead_status- Full name
close.close_update_lead_status
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_lead_status Write
Delete a lead status.
- Lua path
app.integrations.close.delete_lead_status- Full name
close.close_delete_lead_status
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_opportunity_statuses Read
List configured opportunity statuses.
- Lua path
app.integrations.close.list_opportunity_statuses- Full name
close.close_list_opportunity_statuses
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_opportunity_status Write
Create an opportunity status.
- Lua path
app.integrations.close.create_opportunity_status- Full name
close.close_create_opportunity_status
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_opportunity_status Write
Update an opportunity status.
- Lua path
app.integrations.close.update_opportunity_status- Full name
close.close_update_opportunity_status
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_opportunity_status Write
Delete an opportunity status.
- Lua path
app.integrations.close.delete_opportunity_status- Full name
close.close_delete_opportunity_status
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_pipelines Read
List configured pipelines.
- Lua path
app.integrations.close.list_pipelines- Full name
close.close_list_pipelines
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_pipeline Write
Create a pipeline.
- Lua path
app.integrations.close.create_pipeline- Full name
close.close_create_pipeline
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
update_pipeline Write
Update a pipeline.
- Lua path
app.integrations.close.update_pipeline- Full name
close.close_update_pipeline
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_pipeline Write
Delete a pipeline.
- Lua path
app.integrations.close.delete_pipeline- Full name
close.close_delete_pipeline
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||