KosmoKrator

cms

Ghost CMS Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write API key auth

Lua Namespace

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

Ghost CMS — Lua API Reference

list_posts

List blog posts with filtering, pagination, and ordering.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
limitintegernoPosts per page (default: 15, max: 100)
filterstringnoGhost filter syntax (see below)
tagstringnoFilter by tag slug, e.g. "news"
authorstringnoFilter by author slug, e.g. "john"
statusstringno"published", "draft", or "scheduled"
orderstringnoSort order, e.g. "published_at desc"
fieldsstringnoComma-separated fields to return
includestringnoRelated data to include: "tags", "authors", "tags,authors"

Filter Syntax

Ghost uses a simple filter language:

  • AND: tag:news+status:published
  • OR: tag:news,tag:engineering
  • Comparison: published_at:>2025-01-01

Examples

-- List published posts with tags and authors
local result = app.integrations.ghost.list_posts({
  status = "published",
  include = "tags,authors",
  limit = 10
})

-- Filter by tag and paginate
local result = app.integrations.ghost.list_posts({
  tag = "engineering",
  page = 2,
  limit = 20
})

-- Search with custom filter
local result = app.integrations.ghost.list_posts({
  filter = "tag:news+status:published",
  order = "published_at desc"
})

get_post

Get a single blog post by ID.

Parameters

NameTypeRequiredDescription
idstringyesPost UUID
fieldsstringnoComma-separated fields to return
includestringnoRelated data: "tags", "authors"
formatsstringnoContent format: "html", "plaintext"

Example

local result = app.integrations.ghost.get_post({
  id = "64a1b2c3d4e5f6g7h8i9j0k",
  include = "tags,authors"
})

local post = result.posts[1]
print(post.title)
print(post.html)

create_post

Create a new blog post.

Parameters

NameTypeRequiredDescription
titlestringyesPost title
htmlstringnoPost content as HTML
statusstringno"draft" or "published" (default: "draft")
featuredbooleannoFeature this post (default: false)
tagsarraynoTag names, e.g. {"News", "Engineering"}
authorsarraynoAuthor emails, e.g. {"[email protected]"}
excerptstringnoCustom excerpt / meta description
feature_imagestringnoURL for the cover image

Examples

-- Create a draft post
local result = app.integrations.ghost.create_post({
  title = "My New Post",
  html = "<p>Hello world!</p>",
  status = "draft",
  tags = {"News", "Announcement"}
})

-- Create and publish immediately
local result = app.integrations.ghost.create_post({
  title = "Breaking News",
  html = "<p>Important update...</p>",
  status = "published",
  featured = true,
  tags = {"Breaking"},
  authors = {"[email protected]"}
})

update_post

Update an existing blog post.

Parameters

NameTypeRequiredDescription
idstringyesPost UUID to update
titlestringnoNew title
htmlstringnoNew HTML content
statusstringno"draft" or "published"
featuredbooleannoSet/unset featured flag
tagsarraynoReplace tags (e.g. {"Updated"})
excerptstringnoNew excerpt / meta description
feature_imagestringnoNew cover image URL
updated_atstringnoLast known timestamp for concurrency control

Example

-- Update post content and publish
local result = app.integrations.ghost.update_post({
  id = "64a1b2c3d4e5f6g7h8i9j0k",
  html = "<p>Updated content!</p>",
  status = "published"
})

-- Change tags and set featured
local result = app.integrations.ghost.update_post({
  id = "64a1b2c3d4e5f6g7h8i9j0k",
  tags = {"Featured", "Engineering"},
  featured = true
})

list_pages

List static pages (About, Contact, etc.).

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
limitintegernoPages per page (default: 15, max: 100)
filterstringnoGhost filter syntax
statusstringno"published" or "draft"
orderstringnoSort order
fieldsstringnoComma-separated fields to return
includestringnoRelated data: "tags", "authors"

Example

local result = app.integrations.ghost.list_pages({
  status = "published",
  limit = 50
})

for _, page in ipairs(result.pages) do
  print(page.title .. " (" .. page.slug .. ")")
end

list_members

List newsletter members.

Parameters

NameTypeRequiredDescription
pageintegernoPage number (default: 1)
limitintegernoMembers per page (default: 15, max: 100)
filterstringnoGhost filter syntax
orderstringnoSort order (default: "created_at desc")
fieldsstringnoComma-separated fields to return

Examples

-- List all subscribed members
local result = app.integrations.ghost.list_members({
  filter = "subscribed:true",
  limit = 50
})

-- Search by email domain
local result = app.integrations.ghost.list_members({
  filter = "email:@example.com"
})

for _, member in ipairs(result.members) do
  print(member.name .. " <" .. member.email .. ">")
end

get_current_user

Get the currently authenticated Ghost admin user.

Parameters

NameTypeRequiredDescription
fieldsstringnoComma-separated fields to return

Example

local result = app.integrations.ghost.get_current_user({})
local user = result.users[1]
print("Connected as: " .. user.name .. " (" .. user.email .. ")")

Multi-Account Usage

If you have multiple Ghost sites configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.ghost.list_posts({status = "published"})

-- Explicit default (portable across setups)
app.integrations.ghost.default.list_posts({status = "published"})

-- Named accounts (e.g. multiple Ghost sites)
app.integrations.ghost.blog.list_posts({tag = "news"})
app.integrations.ghost.docs.list_pages({status = "published"})

All functions are identical across accounts — only the credentials (API key and base URL) differ.

Raw agent markdown
# Ghost CMS — Lua API Reference

## list_posts

List blog posts with filtering, pagination, and ordering.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `limit` | integer | no | Posts per page (default: 15, max: 100) |
| `filter` | string | no | Ghost filter syntax (see below) |
| `tag` | string | no | Filter by tag slug, e.g. `"news"` |
| `author` | string | no | Filter by author slug, e.g. `"john"` |
| `status` | string | no | `"published"`, `"draft"`, or `"scheduled"` |
| `order` | string | no | Sort order, e.g. `"published_at desc"` |
| `fields` | string | no | Comma-separated fields to return |
| `include` | string | no | Related data to include: `"tags"`, `"authors"`, `"tags,authors"` |

### Filter Syntax

Ghost uses a simple filter language:
- **AND**: `tag:news+status:published`
- **OR**: `tag:news,tag:engineering`
- **Comparison**: `published_at:>2025-01-01`

### Examples

```lua
-- List published posts with tags and authors
local result = app.integrations.ghost.list_posts({
  status = "published",
  include = "tags,authors",
  limit = 10
})

-- Filter by tag and paginate
local result = app.integrations.ghost.list_posts({
  tag = "engineering",
  page = 2,
  limit = 20
})

-- Search with custom filter
local result = app.integrations.ghost.list_posts({
  filter = "tag:news+status:published",
  order = "published_at desc"
})
```

---

## get_post

Get a single blog post by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Post UUID |
| `fields` | string | no | Comma-separated fields to return |
| `include` | string | no | Related data: `"tags"`, `"authors"` |
| `formats` | string | no | Content format: `"html"`, `"plaintext"` |

### Example

```lua
local result = app.integrations.ghost.get_post({
  id = "64a1b2c3d4e5f6g7h8i9j0k",
  include = "tags,authors"
})

local post = result.posts[1]
print(post.title)
print(post.html)
```

---

## create_post

Create a new blog post.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `title` | string | yes | Post title |
| `html` | string | no | Post content as HTML |
| `status` | string | no | `"draft"` or `"published"` (default: `"draft"`) |
| `featured` | boolean | no | Feature this post (default: false) |
| `tags` | array | no | Tag names, e.g. `{"News", "Engineering"}` |
| `authors` | array | no | Author emails, e.g. `{"[email protected]"}` |
| `excerpt` | string | no | Custom excerpt / meta description |
| `feature_image` | string | no | URL for the cover image |

### Examples

```lua
-- Create a draft post
local result = app.integrations.ghost.create_post({
  title = "My New Post",
  html = "<p>Hello world!</p>",
  status = "draft",
  tags = {"News", "Announcement"}
})

-- Create and publish immediately
local result = app.integrations.ghost.create_post({
  title = "Breaking News",
  html = "<p>Important update...</p>",
  status = "published",
  featured = true,
  tags = {"Breaking"},
  authors = {"[email protected]"}
})
```

---

## update_post

Update an existing blog post.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | Post UUID to update |
| `title` | string | no | New title |
| `html` | string | no | New HTML content |
| `status` | string | no | `"draft"` or `"published"` |
| `featured` | boolean | no | Set/unset featured flag |
| `tags` | array | no | Replace tags (e.g. `{"Updated"}`) |
| `excerpt` | string | no | New excerpt / meta description |
| `feature_image` | string | no | New cover image URL |
| `updated_at` | string | no | Last known timestamp for concurrency control |

### Example

```lua
-- Update post content and publish
local result = app.integrations.ghost.update_post({
  id = "64a1b2c3d4e5f6g7h8i9j0k",
  html = "<p>Updated content!</p>",
  status = "published"
})

-- Change tags and set featured
local result = app.integrations.ghost.update_post({
  id = "64a1b2c3d4e5f6g7h8i9j0k",
  tags = {"Featured", "Engineering"},
  featured = true
})
```

---

## list_pages

List static pages (About, Contact, etc.).

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `limit` | integer | no | Pages per page (default: 15, max: 100) |
| `filter` | string | no | Ghost filter syntax |
| `status` | string | no | `"published"` or `"draft"` |
| `order` | string | no | Sort order |
| `fields` | string | no | Comma-separated fields to return |
| `include` | string | no | Related data: `"tags"`, `"authors"` |

### Example

```lua
local result = app.integrations.ghost.list_pages({
  status = "published",
  limit = 50
})

for _, page in ipairs(result.pages) do
  print(page.title .. " (" .. page.slug .. ")")
end
```

---

## list_members

List newsletter members.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | integer | no | Page number (default: 1) |
| `limit` | integer | no | Members per page (default: 15, max: 100) |
| `filter` | string | no | Ghost filter syntax |
| `order` | string | no | Sort order (default: `"created_at desc"`) |
| `fields` | string | no | Comma-separated fields to return |

### Examples

```lua
-- List all subscribed members
local result = app.integrations.ghost.list_members({
  filter = "subscribed:true",
  limit = 50
})

-- Search by email domain
local result = app.integrations.ghost.list_members({
  filter = "email:@example.com"
})

for _, member in ipairs(result.members) do
  print(member.name .. " <" .. member.email .. ">")
end
```

---

## get_current_user

Get the currently authenticated Ghost admin user.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `fields` | string | no | Comma-separated fields to return |

### Example

```lua
local result = app.integrations.ghost.get_current_user({})
local user = result.users[1]
print("Connected as: " .. user.name .. " (" .. user.email .. ")")
```

---

## Multi-Account Usage

If you have multiple Ghost sites configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.ghost.list_posts({status = "published"})

-- Explicit default (portable across setups)
app.integrations.ghost.default.list_posts({status = "published"})

-- Named accounts (e.g. multiple Ghost sites)
app.integrations.ghost.blog.list_posts({tag = "news"})
app.integrations.ghost.docs.list_pages({status = "published"})
```

All functions are identical across accounts — only the credentials (API key and base URL) differ.

Metadata-Derived Lua Example

local result = app.integrations.ghost.ghost_list_posts({
  page = 1,
  limit = 1,
  filter = "example_filter",
  tag = "example_tag",
  author = "example_author",
  status = "example_status",
  order = "example_order",
  fields = "example_fields"
})
print(result)

Functions

ghost_list_posts

List blog posts from Ghost CMS. Supports filtering by tag, author, status, and free-text search. Returns paginated results with post titles, slugs, status, and metadata.

Operation
Read read
Full name
ghost.ghost_list_posts
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
limit integer no Number of posts per page (default: 15, max: 100).
filter string no Ghost filter syntax, e.g. "tag:news+status:published" or "author:john". Use `+` for AND, `,` for OR.
tag string no Filter by tag slug (e.g. "news", "engineering"). Shorthand for filter "tag:{value}".
author string no Filter by author slug (e.g. "john"). Shorthand for filter "author:{value}".
status string no Filter by post status. Shorthand for filter "status:{value}".
order string no Sort order (default: "published_at desc"). Examples: "created_at desc", "title asc", "updated_at desc".
fields string no Comma-separated list of fields to return (e.g. "id,title,slug,status").
include string no Comma-separated related data to include: "tags", "authors", "tags,authors".

ghost_get_post

Get a single Ghost blog post by ID. Returns full post content, metadata, tags, and authors.

Operation
Read read
Full name
ghost.ghost_get_post
ParameterTypeRequiredDescription
id string yes The post UUID.
fields string no Comma-separated list of fields to return (e.g. "id,title,html,status").
include string no Comma-separated related data to include: "tags", "authors", "tags,authors".
formats string no Content formats to return: "html", "plaintext", "mobiledoc" (default: "html").

ghost_create_post

Create a new blog post in Ghost CMS. Supports setting title, HTML content, status (draft or published), featured flag, tags, and authors.

Operation
Write write
Full name
ghost.ghost_create_post
ParameterTypeRequiredDescription
title string yes Post title.
html string no Post content as HTML.
status string no Post status. Defaults to "draft" if not specified.
featured boolean no Whether the post is featured (default: false).
tags array no Array of tag objects or tag name strings, e.g. ["News", {"name": "Engineering"}].
authors array no Array of author objects or author email strings, e.g. ["[email protected]"].
excerpt string no Custom post excerpt / meta description.
feature_image string no URL for the featured/cover image.

ghost_update_post

Update an existing blog post in Ghost CMS. Provide the post ID and any fields to change (title, content, status, featured flag, tags).

Operation
Write write
Full name
ghost.ghost_update_post
ParameterTypeRequiredDescription
id string yes The post UUID to update.
title string no New post title.
html string no New post content as HTML.
status string no Change post status (draft or published).
featured boolean no Set or unset the featured flag.
tags array no Replace post tags. Array of tag name strings, e.g. ["News", "Engineering"].
excerpt string no New custom excerpt / meta description.
feature_image string no New featured/cover image URL.
updated_at string no Last known updated_at timestamp for optimistic concurrency control. Prevents overwriting if the post was modified since you last read it.

ghost_list_pages

List static pages from Ghost CMS. Supports filtering, pagination, and ordering. Pages are non-blog content like "About", "Contact", etc.

Operation
Read read
Full name
ghost.ghost_list_pages
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
limit integer no Number of pages per page (default: 15, max: 100).
filter string no Ghost filter syntax, e.g. "status:published" or "slug:about". Use `+` for AND, `,` for OR.
status string no Filter by page status. Shorthand for filter "status:{value}".
order string no Sort order (default: "published_at desc"). Examples: "title asc", "created_at desc".
fields string no Comma-separated list of fields to return (e.g. "id,title,slug,status").
include string no Comma-separated related data to include: "tags", "authors", "tags,authors".

ghost_list_members

List newsletter members from Ghost CMS. Supports filtering by subscription status, email search, and pagination. Returns member names, emails, labels, and subscription info.

Operation
Read read
Full name
ghost.ghost_list_members
ParameterTypeRequiredDescription
page integer no Page number (default: 1).
limit integer no Number of members per page (default: 15, max: 100).
filter string no Ghost filter syntax, e.g. "subscribed:true" or "email:@example.com". Use `+` for AND, `,` for OR.
order string no Sort order (default: "created_at desc"). Examples: "name asc", "email desc".
fields string no Comma-separated list of fields to return (e.g. "id,name,email,status").

ghost_get_current_user

Get the currently authenticated Ghost admin user. Useful for verifying API credentials and checking user role/permissions.

Operation
Read read
Full name
ghost.ghost_get_current_user
ParameterTypeRequiredDescription
fields string no Comma-separated list of fields to return (e.g. "id,name,email,role").