KosmoKrator

sales

Keap Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write Bearer token auth

Lua Namespace

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

Keap CRM — Lua API Reference

list_contacts

List contacts from Keap CRM with pagination.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
limitintegernoResults per page (default: 20, max: 200)

Example

local result = app.integrations.keap.list_contacts({
  page = 1,
  limit = 20
})

for _, contact in ipairs(result.contacts) do
  print(contact.given_name .. " " .. contact.family_name)
end

get_contact

Retrieve a single contact by ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe Keap contact ID

Example

local result = app.integrations.keap.get_contact({ id = 12345 })
print(result.given_name .. " " .. result.family_name)

create_contact

Create a new contact in Keap CRM.

Parameters

NameTypeRequiredDescription
first_namestringnoFirst name
last_namestringnoLast name
emailstringnoPrimary email address
company_namestringnoCompany name

At least one field is required.

Example

local result = app.integrations.keap.create_contact({
  first_name = "Jane",
  last_name = "Doe",
  email = "[email protected]",
  company_name = "Acme Corp"
})
print("Created contact ID: " .. result.id)

list_opportunities

List sales opportunities with optional stage filter.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
limitintegernoResults per page (default: 20, max: 200)
stagestringnoFilter by stage (e.g., “New”, “Appointment Scheduled”, “Closed Won”, “Closed Lost”)

Example

local result = app.integrations.keap.list_opportunities({
  page = 1,
  limit = 20,
  stage = "New"
})

for _, opp in ipairs(result.opportunities) do
  print(opp.title .. " — $" .. opp.value)
end

get_opportunity

Retrieve a single opportunity by ID.

Parameters

NameTypeRequiredDescription
idintegeryesThe Keap opportunity ID

Example

local result = app.integrations.keap.get_opportunity({ id = 67890 })
print(result.title .. " — Stage: " .. result.stage)

list_tags

List all tags in Keap.

Parameters

None.

Example

local result = app.integrations.keap.list_tags()

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

get_current_user

Get the currently authenticated Keap user.

Parameters

None.

Example

local result = app.integrations.keap.get_current_user()
print("Connected as: " .. result.first_name .. " " .. result.last_name)

Multi-Account Usage

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

-- Default account (always works)
app.integrations.keap.list_contacts({ page = 1 })

-- Explicit default (portable across setups)
app.integrations.keap.default.list_contacts({ page = 1 })

-- Named accounts
app.integrations.keap.production.list_contacts({ page = 1 })
app.integrations.keap.staging.list_contacts({ page = 1 })

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

Raw agent markdown
# Keap CRM — Lua API Reference

## list_contacts

List contacts from Keap CRM with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `limit` | integer | no | Results per page (default: 20, max: 200) |

### Example

```lua
local result = app.integrations.keap.list_contacts({
  page = 1,
  limit = 20
})

for _, contact in ipairs(result.contacts) do
  print(contact.given_name .. " " .. contact.family_name)
end
```

---

## get_contact

Retrieve a single contact by ID.

### Parameters

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

### Example

```lua
local result = app.integrations.keap.get_contact({ id = 12345 })
print(result.given_name .. " " .. result.family_name)
```

---

## create_contact

Create a new contact in Keap CRM.

### Parameters

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

At least one field is required.

### Example

```lua
local result = app.integrations.keap.create_contact({
  first_name = "Jane",
  last_name = "Doe",
  email = "[email protected]",
  company_name = "Acme Corp"
})
print("Created contact ID: " .. result.id)
```

---

## list_opportunities

List sales opportunities with optional stage filter.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `limit` | integer | no | Results per page (default: 20, max: 200) |
| `stage` | string | no | Filter by stage (e.g., "New", "Appointment Scheduled", "Closed Won", "Closed Lost") |

### Example

```lua
local result = app.integrations.keap.list_opportunities({
  page = 1,
  limit = 20,
  stage = "New"
})

for _, opp in ipairs(result.opportunities) do
  print(opp.title .. " — $" .. opp.value)
end
```

---

## get_opportunity

Retrieve a single opportunity by ID.

### Parameters

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

### Example

```lua
local result = app.integrations.keap.get_opportunity({ id = 67890 })
print(result.title .. " — Stage: " .. result.stage)
```

---

## list_tags

List all tags in Keap.

### Parameters

None.

### Example

```lua
local result = app.integrations.keap.list_tags()

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

---

## get_current_user

Get the currently authenticated Keap user.

### Parameters

None.

### Example

```lua
local result = app.integrations.keap.get_current_user()
print("Connected as: " .. result.first_name .. " " .. result.last_name)
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.keap.list_contacts({ page = 1 })

-- Explicit default (portable across setups)
app.integrations.keap.default.list_contacts({ page = 1 })

-- Named accounts
app.integrations.keap.production.list_contacts({ page = 1 })
app.integrations.keap.staging.list_contacts({ page = 1 })
```

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

Metadata-Derived Lua Example

local result = app.integrations.keap.keap_list_contacts({
  page = 1,
  limit = 1
})
print(result)

Functions

keap_list_contacts

List contacts from Keap CRM. Returns paginated results with contact details including name, email, and company.

Operation
Read read
Full name
keap.keap_list_contacts
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
limit integer no Number of contacts per page (default: 20, max: 200).

keap_get_contact

Retrieve a single Keap contact by ID. Returns full contact details including email addresses, phone numbers, and tags.

Operation
Read read
Full name
keap.keap_get_contact
ParameterTypeRequiredDescription
id integer yes The Keap contact ID.

keap_create_contact

Create a new contact in Keap CRM. Provide at least a first name or last name. Email and company name are optional.

Operation
Write write
Full name
keap.keap_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 for the contact.
company_name string no Company name to associate with the contact.

keap_list_opportunities

List sales opportunities from Keap CRM. Optionally filter by pipeline stage. Returns paginated results with opportunity details.

Operation
Read read
Full name
keap.keap_list_opportunities
ParameterTypeRequiredDescription
page integer no Page number for pagination (default: 1).
limit integer no Number of opportunities per page (default: 20, max: 200).
stage string no Filter by opportunity stage (e.g., "New", "Appointment Scheduled", "Closed Won", "Closed Lost").

keap_get_opportunity

Retrieve a single Keap sales opportunity by ID. Returns full details including contact, stage, value, and notes.

Operation
Read read
Full name
keap.keap_get_opportunity
ParameterTypeRequiredDescription
id integer yes The Keap opportunity ID.

keap_list_tags

List all tags in Keap. Tags are used to categorize contacts and trigger automations.

Operation
Read read
Full name
keap.keap_list_tags
ParameterTypeRequiredDescription
No parameters.

keap_get_current_user

Get the currently authenticated Keap user. Returns profile information for the user associated with the access token.

Operation
Read read
Full name
keap.keap_get_current_user
ParameterTypeRequiredDescription
No parameters.