KosmoKrator

sales

Insightly CRM Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.insightly.*. Use lua_read_doc("integrations.insightly") 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.

Insightly CRM — Lua API Reference

list_contacts

List contacts from Insightly CRM.

Parameters

NameTypeRequiredDescription
topintegernoMaximum number of contacts to return
skipintegernoNumber of contacts to skip for pagination
searchstringnoSearch term to filter contacts by name or email

Example

local result = app.integrations.insightly.list_contacts({
  top = 20,
  search = "John"
})

for _, contact in ipairs(result.contacts) do
  print(contact.FIRST_NAME .. " " .. contact.LAST_NAME .. " - " .. (contact.EMAIL_ADDRESS or "no email"))
end

get_contact

Get a single contact by ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe Insightly contact ID

Example

local result = app.integrations.insightly.get_contact({ id = 12345 })
print(result.FIRST_NAME .. " " .. result.LAST_NAME)
print("Email: " .. (result.EMAIL_ADDRESS or "N/A"))
print("Title: " .. (result.TITLE or "N/A"))

create_contact

Create a new contact in Insightly.

Parameters

NameTypeRequiredDescription
first_namestringnoFirst name
last_namestringnoLast name
emailstringnoPrimary email address
phonestringnoPrimary phone number

Example

local result = app.integrations.insightly.create_contact({
  first_name = "Jane",
  last_name = "Smith",
  email = "[email protected]",
  phone = "+1-555-0100"
})

print("Created contact ID: " .. result.CONTACT_ID)

list_opportunities

List opportunities from Insightly CRM.

Parameters

NameTypeRequiredDescription
topintegernoMaximum number of opportunities to return
skipintegernoNumber of opportunities to skip for pagination
statusstringnoFilter by status (e.g., “Open”, “Won”, “Lost”, “Suspended”)

Example

local result = app.integrations.insightly.list_opportunities({
  top = 10,
  status = "Open"
})

for _, opp in ipairs(result.opportunities) do
  print(opp.OPPORTUNITY_NAME .. " - $" .. (opp.BID_AMOUNT or 0))
end

get_opportunity

Get a single opportunity by ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe Insightly opportunity ID

Example

local result = app.integrations.insightly.get_opportunity({ id = 67890 })
print(result.OPPORTUNITY_NAME)
print("Amount: $" .. (result.BID_AMOUNT or 0))
print("Stage: " .. (result.PIPELINE_NAME or "N/A"))

list_projects

List projects from Insightly CRM.

Parameters

NameTypeRequiredDescription
topintegernoMaximum number of projects to return
skipintegernoNumber of projects to skip for pagination
statusstringnoFilter by status (e.g., “In Progress”, “Completed”, “Scheduled”)

Example

local result = app.integrations.insightly.list_projects({
  top = 15,
  status = "In Progress"
})

for _, project in ipairs(result.projects) do
  print(project.PROJECT_NAME .. " - " .. project.STATUS)
end

get_current_user

Get the profile of the currently authenticated Insightly user.

Parameters

None.

Example

local result = app.integrations.insightly.get_current_user({})
print("User: " .. result.FIRST_NAME .. " " .. result.LAST_NAME)
print("Email: " .. (result.EMAIL or "N/A"))

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.insightly.production.function_name({...})
app.integrations.insightly.staging.function_name({...})

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

Raw agent markdown
# Insightly CRM — Lua API Reference

## list_contacts

List contacts from Insightly CRM.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Maximum number of contacts to return |
| `skip` | integer | no | Number of contacts to skip for pagination |
| `search` | string | no | Search term to filter contacts by name or email |

### Example

```lua
local result = app.integrations.insightly.list_contacts({
  top = 20,
  search = "John"
})

for _, contact in ipairs(result.contacts) do
  print(contact.FIRST_NAME .. " " .. contact.LAST_NAME .. " - " .. (contact.EMAIL_ADDRESS or "no email"))
end
```

---

## get_contact

Get a single contact by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The Insightly contact ID |

### Example

```lua
local result = app.integrations.insightly.get_contact({ id = 12345 })
print(result.FIRST_NAME .. " " .. result.LAST_NAME)
print("Email: " .. (result.EMAIL_ADDRESS or "N/A"))
print("Title: " .. (result.TITLE or "N/A"))
```

---

## create_contact

Create a new contact in Insightly.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `first_name` | string | no | First name |
| `last_name` | string | no | Last name |
| `email` | string | no | Primary email address |
| `phone` | string | no | Primary phone number |

### Example

```lua
local result = app.integrations.insightly.create_contact({
  first_name = "Jane",
  last_name = "Smith",
  email = "[email protected]",
  phone = "+1-555-0100"
})

print("Created contact ID: " .. result.CONTACT_ID)
```

---

## list_opportunities

List opportunities from Insightly CRM.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Maximum number of opportunities to return |
| `skip` | integer | no | Number of opportunities to skip for pagination |
| `status` | string | no | Filter by status (e.g., "Open", "Won", "Lost", "Suspended") |

### Example

```lua
local result = app.integrations.insightly.list_opportunities({
  top = 10,
  status = "Open"
})

for _, opp in ipairs(result.opportunities) do
  print(opp.OPPORTUNITY_NAME .. " - $" .. (opp.BID_AMOUNT or 0))
end
```

---

## get_opportunity

Get a single opportunity by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The Insightly opportunity ID |

### Example

```lua
local result = app.integrations.insightly.get_opportunity({ id = 67890 })
print(result.OPPORTUNITY_NAME)
print("Amount: $" .. (result.BID_AMOUNT or 0))
print("Stage: " .. (result.PIPELINE_NAME or "N/A"))
```

---

## list_projects

List projects from Insightly CRM.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `top` | integer | no | Maximum number of projects to return |
| `skip` | integer | no | Number of projects to skip for pagination |
| `status` | string | no | Filter by status (e.g., "In Progress", "Completed", "Scheduled") |

### Example

```lua
local result = app.integrations.insightly.list_projects({
  top = 15,
  status = "In Progress"
})

for _, project in ipairs(result.projects) do
  print(project.PROJECT_NAME .. " - " .. project.STATUS)
end
```

---

## get_current_user

Get the profile of the currently authenticated Insightly user.

### Parameters

None.

### Example

```lua
local result = app.integrations.insightly.get_current_user({})
print("User: " .. result.FIRST_NAME .. " " .. result.LAST_NAME)
print("Email: " .. (result.EMAIL or "N/A"))
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.insightly.production.function_name({...})
app.integrations.insightly.staging.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.insightly.insightly_list_contacts({
  top = 1,
  skip = 1,
  search = "example_search"
})
print(result)

Functions

insightly_list_contacts

List contacts from Insightly CRM. Returns contact records with names, emails, phones, and organization info. Use top/skip for pagination and search to filter by name or email.

Operation
Read read
Full name
insightly.insightly_list_contacts
ParameterTypeRequiredDescription
top integer no Maximum number of contacts to return.
skip integer no Number of contacts to skip for pagination.
search string no Search term to filter contacts by name or email.

insightly_get_contact

Get detailed information about a single Insightly contact by ID. Returns all contact fields including addresses, emails, phones, and linked organizations.

Operation
Read read
Full name
insightly.insightly_get_contact
ParameterTypeRequiredDescription
id integer yes The Insightly contact ID.

insightly_create_contact

Create a new contact in Insightly CRM. Provide contact details such as first name, last name, email, and phone. Returns the created contact with its new ID.

Operation
Write write
Full name
insightly.insightly_create_contact
ParameterTypeRequiredDescription
first_name string no First name of the contact.
last_name string no Last name of the contact.
email string no Primary email address.
phone string no Primary phone number.

insightly_list_opportunities

List opportunities from Insightly CRM. Returns opportunity records with names, amounts, stages, and pipeline info. Use top/skip for pagination and status to filter by opportunity state.

Operation
Read read
Full name
insightly.insightly_list_opportunities
ParameterTypeRequiredDescription
top integer no Maximum number of opportunities to return.
skip integer no Number of opportunities to skip for pagination.
status string no Filter by opportunity status (e.g., "Open", "Won", "Lost", "Suspended").

insightly_get_opportunity

Get detailed information about a single Insightly opportunity by ID. Returns all opportunity fields including amount, stage, pipeline, and linked contacts.

Operation
Read read
Full name
insightly.insightly_get_opportunity
ParameterTypeRequiredDescription
id integer yes The Insightly opportunity ID.

insightly_list_projects

List projects from Insightly CRM. Returns project records with names, statuses, dates, and linked records. Use top/skip for pagination and status to filter by project state.

Operation
Read read
Full name
insightly.insightly_list_projects
ParameterTypeRequiredDescription
top integer no Maximum number of projects to return.
skip integer no Number of projects to skip for pagination.
status string no Filter by project status (e.g., "In Progress", "Completed", "Scheduled").

insightly_get_current_user

Get the profile of the currently authenticated Insightly user. Returns user name, email, account info, and timezone settings. Useful for verifying API connectivity.

Operation
Read read
Full name
insightly.insightly_get_current_user
ParameterTypeRequiredDescription
No parameters.