KosmoKrator

no-code

Bubble Lua API for KosmoKrator Agents

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

5 functions 2 read 3 write API key auth

Lua Namespace

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

Bubble — Lua API Reference

list_records

List records from a Bubble data type with optional filtering and pagination.

Parameters

NameTypeRequiredDescription
typestringyesBubble data type name (case-sensitive), e.g. "User", "Product"
constraintsstringnoJSON-encoded array of constraint objects for filtering
limitintegernoMax records to return (1–100, default: 100)
cursorintegernoOffset for pagination (0-based)

Constraint Format

Each constraint is an object with three fields:

[
  {"key": "field_name", "constraint_type": "equals", "value": "some_value"},
  {"key": "age", "constraint_type": "greater than", "value": 18}
]

Constraint Types

TypeDescription
equalsExact match
not equalDoes not match
containsString contains substring
not containsString does not contain
is emptyField is empty (no value needed)
is not emptyField has a value (no value needed)
greater thanNumeric greater than
less thanNumeric less than
greater than or equalNumeric ≥
less than or equalNumeric ≤
begins withString starts with
ends withString ends with

Response

{
  "response": [
    {"_id": "abc123", "name": "John", "email": "[email protected]"}
  ],
  "remaining": 42
}

remaining is the count of additional records available after this page.

Examples

List all users

local result = app.integrations.bubble.list_records({
  type = "User"
})

for _, record in ipairs(result.response) do
  print(record.name .. " <" .. record.email .. ">")
end

Filter users by email domain

local result = app.integrations.bubble.list_records({
  type = "User",
  constraints = '[{"key": "email", "constraint_type": "contains", "value": "@company.com"}]'
})

for _, record in ipairs(result.response) do
  print(record.name)
end

Paginate through records

local page_size = 50
local cursor = 0
local all_records = {}

repeat
  local result = app.integrations.bubble.list_records({
    type = "Product",
    limit = page_size,
    cursor = cursor
  })

  for _, record in ipairs(result.response) do
    table.insert(all_records, record)
  end

  cursor = cursor + page_size
until result.remaining == 0

get_record

Get a single record by its unique Bubble ID.

Parameters

NameTypeRequiredDescription
typestringyesBubble data type name
idstringyesThe unique identifier (UUID) of the record

Example

local record = app.integrations.bubble.get_record({
  type = "User",
  id = "1704982345123x456789"
})

print("Name: " .. record.name)
print("Email: " .. record.email)
print("Created: " .. record["Created Date"])

create_record

Create a new record in a Bubble data type.

Parameters

NameTypeRequiredDescription
typestringyesBubble data type name
fieldsstringyesJSON object of field names and values

Example

local result = app.integrations.bubble.create_record({
  type = "User",
  fields = '{"name": "Jane Doe", "email": "[email protected]", "role": "admin"}'
})

print("Created record with ID: " .. result.id)

update_record

Update an existing record. Only the provided fields are changed.

Parameters

NameTypeRequiredDescription
typestringyesBubble data type name
idstringyesThe unique identifier of the record
fieldsstringyesJSON object of field names and values to update

Example

local result = app.integrations.bubble.update_record({
  type = "User",
  id = "1704982345123x456789",
  fields = '{"name": "Jane Smith", "role": "editor"}'
})

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

delete_record

Delete a record permanently by its unique ID.

Parameters

NameTypeRequiredDescription
typestringyesBubble data type name
idstringyesThe unique identifier of the record

Example

app.integrations.bubble.delete_record({
  type = "User",
  id = "1704982345123x456789"
})

Multi-Account Usage

If you have multiple Bubble apps configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.bubble.list_records({ type = "User" })

-- Explicit default (portable across setups)
app.integrations.bubble.default.list_records({ type = "User" })

-- Named accounts
app.integrations.bubble.main_app.list_records({ type = "User" })
app.integrations.bubble.staging.list_records({ type = "User" })

All functions are identical across accounts — only the credentials (API key and hostname) differ.

Raw agent markdown
# Bubble — Lua API Reference

## list_records

List records from a Bubble data type with optional filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Bubble data type name (case-sensitive), e.g. `"User"`, `"Product"` |
| `constraints` | string | no | JSON-encoded array of constraint objects for filtering |
| `limit` | integer | no | Max records to return (1–100, default: 100) |
| `cursor` | integer | no | Offset for pagination (0-based) |

### Constraint Format

Each constraint is an object with three fields:

```json
[
  {"key": "field_name", "constraint_type": "equals", "value": "some_value"},
  {"key": "age", "constraint_type": "greater than", "value": 18}
]
```

### Constraint Types

| Type | Description |
|------|-------------|
| `equals` | Exact match |
| `not equal` | Does not match |
| `contains` | String contains substring |
| `not contains` | String does not contain |
| `is empty` | Field is empty (no value needed) |
| `is not empty` | Field has a value (no value needed) |
| `greater than` | Numeric greater than |
| `less than` | Numeric less than |
| `greater than or equal` | Numeric ≥ |
| `less than or equal` | Numeric ≤ |
| `begins with` | String starts with |
| `ends with` | String ends with |

### Response

```json
{
  "response": [
    {"_id": "abc123", "name": "John", "email": "[email protected]"}
  ],
  "remaining": 42
}
```

`remaining` is the count of additional records available after this page.

### Examples

#### List all users

```lua
local result = app.integrations.bubble.list_records({
  type = "User"
})

for _, record in ipairs(result.response) do
  print(record.name .. " <" .. record.email .. ">")
end
```

#### Filter users by email domain

```lua
local result = app.integrations.bubble.list_records({
  type = "User",
  constraints = '[{"key": "email", "constraint_type": "contains", "value": "@company.com"}]'
})

for _, record in ipairs(result.response) do
  print(record.name)
end
```

#### Paginate through records

```lua
local page_size = 50
local cursor = 0
local all_records = {}

repeat
  local result = app.integrations.bubble.list_records({
    type = "Product",
    limit = page_size,
    cursor = cursor
  })

  for _, record in ipairs(result.response) do
    table.insert(all_records, record)
  end

  cursor = cursor + page_size
until result.remaining == 0
```

---

## get_record

Get a single record by its unique Bubble ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Bubble data type name |
| `id` | string | yes | The unique identifier (UUID) of the record |

### Example

```lua
local record = app.integrations.bubble.get_record({
  type = "User",
  id = "1704982345123x456789"
})

print("Name: " .. record.name)
print("Email: " .. record.email)
print("Created: " .. record["Created Date"])
```

---

## create_record

Create a new record in a Bubble data type.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Bubble data type name |
| `fields` | string | yes | JSON object of field names and values |

### Example

```lua
local result = app.integrations.bubble.create_record({
  type = "User",
  fields = '{"name": "Jane Doe", "email": "[email protected]", "role": "admin"}'
})

print("Created record with ID: " .. result.id)
```

---

## update_record

Update an existing record. Only the provided fields are changed.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Bubble data type name |
| `id` | string | yes | The unique identifier of the record |
| `fields` | string | yes | JSON object of field names and values to update |

### Example

```lua
local result = app.integrations.bubble.update_record({
  type = "User",
  id = "1704982345123x456789",
  fields = '{"name": "Jane Smith", "role": "editor"}'
})

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

---

## delete_record

Delete a record permanently by its unique ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Bubble data type name |
| `id` | string | yes | The unique identifier of the record |

### Example

```lua
app.integrations.bubble.delete_record({
  type = "User",
  id = "1704982345123x456789"
})
```

---

## Multi-Account Usage

If you have multiple Bubble apps configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.bubble.list_records({ type = "User" })

-- Explicit default (portable across setups)
app.integrations.bubble.default.list_records({ type = "User" })

-- Named accounts
app.integrations.bubble.main_app.list_records({ type = "User" })
app.integrations.bubble.staging.list_records({ type = "User" })
```

All functions are identical across accounts — only the credentials (API key and hostname) differ.

Metadata-Derived Lua Example

local result = app.integrations.bubble.bubble_list_records({
  type = "example_type",
  constraints = "example_constraints",
  limit = 1,
  cursor = 1
})
print(result)

Functions

bubble_list_records

List records from a Bubble data type. Supports filtering with constraints, pagination with limit and cursor. Returns matching records and a remaining count for further pagination.

Operation
Read read
Full name
bubble.bubble_list_records
ParameterTypeRequiredDescription
type string yes The Bubble data type name (case-sensitive, e.g. "User", "Product", "Order").
constraints string no JSON-encoded array of Bubble constraint objects for filtering. Each constraint is {"key": "field_name", "constraint_type": "equals", "value": "some_value"}. Pass as a JSON string.
limit integer no Maximum number of records to return (1–100, default: 100).
cursor integer no Offset for pagination (0-based). Use the "remaining" count from the previous response to determine if more pages exist.

bubble_get_record

Get a single record from Bubble by its data type and unique ID. Returns all fields of the record.

Operation
Read read
Full name
bubble.bubble_get_record
ParameterTypeRequiredDescription
type string yes The Bubble data type name (case-sensitive, e.g. "User", "Product", "Order").
id string yes The unique identifier of the record (Bubble-generated UUID).

bubble_create_record

Create a new record in a Bubble data type. Provide field names and values as a JSON object. Returns the created record including its generated ID.

Operation
Write write
Full name
bubble.bubble_create_record
ParameterTypeRequiredDescription
type string yes The Bubble data type name (case-sensitive, e.g. "User", "Product", "Order").
fields string yes JSON object of field names and values for the new record. Example: {"name": "John", "email": "[email protected]", "age": 30}. Pass as a JSON string.

bubble_update_record

Update an existing record in Bubble by its data type and unique ID. Only the fields provided will be changed; other fields remain unchanged. Returns the updated record.

Operation
Write write
Full name
bubble.bubble_update_record
ParameterTypeRequiredDescription
type string yes The Bubble data type name (case-sensitive, e.g. "User", "Product", "Order").
id string yes The unique identifier of the record to update (Bubble-generated UUID).
fields string yes JSON object of field names and values to update. Only the provided fields will be changed. Example: {"name": "Jane", "status": "active"}. Pass as a JSON string.

bubble_delete_record

Delete a record from Bubble by its data type and unique ID. This action is permanent and cannot be undone.

Operation
Write write
Full name
bubble.bubble_delete_record
ParameterTypeRequiredDescription
type string yes The Bubble data type name (case-sensitive, e.g. "User", "Product", "Order").
id string yes The unique identifier of the record to delete (Bubble-generated UUID).