KosmoKrator

productivity

Later Lua API for KosmoKrator Agents

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

Lua Namespace

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

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

Workflow file

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

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

MCP-only Lua

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

Later — Lua API Reference

list_profiles

List all social media profiles connected to the Later account.

Parameters

NameTypeRequiredDescription
limitintegernoNumber of profiles to return per page
pageintegernoPage number for pagination

Example

local result = app.integrations.later.list_profiles()

for _, profile in ipairs(result.data) do
  print(profile.id .. ": " .. profile.platform .. " (" .. profile.username .. ")")
end

get_profile

Get details of a specific social profile.

Parameters

NameTypeRequiredDescription
profileIdstringyesThe social profile ID

Example

local result = app.integrations.later.get_profile({
  profileId = "abc123"
})
print(result.platform)
print(result.username)

list_posts

List scheduled and published posts.

Parameters

NameTypeRequiredDescription
profileIdstringnoFilter posts by profile ID
statusstringnoFilter by status: “scheduled”, “published”, or “draft”
limitintegernoNumber of posts to return per page
pageintegernoPage number for pagination

Example

local result = app.integrations.later.list_posts({
  status = "scheduled",
  limit = 20,
  page = 1
})

for _, post in ipairs(result.data) do
  print(post.id .. ": " .. post.text .. " @ " .. post.scheduled_at)
end

create_post

Create and schedule a new social media post.

Parameters

NameTypeRequiredDescription
textstringyesThe caption or text content of the post
profileIdsarrayyesProfile IDs to publish the post to
scheduledAtstringnoISO 8601 timestamp (e.g., "2025-02-01T09:00:00Z")
mediaUrlstringnoURL of the media to attach
mediaTypestringnoType of media: “image” or “video”
titlestringnoOptional title for the post

Example

local result = app.integrations.later.create_post({
  text = "Check out our latest blog post! https://example.com/blog",
  profileIds = {"abc123", "def456"},
  scheduledAt = "2025-02-01T09:00:00Z",
  mediaUrl = "https://example.com/image.jpg",
  mediaType = "image"
})
print("Created post: " .. result.id)

list_media

List media items in the Later media library.

Parameters

NameTypeRequiredDescription
limitintegernoNumber of items to return per page
pageintegernoPage number for pagination
typestringnoFilter by type: “image” or “video”

Example

local result = app.integrations.later.list_media({
  type = "image",
  limit = 10
})

for _, item in ipairs(result.data) do
  print(item.id .. ": " .. item.url)
end

get_media

Get details of a specific media item by ID.

Parameters

NameTypeRequiredDescription
mediaIdstringyesThe media item ID to retrieve

Example

local result = app.integrations.later.get_media({
  mediaId = "media_abc123"
})
print(result.url)
print(result.type)

get_current_user

Get the currently authenticated Later user profile.

Parameters

None.

Example

local result = app.integrations.later.get_current_user()
print("Logged in as: " .. (result.name or ""))
print("Email: " .. (result.email or ""))

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.later.client_acct.function_name({...})
app.integrations.later.agency.function_name({...})

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

Raw agent markdown
# Later — Lua API Reference

## list_profiles

List all social media profiles connected to the Later account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of profiles to return per page |
| `page` | integer | no | Page number for pagination |

### Example

```lua
local result = app.integrations.later.list_profiles()

for _, profile in ipairs(result.data) do
  print(profile.id .. ": " .. profile.platform .. " (" .. profile.username .. ")")
end
```

---

## get_profile

Get details of a specific social profile.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `profileId` | string | yes | The social profile ID |

### Example

```lua
local result = app.integrations.later.get_profile({
  profileId = "abc123"
})
print(result.platform)
print(result.username)
```

---

## list_posts

List scheduled and published posts.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `profileId` | string | no | Filter posts by profile ID |
| `status` | string | no | Filter by status: "scheduled", "published", or "draft" |
| `limit` | integer | no | Number of posts to return per page |
| `page` | integer | no | Page number for pagination |

### Example

```lua
local result = app.integrations.later.list_posts({
  status = "scheduled",
  limit = 20,
  page = 1
})

for _, post in ipairs(result.data) do
  print(post.id .. ": " .. post.text .. " @ " .. post.scheduled_at)
end
```

---

## create_post

Create and schedule a new social media post.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `text` | string | yes | The caption or text content of the post |
| `profileIds` | array | yes | Profile IDs to publish the post to |
| `scheduledAt` | string | no | ISO 8601 timestamp (e.g., `"2025-02-01T09:00:00Z"`) |
| `mediaUrl` | string | no | URL of the media to attach |
| `mediaType` | string | no | Type of media: "image" or "video" |
| `title` | string | no | Optional title for the post |

### Example

```lua
local result = app.integrations.later.create_post({
  text = "Check out our latest blog post! https://example.com/blog",
  profileIds = {"abc123", "def456"},
  scheduledAt = "2025-02-01T09:00:00Z",
  mediaUrl = "https://example.com/image.jpg",
  mediaType = "image"
})
print("Created post: " .. result.id)
```

---

## list_media

List media items in the Later media library.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of items to return per page |
| `page` | integer | no | Page number for pagination |
| `type` | string | no | Filter by type: "image" or "video" |

### Example

```lua
local result = app.integrations.later.list_media({
  type = "image",
  limit = 10
})

for _, item in ipairs(result.data) do
  print(item.id .. ": " .. item.url)
end
```

---

## get_media

Get details of a specific media item by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `mediaId` | string | yes | The media item ID to retrieve |

### Example

```lua
local result = app.integrations.later.get_media({
  mediaId = "media_abc123"
})
print(result.url)
print(result.type)
```

---

## get_current_user

Get the currently authenticated Later user profile.

### Parameters

None.

### Example

```lua
local result = app.integrations.later.get_current_user()
print("Logged in as: " .. (result.name or ""))
print("Email: " .. (result.email or ""))
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.later.client_acct.function_name({...})
app.integrations.later.agency.function_name({...})
```

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

Functions

list_profiles Read

List all social media profiles connected to the Later account. Returns profile IDs, platform types, and display names.

Lua path
app.integrations.later.list_profiles
Full name
later.later_list_profiles
ParameterTypeRequiredDescription
limit integer no Number of profiles to return per page.
page integer no Page number for pagination.
get_profile Read

Get details of a specific social media profile in Later by its ID. Returns profile platform type, display name, and account metadata.

Lua path
app.integrations.later.get_profile
Full name
later.later_get_profile
ParameterTypeRequiredDescription
profileId string yes The social profile ID to retrieve.
list_posts Read

List scheduled and published posts in Later. Optionally filter by profile ID, status (scheduled, published, draft), and paginate results.

Lua path
app.integrations.later.list_posts
Full name
later.later_list_posts
ParameterTypeRequiredDescription
profileId string no Filter posts by a specific social profile ID.
status string no Filter by post status: "scheduled", "published", or "draft".
limit integer no Number of posts to return per page.
page integer no Page number for pagination.
create_post Write

Create and schedule a new social media post in Later. Provide the caption text, target profile IDs, and optionally a scheduled time or media URL.

Lua path
app.integrations.later.create_post
Full name
later.later_create_post
ParameterTypeRequiredDescription
text string yes The caption or text content of the post.
profileIds array yes Array of Later profile IDs to publish the post to.
scheduledAt string no ISO 8601 timestamp for when the post should be published (e.g., "2025-02-01T09:00:00Z").
mediaUrl string no URL of the media (image or video) to attach to the post.
mediaType string no Type of media: "image" or "video".
title string no Optional title for the post.
list_media Read

List media items in the Later media library. Returns media IDs, URLs, types, and metadata. Optionally filter by media type.

Lua path
app.integrations.later.list_media
Full name
later.later_list_media
ParameterTypeRequiredDescription
limit integer no Number of media items to return per page.
page integer no Page number for pagination.
type string no Filter by media type: "image" or "video".
get_media Read

Get details of a specific media item in Later by its ID. Returns the media URL, type, dimensions, and metadata.

Lua path
app.integrations.later.get_media
Full name
later.later_get_media
ParameterTypeRequiredDescription
mediaId string yes The media item ID to retrieve.
get_current_user Read

Get the currently authenticated Later user profile. Returns the user name, email, and account info.

Lua path
app.integrations.later.get_current_user
Full name
later.later_get_current_user
ParameterTypeRequiredDescription
No parameters.