KosmoKrator

data

Appwrite Lua API for KosmoKrator Agents

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

Lua Namespace

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

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.appwrite.list_databases({queries = "example_queries", search = "example_search", total = true, limit = 1, offset = 1}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("appwrite"))' --json
kosmo integrations:lua --eval 'print(docs.read("appwrite.list_databases"))' --json

Workflow file

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

workflow.lua
local appwrite = app.integrations.appwrite
local result = appwrite.list_databases({queries = "example_queries", search = "example_search", total = true, limit = 1, offset = 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.appwrite, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.appwrite.default.* or app.integrations.appwrite.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Appwrite, 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.

Appwrite - Lua API Reference

Namespace: app.integrations.appwrite

This integration uses the Appwrite server REST API with X-Appwrite-Key and X-Appwrite-Project headers. Configure the Appwrite Cloud endpoint, for example https://cloud.appwrite.io/v1, or a self-hosted /v1 endpoint.

Coverage

Tools cover the main server-side Appwrite surfaces:

  • Databases: list, create, get, update, delete databases.
  • Collections: list, create, get, update, delete collections.
  • Documents: list, create, get, update, delete documents.
  • Users: list, create, get, enable or block, delete users.
  • Teams: list, create, get, delete teams, and list memberships.
  • Storage: list, create, get, update, delete buckets; list, get, delete files.
  • Functions: list and get functions; create, list, and get executions.
  • Messaging: list providers, topics, and messages; create or delete topics; create email and push messages.

Query Parameters

Appwrite’s REST API accepts queries arrays generated with Appwrite’s Query helpers. Pass those query strings directly:

local users = app.integrations.appwrite.list_users({
  queries = {'limit(25)', 'orderDesc("$createdAt")'},
  search = "ada"
})

Databases

local database = app.integrations.appwrite.create_database({
  database_id = "crm",
  name = "CRM"
})

local collection = app.integrations.appwrite.create_collection({
  database_id = "crm",
  collection_id = "contacts",
  name = "Contacts",
  permissions = {"read(\"any\")"},
  document_security = true
})

local document = app.integrations.appwrite.create_document({
  database_id = "crm",
  collection_id = "contacts",
  document_id = "unique()",
  data = {
    name = "Ada Example",
    email = "ada@example.test"
  }
})

Existing database/document tools use snake_case arguments such as database_id, collection_id, and document_id. New tools keep the same convention and map to Appwrite’s camelCase REST fields internally.

Users And Teams

local user = app.integrations.appwrite.create_user({
  user_id = "unique()",
  email = "ada@example.test",
  password = "replace-with-generated-secret",
  name = "Ada Example"
})

app.integrations.appwrite.update_user_status({
  user_id = user["$id"],
  status = false
})

local team = app.integrations.appwrite.create_team({
  team_id = "ops",
  name = "Operations",
  roles = {"owner"}
})

Storage

local bucket = app.integrations.appwrite.create_bucket({
  bucket_id = "imports",
  name = "Imports",
  file_security = true,
  maximum_file_size = 10485760,
  allowed_file_extensions = {"csv", "json"}
})

local files = app.integrations.appwrite.list_files({
  bucket_id = "imports",
  queries = {'limit(10)'}
})

File upload/download endpoints are intentionally not wrapped here because they need multipart or binary response handling. Use storage metadata tools to inspect and clean up files from agents.

Functions

local execution = app.integrations.appwrite.create_execution({
  function_id = "sync_contacts",
  body = '{"dry_run":true}',
  async = false,
  method = "POST"
})

Function execution body is a string because Appwrite passes it to the function runtime as request body content.

Messaging

local topic = app.integrations.appwrite.create_topic({
  topic_id = "product_updates",
  name = "Product updates",
  subscribe = {"user:example"}
})

local email = app.integrations.appwrite.create_email({
  message_id = "unique()",
  subject = "Status update",
  content = "Deployment completed.",
  users = {"user_123"},
  draft = true
})

Messaging provider setup is provider-specific, so the integration exposes list operations for providers and message/topic operations that are safe to drive from agents.

Return Shapes

Responses are the normalized Appwrite REST JSON payloads. Collection list endpoints usually return total plus an array named for the resource, such as databases, collections, documents, users, teams, buckets, files, functions, executions, topics, or messages.

Multi-Account Usage

app.integrations.appwrite.list_databases({})
app.integrations.appwrite.default.list_databases({})
app.integrations.appwrite.production.list_databases({})

All account namespaces expose the same tools; only credentials differ.

Raw agent markdown
# Appwrite - Lua API Reference

Namespace: `app.integrations.appwrite`

This integration uses the Appwrite server REST API with `X-Appwrite-Key` and `X-Appwrite-Project` headers. Configure the Appwrite Cloud endpoint, for example `https://cloud.appwrite.io/v1`, or a self-hosted `/v1` endpoint.

## Coverage

Tools cover the main server-side Appwrite surfaces:

- Databases: list, create, get, update, delete databases.
- Collections: list, create, get, update, delete collections.
- Documents: list, create, get, update, delete documents.
- Users: list, create, get, enable or block, delete users.
- Teams: list, create, get, delete teams, and list memberships.
- Storage: list, create, get, update, delete buckets; list, get, delete files.
- Functions: list and get functions; create, list, and get executions.
- Messaging: list providers, topics, and messages; create or delete topics; create email and push messages.

## Query Parameters

Appwrite's REST API accepts `queries` arrays generated with Appwrite's Query helpers. Pass those query strings directly:

```lua
local users = app.integrations.appwrite.list_users({
  queries = {'limit(25)', 'orderDesc("$createdAt")'},
  search = "ada"
})
```

## Databases

```lua
local database = app.integrations.appwrite.create_database({
  database_id = "crm",
  name = "CRM"
})

local collection = app.integrations.appwrite.create_collection({
  database_id = "crm",
  collection_id = "contacts",
  name = "Contacts",
  permissions = {"read(\"any\")"},
  document_security = true
})

local document = app.integrations.appwrite.create_document({
  database_id = "crm",
  collection_id = "contacts",
  document_id = "unique()",
  data = {
    name = "Ada Example",
    email = "ada@example.test"
  }
})
```

Existing database/document tools use snake_case arguments such as `database_id`, `collection_id`, and `document_id`. New tools keep the same convention and map to Appwrite's camelCase REST fields internally.

## Users And Teams

```lua
local user = app.integrations.appwrite.create_user({
  user_id = "unique()",
  email = "ada@example.test",
  password = "replace-with-generated-secret",
  name = "Ada Example"
})

app.integrations.appwrite.update_user_status({
  user_id = user["$id"],
  status = false
})

local team = app.integrations.appwrite.create_team({
  team_id = "ops",
  name = "Operations",
  roles = {"owner"}
})
```

## Storage

```lua
local bucket = app.integrations.appwrite.create_bucket({
  bucket_id = "imports",
  name = "Imports",
  file_security = true,
  maximum_file_size = 10485760,
  allowed_file_extensions = {"csv", "json"}
})

local files = app.integrations.appwrite.list_files({
  bucket_id = "imports",
  queries = {'limit(10)'}
})
```

File upload/download endpoints are intentionally not wrapped here because they need multipart or binary response handling. Use storage metadata tools to inspect and clean up files from agents.

## Functions

```lua
local execution = app.integrations.appwrite.create_execution({
  function_id = "sync_contacts",
  body = '{"dry_run":true}',
  async = false,
  method = "POST"
})
```

Function execution `body` is a string because Appwrite passes it to the function runtime as request body content.

## Messaging

```lua
local topic = app.integrations.appwrite.create_topic({
  topic_id = "product_updates",
  name = "Product updates",
  subscribe = {"user:example"}
})

local email = app.integrations.appwrite.create_email({
  message_id = "unique()",
  subject = "Status update",
  content = "Deployment completed.",
  users = {"user_123"},
  draft = true
})
```

Messaging provider setup is provider-specific, so the integration exposes list operations for providers and message/topic operations that are safe to drive from agents.

## Return Shapes

Responses are the normalized Appwrite REST JSON payloads. Collection list endpoints usually return `total` plus an array named for the resource, such as `databases`, `collections`, `documents`, `users`, `teams`, `buckets`, `files`, `functions`, `executions`, `topics`, or `messages`.

## Multi-Account Usage

```lua
app.integrations.appwrite.list_databases({})
app.integrations.appwrite.default.list_databases({})
app.integrations.appwrite.production.list_databases({})
```

All account namespaces expose the same tools; only credentials differ.
Metadata-derived Lua example
local result = app.integrations.appwrite.list_databases({queries = "example_queries", search = "example_search", total = true, limit = 1, offset = 1})
print(result)

Functions

list_databases Read

List all databases in the Appwrite project. Returns database IDs and names.

Lua path
app.integrations.appwrite.list_databases
Full name
appwrite.appwrite_list_databases
ParameterTypeRequiredDescription
queries array no Appwrite Query strings for filtering and pagination.
search string no Search term to filter databases by name.
total boolean no Whether Appwrite should calculate total count.
limit integer no Compatibility helper that is converted to an Appwrite limit() query.
offset integer no Compatibility helper that is converted to an Appwrite offset() query.
create_database Write

Create a database in the Appwrite project.

Lua path
app.integrations.appwrite.create_database
Full name
appwrite.appwrite_create_database
ParameterTypeRequiredDescription
No parameters.
get_database Read

Get details of a specific Appwrite database by its ID.

Lua path
app.integrations.appwrite.get_database
Full name
appwrite.appwrite_get_database
ParameterTypeRequiredDescription
id string yes The database ID.
update_database Write

Update a database name or enabled state.

Lua path
app.integrations.appwrite.update_database
Full name
appwrite.appwrite_update_database
ParameterTypeRequiredDescription
No parameters.
delete_database Write

Delete a database by ID.

Lua path
app.integrations.appwrite.delete_database
Full name
appwrite.appwrite_delete_database
ParameterTypeRequiredDescription
No parameters.
list_collections Read

List all collections in an Appwrite database. Returns collection IDs and names.

Lua path
app.integrations.appwrite.list_collections
Full name
appwrite.appwrite_list_collections
ParameterTypeRequiredDescription
database_id string yes The database ID to list collections from.
queries array no Appwrite Query strings for filtering and pagination.
search string no Search term to filter collections by name.
total boolean no Whether Appwrite should calculate total count.
limit integer no Compatibility helper that is converted to an Appwrite limit() query.
offset integer no Compatibility helper that is converted to an Appwrite offset() query.
create_collection Write

Create a collection in a database.

Lua path
app.integrations.appwrite.create_collection
Full name
appwrite.appwrite_create_collection
ParameterTypeRequiredDescription
No parameters.
get_collection Read

Get details for a collection.

Lua path
app.integrations.appwrite.get_collection
Full name
appwrite.appwrite_get_collection
ParameterTypeRequiredDescription
No parameters.
update_collection Write

Update collection metadata and permissions.

Lua path
app.integrations.appwrite.update_collection
Full name
appwrite.appwrite_update_collection
ParameterTypeRequiredDescription
No parameters.
delete_collection Write

Delete a collection from a database.

Lua path
app.integrations.appwrite.delete_collection
Full name
appwrite.appwrite_delete_collection
ParameterTypeRequiredDescription
No parameters.
list_documents Read

List documents in an Appwrite collection. Returns document data and metadata.

Lua path
app.integrations.appwrite.list_documents
Full name
appwrite.appwrite_list_documents
ParameterTypeRequiredDescription
database_id string yes The database ID.
collection_id string yes The collection ID.
queries array no Appwrite Query strings for filtering and pagination.
total boolean no Whether Appwrite should calculate total count.
limit integer no Compatibility helper that is converted to an Appwrite limit() query.
offset integer no Compatibility helper that is converted to an Appwrite offset() query.
get_document Read

Get a single document from an Appwrite collection by its ID.

Lua path
app.integrations.appwrite.get_document
Full name
appwrite.appwrite_get_document
ParameterTypeRequiredDescription
database_id string yes The database ID.
collection_id string yes The collection ID.
doc_id string yes The document ID.
create_document Write

Create a new document in an Appwrite collection.

Lua path
app.integrations.appwrite.create_document
Full name
appwrite.appwrite_create_document
ParameterTypeRequiredDescription
database_id string yes The database ID.
collection_id string yes The collection ID.
document_id string yes A unique ID for the document (use "unique()" to auto-generate).
data object yes The document data as key-value pairs matching the collection attributes.
update_document Write

Update a document data payload.

Lua path
app.integrations.appwrite.update_document
Full name
appwrite.appwrite_update_document
ParameterTypeRequiredDescription
No parameters.
delete_document Write

Delete a document from a collection.

Lua path
app.integrations.appwrite.delete_document
Full name
appwrite.appwrite_delete_document
ParameterTypeRequiredDescription
No parameters.
get_current_user Read

Get the currently authenticated Appwrite user account information.

Lua path
app.integrations.appwrite.get_current_user
Full name
appwrite.appwrite_get_current_user
ParameterTypeRequiredDescription
No parameters.
list_users Read

List users in the Appwrite project.

Lua path
app.integrations.appwrite.list_users
Full name
appwrite.appwrite_list_users
ParameterTypeRequiredDescription
No parameters.
get_user Read

Get one Appwrite user by ID.

Lua path
app.integrations.appwrite.get_user
Full name
appwrite.appwrite_get_user
ParameterTypeRequiredDescription
No parameters.
create_user Write

Create a user in the Appwrite project.

Lua path
app.integrations.appwrite.create_user
Full name
appwrite.appwrite_create_user
ParameterTypeRequiredDescription
No parameters.
update_user_status Write

Enable or disable an Appwrite user.

Lua path
app.integrations.appwrite.update_user_status
Full name
appwrite.appwrite_update_user_status
ParameterTypeRequiredDescription
No parameters.
delete_user Write

Delete an Appwrite user.

Lua path
app.integrations.appwrite.delete_user
Full name
appwrite.appwrite_delete_user
ParameterTypeRequiredDescription
No parameters.
list_teams Read

List teams in the Appwrite project.

Lua path
app.integrations.appwrite.list_teams
Full name
appwrite.appwrite_list_teams
ParameterTypeRequiredDescription
No parameters.
get_team Read

Get one Appwrite team by ID.

Lua path
app.integrations.appwrite.get_team
Full name
appwrite.appwrite_get_team
ParameterTypeRequiredDescription
No parameters.
create_team Write

Create a team in the Appwrite project.

Lua path
app.integrations.appwrite.create_team
Full name
appwrite.appwrite_create_team
ParameterTypeRequiredDescription
No parameters.
delete_team Write

Delete an Appwrite team.

Lua path
app.integrations.appwrite.delete_team
Full name
appwrite.appwrite_delete_team
ParameterTypeRequiredDescription
No parameters.
list_team_memberships Read

List memberships for a team.

Lua path
app.integrations.appwrite.list_team_memberships
Full name
appwrite.appwrite_list_team_memberships
ParameterTypeRequiredDescription
No parameters.
list_buckets Read

List Appwrite storage buckets.

Lua path
app.integrations.appwrite.list_buckets
Full name
appwrite.appwrite_list_buckets
ParameterTypeRequiredDescription
No parameters.
get_bucket Read

Get one Appwrite storage bucket.

Lua path
app.integrations.appwrite.get_bucket
Full name
appwrite.appwrite_get_bucket
ParameterTypeRequiredDescription
No parameters.
create_bucket Write

Create an Appwrite storage bucket.

Lua path
app.integrations.appwrite.create_bucket
Full name
appwrite.appwrite_create_bucket
ParameterTypeRequiredDescription
No parameters.
update_bucket Write

Update an Appwrite storage bucket.

Lua path
app.integrations.appwrite.update_bucket
Full name
appwrite.appwrite_update_bucket
ParameterTypeRequiredDescription
No parameters.
delete_bucket Write

Delete an Appwrite storage bucket.

Lua path
app.integrations.appwrite.delete_bucket
Full name
appwrite.appwrite_delete_bucket
ParameterTypeRequiredDescription
No parameters.
list_files Read

List files in a storage bucket.

Lua path
app.integrations.appwrite.list_files
Full name
appwrite.appwrite_list_files
ParameterTypeRequiredDescription
No parameters.
get_file Read

Get Appwrite storage file metadata.

Lua path
app.integrations.appwrite.get_file
Full name
appwrite.appwrite_get_file
ParameterTypeRequiredDescription
No parameters.
delete_file Write

Delete a file from a storage bucket.

Lua path
app.integrations.appwrite.delete_file
Full name
appwrite.appwrite_delete_file
ParameterTypeRequiredDescription
No parameters.
list_functions Read

List Appwrite functions.

Lua path
app.integrations.appwrite.list_functions
Full name
appwrite.appwrite_list_functions
ParameterTypeRequiredDescription
No parameters.
get_function Read

Get one Appwrite function by ID.

Lua path
app.integrations.appwrite.get_function
Full name
appwrite.appwrite_get_function
ParameterTypeRequiredDescription
No parameters.
create_execution Write

Execute an Appwrite function.

Lua path
app.integrations.appwrite.create_execution
Full name
appwrite.appwrite_create_execution
ParameterTypeRequiredDescription
No parameters.
list_executions Read

List executions for an Appwrite function.

Lua path
app.integrations.appwrite.list_executions
Full name
appwrite.appwrite_list_executions
ParameterTypeRequiredDescription
No parameters.
get_execution Read

Get one Appwrite function execution.

Lua path
app.integrations.appwrite.get_execution
Full name
appwrite.appwrite_get_execution
ParameterTypeRequiredDescription
No parameters.
list_messaging_providers Read

List Appwrite messaging providers.

Lua path
app.integrations.appwrite.list_messaging_providers
Full name
appwrite.appwrite_list_messaging_providers
ParameterTypeRequiredDescription
No parameters.
list_topics Read

List Appwrite messaging topics.

Lua path
app.integrations.appwrite.list_topics
Full name
appwrite.appwrite_list_topics
ParameterTypeRequiredDescription
No parameters.
create_topic Write

Create an Appwrite messaging topic.

Lua path
app.integrations.appwrite.create_topic
Full name
appwrite.appwrite_create_topic
ParameterTypeRequiredDescription
No parameters.
delete_topic Write

Delete an Appwrite messaging topic.

Lua path
app.integrations.appwrite.delete_topic
Full name
appwrite.appwrite_delete_topic
ParameterTypeRequiredDescription
No parameters.
list_messages Read

List Appwrite messaging messages.

Lua path
app.integrations.appwrite.list_messages
Full name
appwrite.appwrite_list_messages
ParameterTypeRequiredDescription
No parameters.
create_email Write

Create an Appwrite email message.

Lua path
app.integrations.appwrite.create_email
Full name
appwrite.appwrite_create_email
ParameterTypeRequiredDescription
No parameters.
create_push Write

Create an Appwrite push notification.

Lua path
app.integrations.appwrite.create_push
Full name
appwrite.appwrite_create_push
ParameterTypeRequiredDescription
No parameters.