KosmoKrator

other

Strapi Lua API for KosmoKrator Agents

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

7 functions 4 read 3 write API token auth

Lua Namespace

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

Strapi — Lua API Reference

strapi_list_entries

List entries for a content type in Strapi. Supports pagination, sorting, and population of relations.

Parameters

NameTypeRequiredDescription
content_typestringyesThe API ID of the content type (e.g., "article", "page", "product")
pageintegernoPage number for pagination (default: 1)
page_sizeintegernoNumber of entries per page (default: 25)
sortstringnoSort field and direction (e.g., "createdAt:desc", "title:asc")
populatestringnoRelations to populate: "*" for all, or a field name (e.g., "author", "image")

Examples

-- List all articles
local result = app.integrations.strapi.list_entries({
  content_type = "article",
  page_size = 10,
  sort = "createdAt:desc",
  populate = "*"
})

for _, entry in ipairs(result.data) do
  print(entry.id .. ": " .. entry.attributes.title)
end
-- List products with pagination
local result = app.integrations.strapi.list_entries({
  content_type = "product",
  page = 2,
  page_size = 50,
  populate = "image"
})

strapi_get_entry

Get a single entry by content type and ID.

Parameters

NameTypeRequiredDescription
content_typestringyesThe API ID of the content type
idintegeryesThe entry ID
populatestringnoRelations to populate: "*" for all, or a field name

Examples

-- Get a single article with all relations
local result = app.integrations.strapi.get_entry({
  content_type = "article",
  id = 42,
  populate = "*"
})

print(result.data.attributes.title)

strapi_create_entry

Create a new entry for a content type. The data is automatically wrapped in the required "data" envelope.

Parameters

NameTypeRequiredDescription
content_typestringyesThe API ID of the content type
dataobjectyesThe entry data (fields depend on the content type)

Examples

-- Create a new article
local result = app.integrations.strapi.create_entry({
  content_type = "article",
  data = {
    title = "Hello World",
    body = "This is my first article.",
    publishedAt = nil   -- set to nil for draft
  }
})

print("Created entry with ID: " .. result.data.id)

strapi_update_entry

Update an existing entry by content type and ID. The data is automatically wrapped in the required "data" envelope.

Parameters

NameTypeRequiredDescription
content_typestringyesThe API ID of the content type
idintegeryesThe entry ID to update
dataobjectyesThe fields to update

Examples

-- Update an article's title
local result = app.integrations.strapi.update_entry({
  content_type = "article",
  id = 42,
  data = {
    title = "Updated Title"
  }
})

strapi_delete_entry

Delete an entry by content type and ID. This action is permanent.

Parameters

NameTypeRequiredDescription
content_typestringyesThe API ID of the content type
idintegeryesThe entry ID to delete

Examples

local result = app.integrations.strapi.delete_entry({
  content_type = "article",
  id = 42
})

print(result.message)

strapi_list_content_types

List all content types defined in the Strapi Content-Type Builder. Returns API IDs, display names, and schema information.

Parameters

None.

Examples

local result = app.integrations.strapi.list_content_types()

for _, ct in ipairs(result.data) do
  print(ct.uid .. " — " .. ct.schema.displayName)
end

strapi_get_current_user

Get the currently authenticated Strapi user. Useful for verifying the API token and checking permissions.

Parameters

None.

Examples

local result = app.integrations.strapi.get_current_user()

print("Connected as: " .. result.username .. " (" .. result.email .. ")")

Multi-Account Usage

If you have multiple Strapi instances configured, use account-specific namespaces:

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

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

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

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

Raw agent markdown
# Strapi — Lua API Reference

## strapi_list_entries

List entries for a content type in Strapi. Supports pagination, sorting, and population of relations.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type` | string | yes | The API ID of the content type (e.g., `"article"`, `"page"`, `"product"`) |
| `page` | integer | no | Page number for pagination (default: 1) |
| `page_size` | integer | no | Number of entries per page (default: 25) |
| `sort` | string | no | Sort field and direction (e.g., `"createdAt:desc"`, `"title:asc"`) |
| `populate` | string | no | Relations to populate: `"*"` for all, or a field name (e.g., `"author"`, `"image"`) |

### Examples

```lua
-- List all articles
local result = app.integrations.strapi.list_entries({
  content_type = "article",
  page_size = 10,
  sort = "createdAt:desc",
  populate = "*"
})

for _, entry in ipairs(result.data) do
  print(entry.id .. ": " .. entry.attributes.title)
end
```

```lua
-- List products with pagination
local result = app.integrations.strapi.list_entries({
  content_type = "product",
  page = 2,
  page_size = 50,
  populate = "image"
})
```

---

## strapi_get_entry

Get a single entry by content type and ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type` | string | yes | The API ID of the content type |
| `id` | integer | yes | The entry ID |
| `populate` | string | no | Relations to populate: `"*"` for all, or a field name |

### Examples

```lua
-- Get a single article with all relations
local result = app.integrations.strapi.get_entry({
  content_type = "article",
  id = 42,
  populate = "*"
})

print(result.data.attributes.title)
```

---

## strapi_create_entry

Create a new entry for a content type. The data is automatically wrapped in the required `"data"` envelope.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type` | string | yes | The API ID of the content type |
| `data` | object | yes | The entry data (fields depend on the content type) |

### Examples

```lua
-- Create a new article
local result = app.integrations.strapi.create_entry({
  content_type = "article",
  data = {
    title = "Hello World",
    body = "This is my first article.",
    publishedAt = nil   -- set to nil for draft
  }
})

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

---

## strapi_update_entry

Update an existing entry by content type and ID. The data is automatically wrapped in the required `"data"` envelope.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type` | string | yes | The API ID of the content type |
| `id` | integer | yes | The entry ID to update |
| `data` | object | yes | The fields to update |

### Examples

```lua
-- Update an article's title
local result = app.integrations.strapi.update_entry({
  content_type = "article",
  id = 42,
  data = {
    title = "Updated Title"
  }
})
```

---

## strapi_delete_entry

Delete an entry by content type and ID. This action is permanent.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type` | string | yes | The API ID of the content type |
| `id` | integer | yes | The entry ID to delete |

### Examples

```lua
local result = app.integrations.strapi.delete_entry({
  content_type = "article",
  id = 42
})

print(result.message)
```

---

## strapi_list_content_types

List all content types defined in the Strapi Content-Type Builder. Returns API IDs, display names, and schema information.

### Parameters

None.

### Examples

```lua
local result = app.integrations.strapi.list_content_types()

for _, ct in ipairs(result.data) do
  print(ct.uid .. " — " .. ct.schema.displayName)
end
```

---

## strapi_get_current_user

Get the currently authenticated Strapi user. Useful for verifying the API token and checking permissions.

### Parameters

None.

### Examples

```lua
local result = app.integrations.strapi.get_current_user()

print("Connected as: " .. result.username .. " (" .. result.email .. ")")
```

---

## Multi-Account Usage

If you have multiple Strapi instances configured, use account-specific namespaces:

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

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

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

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

Metadata-Derived Lua Example

local result = app.integrations.strapi.strapi_list_entries({
  content_type = "example_content_type",
  page = 1,
  page_size = 1,
  sort = "example_sort",
  populate = "example_populate"
})
print(result)

Functions

strapi_list_entries

List entries for a content type in Strapi. Supports pagination, sorting, and field population (relations, media, components).

Operation
Read read
Full name
strapi.strapi_list_entries
ParameterTypeRequiredDescription
content_type string yes The API ID of the content type (e.g., "article", "page", "product").
page integer no Page number for pagination (default: 1).
page_size integer no Number of entries per page (default: 25).
sort string no Sort field and direction (e.g., "createdAt:desc", "title:asc").
populate string no Relations to populate. Use "*" for all, or a specific field name (e.g., "author", "image").

strapi_get_entry

Get a single entry from Strapi by content type and ID. Supports population of relations and media.

Operation
Read read
Full name
strapi.strapi_get_entry
ParameterTypeRequiredDescription
content_type string yes The API ID of the content type (e.g., "article", "page", "product").
id integer yes The entry ID.
populate string no Relations to populate. Use "*" for all, or a specific field name (e.g., "author", "image").

strapi_create_entry

Create a new entry in Strapi for a given content type. The data is automatically wrapped in the required "data" envelope.

Operation
Write write
Full name
strapi.strapi_create_entry
ParameterTypeRequiredDescription
content_type string yes The API ID of the content type (e.g., "article", "page", "product").
data object yes The entry data as a JSON object. Fields depend on the content type (e.g., {"title": "Hello", "body": "World"}).

strapi_update_entry

Update an existing entry in Strapi by content type and ID. The data is automatically wrapped in the required "data" envelope.

Operation
Write write
Full name
strapi.strapi_update_entry
ParameterTypeRequiredDescription
content_type string yes The API ID of the content type (e.g., "article", "page", "product").
id integer yes The entry ID to update.
data object yes The fields to update as a JSON object (e.g., {"title": "Updated Title"}).

strapi_delete_entry

Delete an entry from Strapi by content type and ID. This action is permanent.

Operation
Write write
Full name
strapi.strapi_delete_entry
ParameterTypeRequiredDescription
content_type string yes The API ID of the content type (e.g., "article", "page", "product").
id integer yes The entry ID to delete.

strapi_list_content_types

List all content types defined in the Strapi Content-Type Builder. Returns API IDs, display names, and schema information.

Operation
Read read
Full name
strapi.strapi_list_content_types
ParameterTypeRequiredDescription
No parameters.

strapi_get_current_user

Get the currently authenticated Strapi user. Useful for verifying the API token and checking permissions.

Operation
Read read
Full name
strapi.strapi_get_current_user
ParameterTypeRequiredDescription
No parameters.