KosmoKrator

data

Memberstack Lua API for KosmoKrator Agents

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

Lua Namespace

Agents call this integration through app.integrations.memberstack.*. Use lua_read_doc("integrations.memberstack") 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 Memberstack workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.memberstack.list({limit = 1, page = 1}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("memberstack"))' --json
kosmo integrations:lua --eval 'print(docs.read("memberstack.list"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local memberstack = app.integrations.memberstack
local result = memberstack.list({limit = 1, page = 1})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.memberstack, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.memberstack.default.* or app.integrations.memberstack.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Memberstack, use the narrower mcp:lua command.

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.

Memberstack — Lua API Reference

list_members

List members with pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMembers per page (default: 50, max: 100)
pageintegernoPage number, 1-based (default: 1)

Example

local result = app.integrations.memberstack.list_members({
  limit = 25,
  page = 1
})

for _, member in ipairs(result.data) do
  print(member.id .. ": " .. member.email)
end

get_member

Get a single member by ID.

Parameters

NameTypeRequiredDescription
idstringyesMemberstack member ID

Example

local result = app.integrations.memberstack.get_member({
  id = "mem_abc123"
})

print(result.data.email)
print(result.data.metadata.name)

create_member

Create a new member.

Parameters

NameTypeRequiredDescription
emailstringyesEmail address
passwordstringnoPassword for the member
planIdstringnoPlan ID to assign (use list_plans to find IDs)
metadataobjectnoCustom key-value metadata

Example

local result = app.integrations.memberstack.create_member({
  email = "newuser@example.com",
  password = "secure-password",
  planId = "pln_premium",
  metadata = {
    name = "Jane Doe",
    company = "Acme Inc"
  }
})

print("Created member: " .. result.data.id)

update_member

Update an existing member.

Parameters

NameTypeRequiredDescription
idstringyesMemberstack member ID
emailstringnoNew email address
planIdstringnoNew plan ID to assign
metadataobjectnoMetadata to merge with existing values

Example

local result = app.integrations.memberstack.update_member({
  id = "mem_abc123",
  planId = "pln_enterprise",
  metadata = {
    role = "admin"
  }
})

delete_member

Permanently delete a member.

Parameters

NameTypeRequiredDescription
idstringyesMemberstack member ID

Example

app.integrations.memberstack.delete_member({
  id = "mem_abc123"
})

list_plans

List all membership plans.

Parameters

None.

Example

local result = app.integrations.memberstack.list_plans({})

for _, plan in ipairs(result.data) do
  print(plan.id .. ": " .. plan.name .. " ($" .. plan.price .. ")")
end

get_current_user

Get the currently authenticated user (verifies API credentials).

Parameters

None.

Example

local result = app.integrations.memberstack.get_current_user({})

print("Authenticated as: " .. result.data.email)

Multi-Account Usage

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

-- Default account (always works)
app.integrations.memberstack.list_members({limit = 10})

-- Explicit default (portable across setups)
app.integrations.memberstack.default.list_members({limit = 10})

-- Named accounts
app.integrations.memberstack.production.list_members({limit = 10})
app.integrations.memberstack.staging.list_members({limit = 10})

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

Raw agent markdown
# Memberstack — Lua API Reference

## list_members

List members with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Members per page (default: 50, max: 100) |
| `page` | integer | no | Page number, 1-based (default: 1) |

### Example

```lua
local result = app.integrations.memberstack.list_members({
  limit = 25,
  page = 1
})

for _, member in ipairs(result.data) do
  print(member.id .. ": " .. member.email)
end
```

---

## get_member

Get a single member by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Memberstack member ID |

### Example

```lua
local result = app.integrations.memberstack.get_member({
  id = "mem_abc123"
})

print(result.data.email)
print(result.data.metadata.name)
```

---

## create_member

Create a new member.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `email` | string | yes | Email address |
| `password` | string | no | Password for the member |
| `planId` | string | no | Plan ID to assign (use `list_plans` to find IDs) |
| `metadata` | object | no | Custom key-value metadata |

### Example

```lua
local result = app.integrations.memberstack.create_member({
  email = "newuser@example.com",
  password = "secure-password",
  planId = "pln_premium",
  metadata = {
    name = "Jane Doe",
    company = "Acme Inc"
  }
})

print("Created member: " .. result.data.id)
```

---

## update_member

Update an existing member.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Memberstack member ID |
| `email` | string | no | New email address |
| `planId` | string | no | New plan ID to assign |
| `metadata` | object | no | Metadata to merge with existing values |

### Example

```lua
local result = app.integrations.memberstack.update_member({
  id = "mem_abc123",
  planId = "pln_enterprise",
  metadata = {
    role = "admin"
  }
})
```

---

## delete_member

Permanently delete a member.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Memberstack member ID |

### Example

```lua
app.integrations.memberstack.delete_member({
  id = "mem_abc123"
})
```

---

## list_plans

List all membership plans.

### Parameters

None.

### Example

```lua
local result = app.integrations.memberstack.list_plans({})

for _, plan in ipairs(result.data) do
  print(plan.id .. ": " .. plan.name .. " ($" .. plan.price .. ")")
end
```

---

## get_current_user

Get the currently authenticated user (verifies API credentials).

### Parameters

None.

### Example

```lua
local result = app.integrations.memberstack.get_current_user({})

print("Authenticated as: " .. result.data.email)
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.memberstack.list_members({limit = 10})

-- Explicit default (portable across setups)
app.integrations.memberstack.default.list_members({limit = 10})

-- Named accounts
app.integrations.memberstack.production.list_members({limit = 10})
app.integrations.memberstack.staging.list_members({limit = 10})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.memberstack.list({limit = 1, page = 1})
print(result)

Functions

list Read

List members from Memberstack with pagination. Returns member IDs, emails, plan assignments, and metadata.

Lua path
app.integrations.memberstack.list
Full name
memberstack.memberstack_list_members
ParameterTypeRequiredDescription
limit integer no Number of members to return per page (default: 50, max: 100).
page integer no Page number for pagination (1-based, default: 1).
get Read

Get detailed information about a single Memberstack member by their ID, including email, plan, and custom metadata.

Lua path
app.integrations.memberstack.get
Full name
memberstack.memberstack_get_member
ParameterTypeRequiredDescription
id string yes The Memberstack member ID.
create Write

Create a new member in Memberstack. Requires an email address. Optionally set a password, assign a plan, and attach custom metadata.

Lua path
app.integrations.memberstack.create
Full name
memberstack.memberstack_create_member
ParameterTypeRequiredDescription
email string yes Email address for the new member.
password string no Password for the new member (optional).
planId string no ID of the plan to assign to the member (optional). Use memberstack_list_plans to find plan IDs.
metadata object no Custom metadata key-value pairs to attach to the member (optional).
update Write

Update an existing Memberstack member. Provide the member ID and any fields to change (email, plan assignment, or custom metadata).

Lua path
app.integrations.memberstack.update
Full name
memberstack.memberstack_update_member
ParameterTypeRequiredDescription
id string yes The Memberstack member ID to update.
email string no New email address for the member (optional).
planId string no New plan ID to assign (optional). Use memberstack_list_plans to find plan IDs.
metadata object no Custom metadata key-value pairs to update (optional). Merges with existing metadata.
delete Write

Permanently delete a member from Memberstack. This action is irreversible and removes all associated data.

Lua path
app.integrations.memberstack.delete
Full name
memberstack.memberstack_delete_member
ParameterTypeRequiredDescription
id string yes The Memberstack member ID to delete.
list_plans Read

List all membership plans configured in Memberstack. Returns plan IDs, names, pricing, and billing details.

Lua path
app.integrations.memberstack.list_plans
Full name
memberstack.memberstack_list_plans
ParameterTypeRequiredDescription
No parameters.
get_current_user Read

Get the currently authenticated user from Memberstack. Useful for verifying API credentials and checking account details.

Lua path
app.integrations.memberstack.get_current_user
Full name
memberstack.memberstack_get_current_user
ParameterTypeRequiredDescription
No parameters.