data
Strapi Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Strapi KosmoKrator integration.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.
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
Strapi workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.strapi.list_entries({content_type = "example_content_type", page = 1, page_size = 1, sort = "example_sort", populate = "example_populate"}))' --json kosmo integrations:lua --eval 'print(docs.read("strapi"))' --json
kosmo integrations:lua --eval 'print(docs.read("strapi.list_entries"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local strapi = app.integrations.strapi
local result = strapi.list_entries({content_type = "example_content_type", page = 1, page_size = 1, sort = "example_sort", populate = "example_populate"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.strapi, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.strapi.default.* or app.integrations.strapi.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Strapi, use the narrower 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.
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
-- 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
| 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
-- 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
-- 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
-- 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
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. local result = app.integrations.strapi.list_entries({content_type = "example_content_type", page = 1, page_size = 1, sort = "example_sort", populate = "example_populate"})
print(result) Functions
list_entries Read
List entries for a content type in Strapi. Supports pagination, sorting, and field population (relations, media, components).
- Lua path
app.integrations.strapi.list_entries- Full name
strapi.strapi_list_entries
| Parameter | 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. Use "*" for all, or a specific field name (e.g., "author", "image"). |
get_entry Read
Get a single entry from Strapi by content type and ID. Supports population of relations and media.
- Lua path
app.integrations.strapi.get_entry- Full name
strapi.strapi_get_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
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"). |
create_entry Write
Create a new entry in Strapi for a given content type. The data is automatically wrapped in the required "data" envelope.
- Lua path
app.integrations.strapi.create_entry- Full name
strapi.strapi_create_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
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"}). |
update_entry Write
Update an existing entry in Strapi by content type and ID. The data is automatically wrapped in the required "data" envelope.
- Lua path
app.integrations.strapi.update_entry- Full name
strapi.strapi_update_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
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"}). |
delete_entry Write
Delete an entry from Strapi by content type and ID. This action is permanent.
- Lua path
app.integrations.strapi.delete_entry- Full name
strapi.strapi_delete_entry
| Parameter | Type | Required | Description |
|---|---|---|---|
content_type | string | yes | The API ID of the content type (e.g., "article", "page", "product"). |
id | integer | yes | The entry ID to delete. |
list_content_types Read
List all content types defined in the Strapi Content-Type Builder. Returns API IDs, display names, and schema information.
- Lua path
app.integrations.strapi.list_content_types- Full name
strapi.strapi_list_content_types
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_current_user Read
Get the currently authenticated Strapi user. Useful for verifying the API token and checking permissions.
- Lua path
app.integrations.strapi.get_current_user- Full name
strapi.strapi_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||