KosmoKrator

productivity

LinkedIn Lua API for KosmoKrator Agents

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

Lua Namespace

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

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.linkedin.list_posts({author = "example_author", count = 1, start = 1}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("linkedin"))' --json
kosmo integrations:lua --eval 'print(docs.read("linkedin.list_posts"))' --json

Workflow file

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

workflow.lua
local linkedin = app.integrations.linkedin
local result = linkedin.list_posts({author = "example_author", count = 1, start = 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.linkedin, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.linkedin.default.* or app.integrations.linkedin.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need LinkedIn, 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 LinkedIn REST API v2 covering posts, organizations, and ad accounts — Lua API Reference

linkedin_list_posts

List LinkedIn UGC posts for an author. Returns post IDs, lifecycle state, and creation timestamps. Use author, count, and start for filtering and pagination.

Parameters

NameTypeRequiredDescription
authorstringyesAuthor URN (e.g. “urn:li:person:ABC123” or “urn:li:organization:12345”).
countintegernoMaximum number of posts to return (default 10, max 100).
startintegernoPagination offset (0-based).

Example

local result = app.integrations.linkedin.linkedin_list_posts({
  author = "urn:li:person:ABC123"
  count = 10
  start = 0
})

linkedin_get_post

Retrieve a LinkedIn UGC post by its ID. Returns the full post including content, lifecycle state, and visibility.

Parameters

NameTypeRequiredDescription
post_idstringyesLinkedIn UGC post URN or ID (e.g. “urn:li:ugcPost:123456789”).

Example

local result = app.integrations.linkedin.linkedin_get_post({
  post_id = "urn:li:ugcPost:123456789"
})

linkedin_create_post

Create a new LinkedIn UGC post. Requires an author URN and text content. Returns the created post with its ID and lifecycle state.

Parameters

NameTypeRequiredDescription
authorstringyesAuthor URN (e.g. “urn:li:person:ABC123” or “urn:li:organization:12345”).
textstringyesText content for the post.
visibilitystringnoVisibility: “PUBLIC” (default) or “CONNECTIONS”.

Example

local result = app.integrations.linkedin.linkedin_create_post({
  author = "urn:li:person:ABC123"
  text = "Hello from the LinkedIn API!"
  visibility = "PUBLIC"
})

linkedin_list_organizations

List LinkedIn organizations (company pages) the authenticated user has access to. Returns organization IDs, names, and roles.

Parameters

NameTypeRequiredDescription
countintegernoMaximum number of organizations to return (default 10).
startintegernoPagination offset (0-based).

Example

local result = app.integrations.linkedin.linkedin_list_organizations({
  count = 10
  start = 0
})

linkedin_get_organization

Retrieve a LinkedIn organization (company page) by its ID. Returns the organization’s name, description, website, and other profile data.

Parameters

NameTypeRequiredDescription
organization_idstringyesLinkedIn organization ID or URN (e.g. “12345” or “urn:li:organization:12345”).

Example

local result = app.integrations.linkedin.linkedin_get_organization({
  organization_id = "12345"
})

linkedin_list_ad_accounts

List LinkedIn ad accounts the authenticated user has access to. Returns ad account IDs, names, statuses, and currency information.

Parameters

NameTypeRequiredDescription
countintegernoMaximum number of ad accounts to return (default 10).
startintegernoPagination offset (0-based).

Example

local result = app.integrations.linkedin.linkedin_list_ad_accounts({
  count = 10
  start = 0
})

linkedin_get_current_user

Retrieve the currently authenticated LinkedIn user profile. Returns the user’s ID, localized name, and profile metadata. Useful for identifying which account or token is in use.

Example

local result = app.integrations.linkedin.linkedin_get_current_user({
})

Multi-Account Usage

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

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

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

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

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

Raw agent markdown
# Client for the LinkedIn REST API v2 covering posts, organizations, and ad accounts — Lua API Reference

## linkedin_list_posts

List LinkedIn UGC posts for an author.
Returns post IDs, lifecycle state, and creation timestamps.
Use author, count, and start for filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `author` | string | yes | Author URN (e.g. "urn:li:person:ABC123" or "urn:li:organization:12345"). |
| `count` | integer | no | Maximum number of posts to return (default 10, max 100). |
| `start` | integer | no | Pagination offset (0-based). |

### Example

```lua
local result = app.integrations.linkedin.linkedin_list_posts({
  author = "urn:li:person:ABC123"
  count = 10
  start = 0
})
```

## linkedin_get_post

Retrieve a LinkedIn UGC post by its ID.
Returns the full post including content, lifecycle state, and visibility.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `post_id` | string | yes | LinkedIn UGC post URN or ID (e.g. "urn:li:ugcPost:123456789"). |

### Example

```lua
local result = app.integrations.linkedin.linkedin_get_post({
  post_id = "urn:li:ugcPost:123456789"
})
```

## linkedin_create_post

Create a new LinkedIn UGC post.
Requires an author URN and text content.
Returns the created post with its ID and lifecycle state.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `author` | string | yes | Author URN (e.g. "urn:li:person:ABC123" or "urn:li:organization:12345"). |
| `text` | string | yes | Text content for the post. |
| `visibility` | string | no | Visibility: "PUBLIC" (default) or "CONNECTIONS". |

### Example

```lua
local result = app.integrations.linkedin.linkedin_create_post({
  author = "urn:li:person:ABC123"
  text = "Hello from the LinkedIn API!"
  visibility = "PUBLIC"
})
```

## linkedin_list_organizations

List LinkedIn organizations (company pages) the authenticated user has access to.
Returns organization IDs, names, and roles.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `count` | integer | no | Maximum number of organizations to return (default 10). |
| `start` | integer | no | Pagination offset (0-based). |

### Example

```lua
local result = app.integrations.linkedin.linkedin_list_organizations({
  count = 10
  start = 0
})
```

## linkedin_get_organization

Retrieve a LinkedIn organization (company page) by its ID.
Returns the organization's name, description, website, and other profile data.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `organization_id` | string | yes | LinkedIn organization ID or URN (e.g. "12345" or "urn:li:organization:12345"). |

### Example

```lua
local result = app.integrations.linkedin.linkedin_get_organization({
  organization_id = "12345"
})
```

## linkedin_list_ad_accounts

List LinkedIn ad accounts the authenticated user has access to.
Returns ad account IDs, names, statuses, and currency information.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `count` | integer | no | Maximum number of ad accounts to return (default 10). |
| `start` | integer | no | Pagination offset (0-based). |

### Example

```lua
local result = app.integrations.linkedin.linkedin_list_ad_accounts({
  count = 10
  start = 0
})
```

## linkedin_get_current_user

Retrieve the currently authenticated LinkedIn user profile.
Returns the user's ID, localized name, and profile metadata.
Useful for identifying which account or token is in use.

### Example

```lua
local result = app.integrations.linkedin.linkedin_get_current_user({
})
```

---

## Multi-Account Usage

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

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

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

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

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.linkedin.list_posts({author = "example_author", count = 1, start = 1})
print(result)

Functions

list_posts Read

List LinkedIn UGC posts for an author. Returns post IDs, lifecycle state, and creation timestamps. Use author, count, and start for filtering and pagination.

Lua path
app.integrations.linkedin.list_posts
Full name
linkedin.linkedin_list_posts
ParameterTypeRequiredDescription
author string yes Author URN (e.g. "urn:li:person:ABC123" or "urn:li:organization:12345").
count integer no Maximum number of posts to return (default 10, max 100).
start integer no Pagination offset (0-based).
get_post Read

Retrieve a LinkedIn UGC post by its ID. Returns the full post including content, lifecycle state, and visibility.

Lua path
app.integrations.linkedin.get_post
Full name
linkedin.linkedin_get_post
ParameterTypeRequiredDescription
post_id string yes LinkedIn UGC post URN or ID (e.g. "urn:li:ugcPost:123456789").
create_post Write

Create a new LinkedIn UGC post. Requires an author URN and text content. Returns the created post with its ID and lifecycle state.

Lua path
app.integrations.linkedin.create_post
Full name
linkedin.linkedin_create_post
ParameterTypeRequiredDescription
author string yes Author URN (e.g. "urn:li:person:ABC123" or "urn:li:organization:12345").
text string yes Text content for the post.
visibility string no Visibility: "PUBLIC" (default) or "CONNECTIONS".
list_organizations Read

List LinkedIn organizations (company pages) the authenticated user has access to. Returns organization IDs, names, and roles.

Lua path
app.integrations.linkedin.list_organizations
Full name
linkedin.linkedin_list_organizations
ParameterTypeRequiredDescription
count integer no Maximum number of organizations to return (default 10).
start integer no Pagination offset (0-based).
get_organization Read

Retrieve a LinkedIn organization (company page) by its ID. Returns the organization's name, description, website, and other profile data.

Lua path
app.integrations.linkedin.get_organization
Full name
linkedin.linkedin_get_organization
ParameterTypeRequiredDescription
organization_id string yes LinkedIn organization ID or URN (e.g. "12345" or "urn:li:organization:12345").
list_ad_accounts Read

List LinkedIn ad accounts the authenticated user has access to. Returns ad account IDs, names, statuses, and currency information.

Lua path
app.integrations.linkedin.list_ad_accounts
Full name
linkedin.linkedin_list_ad_accounts
ParameterTypeRequiredDescription
count integer no Maximum number of ad accounts to return (default 10).
start integer no Pagination offset (0-based).
get_current_user Read

Retrieve the currently authenticated LinkedIn user profile. Returns the user's ID, localized name, and profile metadata. Useful for identifying which account or token is in use.

Lua path
app.integrations.linkedin.get_current_user
Full name
linkedin.linkedin_get_current_user
ParameterTypeRequiredDescription
No parameters.