KosmoKrator

crm

Close CRM Lua API for KosmoKrator Agents

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

9 functions 5 read 4 write API key auth

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.

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

list_leads

Search and list leads in Close CRM. Supports Close’s powerful search syntax for filtering.

Parameters

NameTypeRequiredDescription
querystringnoSearch query using Close syntax (e.g., "Acme", "status:Potential")
limitintegernoMax results (default: 25, max: 100)
skipintegernoRecords to skip for pagination

Search Syntax Examples

  • "Acme" — search all fields for “Acme”
  • "name:Acme" — search lead name only
  • "status:Potential" — filter by status name
  • "name:Acme AND status:Qualified" — combine conditions
  • "custom.Industry:SaaS" — filter by custom field
  • "created_at>=2026-01-01" — date range filter

Example

local result = app.integrations.close.list_leads({
  query = "Acme",
  limit = 10
})

for _, lead in ipairs(result.leads) do
  print(lead.id .. ": " .. lead.name)
end

get_lead

Get full details for a single lead by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe lead ID (e.g., "lead_abc123XYZ")

Example

local lead = app.integrations.close.get_lead({
  id = "lead_abc123XYZ"
})

print(lead.name)
for _, contact in ipairs(lead.contacts) do
  print("  Contact: " .. contact.display_name)
end

create_lead

Create a new lead with optional contacts.

Parameters

NameTypeRequiredDescription
namestringyesCompany or lead name
contactsarraynoArray of contact objects
urlstringnoCompany website URL
status_idstringnoStatus ID to assign
customobjectnoCustom field values

Contact Object

{
  name = "John Doe",
  emails = {
    { email = "[email protected]", type = "office" }
  },
  phones = {
    { phone = "+1234567890", type = "office" }
  }
}

Example

local lead = app.integrations.close.create_lead({
  name = "Acme Corp",
  contacts = {
    {
      name = "Jane Smith",
      emails = {
        { email = "[email protected]", type = "office" }
      },
      phones = {
        { phone = "+1234567890", type = "office" }
      }
    }
  },
  url = "https://acme.com"
})

print("Created lead: " .. lead.id)

update_lead

Update fields on an existing lead.

Parameters

NameTypeRequiredDescription
idstringyesThe lead ID to update
namestringnoNew company or lead name
status_idstringnoNew status ID
urlstringnoNew company website URL
customobjectnoUpdated custom field values

Example

local lead = app.integrations.close.update_lead({
  id = "lead_abc123XYZ",
  name = "Acme Corp (Updated)",
  custom = { Industry = "SaaS" }
})

print("Updated: " .. lead.name)

delete_lead

Permanently delete a lead and all its associated data.

Parameters

NameTypeRequiredDescription
idstringyesThe lead ID to delete

Example

app.integrations.close.delete_lead({
  id = "lead_abc123XYZ"
})

list_contacts

List contacts, optionally filtered by lead.

Parameters

NameTypeRequiredDescription
lead_idstringnoFilter contacts by lead ID
limitintegernoMax results (default: 25, max: 100)
skipintegernoRecords to skip for pagination

Example

local result = app.integrations.close.list_contacts({
  lead_id = "lead_abc123XYZ",
  limit = 50
})

for _, contact in ipairs(result.contacts) do
  print(contact.display_name)
end

list_activities

List activities (emails, calls, notes, etc.) with optional filters.

Parameters

NameTypeRequiredDescription
lead_idstringnoFilter by lead ID
typestringnoActivity type: "email", "call", "note", "sms", "meeting"
limitintegernoMax results (default: 25, max: 100)
skipintegernoRecords to skip for pagination

Example

local result = app.integrations.close.list_activities({
  lead_id = "lead_abc123XYZ",
  type = "email",
  limit = 10
})

for _, activity in ipairs(result.activities) do
  print(activity.type .. ": " .. (activity.subject or activity.body_preview or ""))
end

create_task

Create a new task, optionally linked to a lead.

Parameters

NameTypeRequiredDescription
textstringyesTask description
lead_idstringnoAssociate with a lead
assignee_idstringnoUser ID to assign to
due_datestringnoDue date (ISO 8601, e.g., "2026-04-15")
is_completebooleannoWhether already complete (default: false)

Example

local task = app.integrations.close.create_task({
  text = "Follow up with prospect",
  lead_id = "lead_abc123XYZ",
  due_date = "2026-04-15"
})

print("Created task: " .. task.id)

get_current_user

Get the authenticated user’s profile.

Parameters

None.

Example

local user = app.integrations.close.get_current_user({})

print("Logged in as: " .. user.first_name .. " " .. user.last_name)
print("Email: " .. user.email)

for _, org in ipairs(user.organizations or {}) do
  print("Organization: " .. org.name)
end

Multi-Account Usage

If you have multiple Close accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.close.function_name({...})

-- Explicit default (portable across setups)
app.integrations.close.default.function_name({...})

-- Named accounts
app.integrations.close.us_team.function_name({...})
app.integrations.close.eu_team.function_name({...})

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

Raw agent markdown
# Close CRM — Lua API Reference

## list_leads

Search and list leads in Close CRM. Supports Close's powerful search syntax for filtering.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `query` | string | no | Search query using Close syntax (e.g., `"Acme"`, `"status:Potential"`) |
| `limit` | integer | no | Max results (default: 25, max: 100) |
| `skip` | integer | no | Records to skip for pagination |

### Search Syntax Examples

- `"Acme"` — search all fields for "Acme"
- `"name:Acme"` — search lead name only
- `"status:Potential"` — filter by status name
- `"name:Acme AND status:Qualified"` — combine conditions
- `"custom.Industry:SaaS"` — filter by custom field
- `"created_at>=2026-01-01"` — date range filter

### Example

```lua
local result = app.integrations.close.list_leads({
  query = "Acme",
  limit = 10
})

for _, lead in ipairs(result.leads) do
  print(lead.id .. ": " .. lead.name)
end
```

---

## get_lead

Get full details for a single lead by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The lead ID (e.g., `"lead_abc123XYZ"`) |

### Example

```lua
local lead = app.integrations.close.get_lead({
  id = "lead_abc123XYZ"
})

print(lead.name)
for _, contact in ipairs(lead.contacts) do
  print("  Contact: " .. contact.display_name)
end
```

---

## create_lead

Create a new lead with optional contacts.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Company or lead name |
| `contacts` | array | no | Array of contact objects |
| `url` | string | no | Company website URL |
| `status_id` | string | no | Status ID to assign |
| `custom` | object | no | Custom field values |

### Contact Object

```lua
{
  name = "John Doe",
  emails = {
    { email = "[email protected]", type = "office" }
  },
  phones = {
    { phone = "+1234567890", type = "office" }
  }
}
```

### Example

```lua
local lead = app.integrations.close.create_lead({
  name = "Acme Corp",
  contacts = {
    {
      name = "Jane Smith",
      emails = {
        { email = "[email protected]", type = "office" }
      },
      phones = {
        { phone = "+1234567890", type = "office" }
      }
    }
  },
  url = "https://acme.com"
})

print("Created lead: " .. lead.id)
```

---

## update_lead

Update fields on an existing lead.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The lead ID to update |
| `name` | string | no | New company or lead name |
| `status_id` | string | no | New status ID |
| `url` | string | no | New company website URL |
| `custom` | object | no | Updated custom field values |

### Example

```lua
local lead = app.integrations.close.update_lead({
  id = "lead_abc123XYZ",
  name = "Acme Corp (Updated)",
  custom = { Industry = "SaaS" }
})

print("Updated: " .. lead.name)
```

---

## delete_lead

Permanently delete a lead and all its associated data.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The lead ID to delete |

### Example

```lua
app.integrations.close.delete_lead({
  id = "lead_abc123XYZ"
})
```

---

## list_contacts

List contacts, optionally filtered by lead.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `lead_id` | string | no | Filter contacts by lead ID |
| `limit` | integer | no | Max results (default: 25, max: 100) |
| `skip` | integer | no | Records to skip for pagination |

### Example

```lua
local result = app.integrations.close.list_contacts({
  lead_id = "lead_abc123XYZ",
  limit = 50
})

for _, contact in ipairs(result.contacts) do
  print(contact.display_name)
end
```

---

## list_activities

List activities (emails, calls, notes, etc.) with optional filters.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `lead_id` | string | no | Filter by lead ID |
| `type` | string | no | Activity type: `"email"`, `"call"`, `"note"`, `"sms"`, `"meeting"` |
| `limit` | integer | no | Max results (default: 25, max: 100) |
| `skip` | integer | no | Records to skip for pagination |

### Example

```lua
local result = app.integrations.close.list_activities({
  lead_id = "lead_abc123XYZ",
  type = "email",
  limit = 10
})

for _, activity in ipairs(result.activities) do
  print(activity.type .. ": " .. (activity.subject or activity.body_preview or ""))
end
```

---

## create_task

Create a new task, optionally linked to a lead.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `text` | string | yes | Task description |
| `lead_id` | string | no | Associate with a lead |
| `assignee_id` | string | no | User ID to assign to |
| `due_date` | string | no | Due date (ISO 8601, e.g., `"2026-04-15"`) |
| `is_complete` | boolean | no | Whether already complete (default: `false`) |

### Example

```lua
local task = app.integrations.close.create_task({
  text = "Follow up with prospect",
  lead_id = "lead_abc123XYZ",
  due_date = "2026-04-15"
})

print("Created task: " .. task.id)
```

---

## get_current_user

Get the authenticated user's profile.

### Parameters

None.

### Example

```lua
local user = app.integrations.close.get_current_user({})

print("Logged in as: " .. user.first_name .. " " .. user.last_name)
print("Email: " .. user.email)

for _, org in ipairs(user.organizations or {}) do
  print("Organization: " .. org.name)
end
```

---

## Multi-Account Usage

If you have multiple Close accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.close.function_name({...})

-- Explicit default (portable across setups)
app.integrations.close.default.function_name({...})

-- Named accounts
app.integrations.close.us_team.function_name({...})
app.integrations.close.eu_team.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.close.close_list_leads({
  query = "example_query",
  limit = 1,
  skip = 1
})
print(result)

Functions

close_list_leads

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.

Operation
Read read
Full name
close.close_list_leads
ParameterTypeRequiredDescription
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.

close_get_lead

Get full details for a single lead in Close CRM, including contacts, addresses, custom fields, and associated information.

Operation
Read read
Full name
close.close_get_lead
ParameterTypeRequiredDescription
id string yes The lead ID (e.g., "lead_abc123XYZ").

close_create_lead

Create a new lead in Close CRM. Provide a company name and optionally add contacts with email addresses and phone numbers.

Operation
Write write
Full name
close.close_create_lead
ParameterTypeRequiredDescription
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"}).

close_update_lead

Update an existing lead in Close CRM. Provide the lead ID and the fields to update (name, status, custom fields, URL, etc.).

Operation
Write write
Full name
close.close_update_lead
ParameterTypeRequiredDescription
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"}).

close_delete_lead

Permanently delete a lead from Close CRM. This removes the lead and all associated contacts, activities, and tasks.

Operation
Write write
Full name
close.close_delete_lead
ParameterTypeRequiredDescription
id string yes The lead ID to delete (e.g., "lead_abc123XYZ").

close_list_contacts

List contacts in Close CRM. Optionally filter by lead ID to get contacts for a specific lead. Supports pagination.

Operation
Read read
Full name
close.close_list_contacts
ParameterTypeRequiredDescription
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.

close_list_activities

List activities in Close CRM — emails, calls, notes, and other activity types. Filter by lead ID or activity type. Supports pagination.

Operation
Read read
Full name
close.close_list_activities
ParameterTypeRequiredDescription
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.

close_create_task

Create a new task in Close CRM. Optionally associate it with a lead, assign it to a user, and set a due date.

Operation
Write write
Full name
close.close_create_task
ParameterTypeRequiredDescription
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").
due_date string no Due date in ISO 8601 format (e.g., "2026-04-15").
is_complete boolean no Whether the task is already completed (default: false).

close_get_current_user

Get the profile of the currently authenticated Close CRM user — name, email, organization, and other account details.

Operation
Read read
Full name
close.close_get_current_user
ParameterTypeRequiredDescription
No parameters.