KosmoKrator

productivity

Contentful Lua API for KosmoKrator Agents

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

Lua Namespace

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

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

Workflow file

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

workflow.lua
local contentful = app.integrations.contentful
local result = contentful.list_types({limit = 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.contentful, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.contentful.default.* or app.integrations.contentful.work.* when you configured named credential accounts.

MCP-only Lua

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

Client for the Contentful Content Management API covering content types, entries, assets, and space info — Lua API Reference

contentful_create_content_type

No description.

Parameters

NameTypeRequiredDescription
namestringyesInternal name of the content type (e.g.
display_namestringyesHuman-readable display name (e.g.
descriptionstringnoDescription of the content type.
fieldsstringyesJSON array of field definitions. Each field needs id, name, and type. Example: [{

Example

local result = app.integrations.contentful.contentful_create_content_type({
  name = ""
  display_name = ""
  description = ""
})

contentful_create_entry

No description.

Parameters

NameTypeRequiredDescription
content_type_idstringyesThe content type ID for the new entry.
fieldsstringyesJSON object of localized field values. E.g. {

Example

local result = app.integrations.contentful.contentful_create_entry({
  content_type_id = ""
  fields = ""
})

contentful_delete_entry

No description.

Parameters

NameTypeRequiredDescription
entry_idstringyesThe ID of the entry to delete.

Example

local result = app.integrations.contentful.contentful_delete_entry({
  entry_id = ""
})

contentful_get_content_type

No description.

Parameters

NameTypeRequiredDescription
content_type_idstringyesThe ID of the content type to retrieve.

Example

local result = app.integrations.contentful.contentful_get_content_type({
  content_type_id = ""
})

contentful_get_entry

No description.

Parameters

NameTypeRequiredDescription
entry_idstringyesThe ID of the entry to retrieve.

Example

local result = app.integrations.contentful.contentful_get_entry({
  entry_id = ""
})

contentful_get_space

No description.

Example

local result = app.integrations.contentful.contentful_get_space({
})

contentful_list_assets

No description.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of assets to return (default 100).
skipintegernoNumber of assets to skip for pagination.

Example

local result = app.integrations.contentful.contentful_list_assets({
  limit = 0
  skip = 0
})

contentful_list_content_types

No description.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of content types to return (default 100).

Example

local result = app.integrations.contentful.contentful_list_content_types({
  limit = 0
})

contentful_list_entries

No description.

Parameters

NameTypeRequiredDescription
content_typestringnoFilter entries by content type ID.
limitintegernoMaximum number of entries to return (default 100, max 1000).
skipintegernoNumber of entries to skip for pagination.
orderstringnoOrder entries by field. Prefix with
querystringnoFull-text search query to filter entries.

Example

local result = app.integrations.contentful.contentful_list_entries({
  content_type = ""
  limit = 0
  skip = 0
})

contentful_publish_entry

No description.

Parameters

NameTypeRequiredDescription
entry_idstringyesThe ID of the entry to publish.
versionintegeryesCurrent version of the entry (required for optimistic locking).

Example

local result = app.integrations.contentful.contentful_publish_entry({
  entry_id = ""
  version = 0
})

contentful_unpublish_entry

No description.

Parameters

NameTypeRequiredDescription
entry_idstringyesThe ID of the entry to unpublish.
versionintegeryesCurrent version of the entry (required for optimistic locking).

Example

local result = app.integrations.contentful.contentful_unpublish_entry({
  entry_id = ""
  version = 0
})

contentful_update_entry

No description.

Parameters

NameTypeRequiredDescription
entry_idstringyesThe ID of the entry to update.
fieldsstringyesJSON object of localized field values to update. E.g. {
versionintegeryesCurrent version of the entry (required for optimistic locking). Get this from the entry\

Example

local result = app.integrations.contentful.contentful_update_entry({
  entry_id = ""
  fields = ""
  version = 0
})

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.contentful.work.function_name({...})
app.integrations.contentful.personal.function_name({...})

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

Raw agent markdown
# Client for the Contentful Content Management API covering content types, entries, assets, and space info — Lua API Reference

## contentful_create_content_type

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Internal name of the content type (e.g.  |
| `display_name` | string | yes | Human-readable display name (e.g.  |
| `description` | string | no | Description of the content type. |
| `fields` | string | yes | JSON array of field definitions. Each field needs id, name, and type. Example: [{ |

### Example

```lua
local result = app.integrations.contentful.contentful_create_content_type({
  name = ""
  display_name = ""
  description = ""
})
```

## contentful_create_entry

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type_id` | string | yes | The content type ID for the new entry. |
| `fields` | string | yes | JSON object of localized field values. E.g. { |

### Example

```lua
local result = app.integrations.contentful.contentful_create_entry({
  content_type_id = ""
  fields = ""
})
```

## contentful_delete_entry

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entry_id` | string | yes | The ID of the entry to delete. |

### Example

```lua
local result = app.integrations.contentful.contentful_delete_entry({
  entry_id = ""
})
```

## contentful_get_content_type

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type_id` | string | yes | The ID of the content type to retrieve. |

### Example

```lua
local result = app.integrations.contentful.contentful_get_content_type({
  content_type_id = ""
})
```

## contentful_get_entry

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entry_id` | string | yes | The ID of the entry to retrieve. |

### Example

```lua
local result = app.integrations.contentful.contentful_get_entry({
  entry_id = ""
})
```

## contentful_get_space

No description.

### Example

```lua
local result = app.integrations.contentful.contentful_get_space({
})
```

## contentful_list_assets

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of assets to return (default 100). |
| `skip` | integer | no | Number of assets to skip for pagination. |

### Example

```lua
local result = app.integrations.contentful.contentful_list_assets({
  limit = 0
  skip = 0
})
```

## contentful_list_content_types

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of content types to return (default 100). |

### Example

```lua
local result = app.integrations.contentful.contentful_list_content_types({
  limit = 0
})
```

## contentful_list_entries

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `content_type` | string | no | Filter entries by content type ID. |
| `limit` | integer | no | Maximum number of entries to return (default 100, max 1000). |
| `skip` | integer | no | Number of entries to skip for pagination. |
| `order` | string | no | Order entries by field. Prefix with  |
| `query` | string | no | Full-text search query to filter entries. |

### Example

```lua
local result = app.integrations.contentful.contentful_list_entries({
  content_type = ""
  limit = 0
  skip = 0
})
```

## contentful_publish_entry

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entry_id` | string | yes | The ID of the entry to publish. |
| `version` | integer | yes | Current version of the entry (required for optimistic locking). |

### Example

```lua
local result = app.integrations.contentful.contentful_publish_entry({
  entry_id = ""
  version = 0
})
```

## contentful_unpublish_entry

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entry_id` | string | yes | The ID of the entry to unpublish. |
| `version` | integer | yes | Current version of the entry (required for optimistic locking). |

### Example

```lua
local result = app.integrations.contentful.contentful_unpublish_entry({
  entry_id = ""
  version = 0
})
```

## contentful_update_entry

No description.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `entry_id` | string | yes | The ID of the entry to update. |
| `fields` | string | yes | JSON object of localized field values to update. E.g. { |
| `version` | integer | yes | Current version of the entry (required for optimistic locking). Get this from the entry\ |

### Example

```lua
local result = app.integrations.contentful.contentful_update_entry({
  entry_id = ""
  fields = ""
  version = 0
})
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.contentful.work.function_name({...})
app.integrations.contentful.personal.function_name({...})
```

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

Functions

list_types Read

List all content types defined in the connected Contentful space. Returns each content type's ID, name, description, and field count. Optionally limit the number of results.

Lua path
app.integrations.contentful.list_types
Full name
contentful.contentful_list_content_types
ParameterTypeRequiredDescription
limit integer no Maximum number of content types to return (default 100).
get_type Read

Get detailed information about a specific content type by its ID. Returns the content type name, description, display field, and full field definitions.

Lua path
app.integrations.contentful.get_type
Full name
contentful.contentful_get_content_type
ParameterTypeRequiredDescription
content_type_id string yes The ID of the content type to retrieve.
create_type Write

Create a new content type in Contentful with a name, display name, optional description, and field definitions. Fields are provided as a JSON array of objects with id, name, and type. Common field types: Symbol, Text, Integer, Number, Boolean, Date, Location, RichText, Array, Link.

Lua path
app.integrations.contentful.create_type
Full name
contentful.contentful_create_content_type
ParameterTypeRequiredDescription
name string yes Internal name of the content type (e.g. "blogPost").
display_name string yes Human-readable display name (e.g. "Blog Post").
description string no Description of the content type.
fields string yes JSON array of field definitions. Each field needs id, name, and type. Example: [{"id":"title","name":"Title","type":"Symbol"}].
list_entries Read

List entries in the Contentful space. Optionally filter by content type, control pagination with limit and skip, order results, or search with a text query. Returns entry IDs, content types, and localized field values.

Lua path
app.integrations.contentful.list_entries
Full name
contentful.contentful_list_entries
ParameterTypeRequiredDescription
content_type string no Filter entries by content type ID.
limit integer no Maximum number of entries to return (default 100, max 1000).
skip integer no Number of entries to skip for pagination.
order string no Order entries by field. Prefix with "-" for descending. E.g. "sys.createdAt" or "-sys.updatedAt".
query string no Full-text search query to filter entries.
get_entry Read

Get detailed information about a specific entry by its ID. Returns all localized field values, content type, version, and timestamps.

Lua path
app.integrations.contentful.get_entry
Full name
contentful.contentful_get_entry
ParameterTypeRequiredDescription
entry_id string yes The ID of the entry to retrieve.
create_entry Write

Create a new entry in Contentful. Specify the content type ID and provide field values as a JSON object. Fields must be localized, e.g. {"title": {"en-US": "My Title"}}. The entry is created as a draft; use the publish tool to publish it.

Lua path
app.integrations.contentful.create_entry
Full name
contentful.contentful_create_entry
ParameterTypeRequiredDescription
content_type_id string yes The content type ID for the new entry.
fields string yes JSON object of localized field values. E.g. {"title": {"en-US": "Hello"}, "body": {"en-US": "World"}}.
update_entry Write

Update an existing entry's field values. Requires the current version number for optimistic locking. Fields must be localized, e.g. {"title": {"en-US": "Updated Title"}}. The version is sent as the X-Contentful-Version header.

Lua path
app.integrations.contentful.update_entry
Full name
contentful.contentful_update_entry
ParameterTypeRequiredDescription
entry_id string yes The ID of the entry to update.
fields string yes JSON object of localized field values to update. E.g. {"title": {"en-US": "New Title"}}.
version integer yes Current version of the entry (required for optimistic locking). Get this from the entry's sys.version.
publish_entry Write

Publish a draft or updated entry. Requires the current version number for optimistic locking, sent as the X-Contentful-Version header. After publishing, the entry becomes publicly visible via the Content Delivery API.

Lua path
app.integrations.contentful.publish_entry
Full name
contentful.contentful_publish_entry
ParameterTypeRequiredDescription
entry_id string yes The ID of the entry to publish.
version integer yes Current version of the entry (required for optimistic locking).
unpublish_entry Write

Unpublish a published entry, reverting it to draft status. Requires the current version number for optimistic locking, sent as the X-Contentful-Version header. The entry will no longer be visible via the Content Delivery API.

Lua path
app.integrations.contentful.unpublish_entry
Full name
contentful.contentful_unpublish_entry
ParameterTypeRequiredDescription
entry_id string yes The ID of the entry to unpublish.
version integer yes Current version of the entry (required for optimistic locking).
delete_entry Write

Permanently delete an entry from the Contentful space. The entry must be unpublished before it can be deleted. This action is irreversible.

Lua path
app.integrations.contentful.delete_entry
Full name
contentful.contentful_delete_entry
ParameterTypeRequiredDescription
entry_id string yes The ID of the entry to delete.
list_assets Read

List assets (images, files, videos) in the Contentful space. Supports pagination with limit and skip parameters. Returns asset IDs, titles, file details, and URLs.

Lua path
app.integrations.contentful.list_assets
Full name
contentful.contentful_list_assets
ParameterTypeRequiredDescription
limit integer no Maximum number of assets to return (default 100).
skip integer no Number of assets to skip for pagination.
get_space Read

Get details about the connected Contentful space, including name, locales, organization, and space type.

Lua path
app.integrations.contentful.get_space
Full name
contentful.contentful_get_space
ParameterTypeRequiredDescription
No parameters.