KosmoKrator

productivity

LaunchDarkly Lua API for KosmoKrator Agents

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

Lua Namespace

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

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.launchdarkly.api_get({}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("launchdarkly"))' --json
kosmo integrations:lua --eval 'print(docs.read("launchdarkly.api_get"))' --json

Workflow file

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

workflow.lua
local launchdarkly = app.integrations.launchdarkly
local result = launchdarkly.api_get({})

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.launchdarkly, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.launchdarkly.default.* or app.integrations.launchdarkly.work.* when you configured named credential accounts.

MCP-only Lua

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

LaunchDarkly Lua API Reference

Namespace: app.integrations.launchdarkly

This integration manages LaunchDarkly projects, environments, feature flags, segments, account members, and teams through the LaunchDarkly REST API. The typed tools cover common release-management workflows. The raw API tools expose the rest of /api/v2 for newer or less common endpoints.

LaunchDarkly PATCH endpoints often expect JSON Patch arrays. Feature flags and teams may also accept semantic patch bodies for specific workflows. When in doubt, use the exact patch format from the LaunchDarkly API docs.

Raw API Helpers

Use these when a LaunchDarkly endpoint is not covered by a first-class tool:

ToolMethodNotes
api_getGETAccepts path and optional query
api_postPOSTAccepts path, body, and optional query
api_patchPATCHAccepts path, patch or body, and optional query
api_putPUTAccepts path, body, and optional query
api_deleteDELETEAccepts path, optional body, and optional query
local projects = app.integrations.launchdarkly.api_get({
  path = "/projects",
  query = { limit = 20 }
})

local flag = app.integrations.launchdarkly.api_get({
  path = "/flags/default/checkout-flow"
})

Projects

ToolPurpose
list_projectsList projects with normalized keys, names, tags, and environment counts
get_projectGet a normalized project summary
create_projectCreate a project
update_projectPatch a project with JSON Patch
delete_projectDelete a project
local created = app.integrations.launchdarkly.create_project({
  key = "web-app",
  name = "Web App",
  tags = { "example" }
})

local updated = app.integrations.launchdarkly.update_project({
  project_key = "web-app",
  patch = {
    { op = "replace", path = "/name", value = "Web Application" }
  }
})

Deleting a project also deletes associated environments and flags. LaunchDarkly does not allow deleting the last project in an account.

Environments

ToolPurpose
list_environmentsList normalized environments for a project
get_environmentGet one environment
create_environmentCreate an environment
update_environmentPatch an environment with JSON Patch
delete_environmentDelete an environment
local env = app.integrations.launchdarkly.create_environment({
  project_key = "web-app",
  key = "qa",
  name = "QA",
  color = "DADBEE",
  requireComments = true
})

Feature Flags

ToolPurpose
list_flagsList normalized flags and per-environment on/off states
get_flagGet a normalized flag summary with variations and environment rules
create_feature_flagCreate a flag
update_feature_flagPatch a flag
toggle_flagTurn a flag on or off for one environment
copy_feature_flagCopy flag settings between environments
delete_feature_flagDelete a flag
local flags = app.integrations.launchdarkly.list_flags({
  project_key = "web-app",
  env = "production",
  limit = 50
})

local flag = app.integrations.launchdarkly.create_feature_flag({
  project_key = "web-app",
  key = "checkout-flow",
  name = "Checkout Flow",
  kind = "boolean",
  temporary = true,
  tags = { "release" }
})

local toggled = app.integrations.launchdarkly.toggle_flag({
  project_key = "web-app",
  feature_flag_key = "checkout-flow",
  environment_key = "production",
  enabled = true
})

For advanced flag changes, update_feature_flag accepts either a JSON Patch list or a semantic patch-style body:

local patched = app.integrations.launchdarkly.update_feature_flag({
  project_key = "web-app",
  feature_flag_key = "checkout-flow",
  patch = {
    { op = "replace", path = "/environments/production/on", value = false }
  }
})

local semantic = app.integrations.launchdarkly.update_feature_flag({
  project_key = "web-app",
  feature_flag_key = "checkout-flow",
  body = {
    environmentKey = "production",
    instructions = {
      { kind = "turnFlagOn" }
    }
  }
})

The host currently sends normal JSON content headers. If a LaunchDarkly semantic patch requires the specialized semantic-patch content type in your account, use api_patch only after the host gains custom header support or fall back to JSON Patch.

Segments

ToolPurpose
list_segmentsList segments for a project environment
get_segmentGet one segment
create_segmentCreate a rule-based, list-based, or big segment
update_segmentPatch a segment
delete_segmentDelete a segment
local segment = app.integrations.launchdarkly.create_segment({
  project_key = "web-app",
  environment_key = "production",
  key = "beta-users",
  name = "Beta Users",
  tags = { "example" }
})

Big segments and synced segments can be Enterprise-only in LaunchDarkly. The API may reject those operations depending on the account plan.

Members

ToolPurpose
get_current_userGet the authenticated member
list_membersList account members
get_memberGet one member by _id
invite_membersInvite one or more members
update_memberPatch a member
delete_memberRemove a member
local members = app.integrations.launchdarkly.list_members({
  limit = 20,
  filter = "query:alex"
})

local invited = app.integrations.launchdarkly.invite_members({
  body = {
    {
      email = "person@example.test",
      role = "reader"
    }
  }
})

Use member IDs from the _id field returned by list_members or invite_members.

Teams

ToolPurpose
list_teamsList teams with optional expansions
get_teamGet one team
create_teamCreate a team
update_teamPatch a team
delete_teamDelete a team
local teams = app.integrations.launchdarkly.list_teams({
  filter = "query:platform",
  expand = "members,maintainers"
})

local team = app.integrations.launchdarkly.create_team({
  key = "platform",
  name = "Platform",
  description = "Platform engineering"
})

Teams are an Enterprise feature in LaunchDarkly. Non-Enterprise accounts may receive permission or plan errors.

Normalized Versus Raw Output

The legacy convenience tools list_projects, get_project, list_environments, list_flags, get_flag, toggle_flag, and get_current_user return smaller normalized payloads for agent workflows.

The newer endpoint-mapped tools return LaunchDarkly’s parsed JSON response directly. For DELETE endpoints that return 204 No Content, the tool returns an empty object.

Multi-Account Usage

If multiple LaunchDarkly accounts are configured, use account-specific namespaces:

local result = app.integrations.launchdarkly.accounts.production.list_flags({
  project_key = "web-app",
  env = "production"
})

Safety Notes

  • Use example.test or other dummy values in generated examples and tests.
  • Delete operations are destructive and may remove environments, flags, project data, members, or teams.
  • LaunchDarkly API tokens are sent as the Authorization header value exactly as configured.
Raw agent markdown
# LaunchDarkly Lua API Reference

Namespace: `app.integrations.launchdarkly`

This integration manages LaunchDarkly projects, environments, feature flags, segments, account members, and teams through the LaunchDarkly REST API. The typed tools cover common release-management workflows. The raw API tools expose the rest of `/api/v2` for newer or less common endpoints.

LaunchDarkly PATCH endpoints often expect JSON Patch arrays. Feature flags and teams may also accept semantic patch bodies for specific workflows. When in doubt, use the exact patch format from the LaunchDarkly API docs.

## Raw API Helpers

Use these when a LaunchDarkly endpoint is not covered by a first-class tool:

| Tool | Method | Notes |
|------|--------|-------|
| `api_get` | GET | Accepts `path` and optional `query` |
| `api_post` | POST | Accepts `path`, `body`, and optional `query` |
| `api_patch` | PATCH | Accepts `path`, `patch` or `body`, and optional `query` |
| `api_put` | PUT | Accepts `path`, `body`, and optional `query` |
| `api_delete` | DELETE | Accepts `path`, optional `body`, and optional `query` |

```lua
local projects = app.integrations.launchdarkly.api_get({
  path = "/projects",
  query = { limit = 20 }
})

local flag = app.integrations.launchdarkly.api_get({
  path = "/flags/default/checkout-flow"
})
```

## Projects

| Tool | Purpose |
|------|---------|
| `list_projects` | List projects with normalized keys, names, tags, and environment counts |
| `get_project` | Get a normalized project summary |
| `create_project` | Create a project |
| `update_project` | Patch a project with JSON Patch |
| `delete_project` | Delete a project |

```lua
local created = app.integrations.launchdarkly.create_project({
  key = "web-app",
  name = "Web App",
  tags = { "example" }
})

local updated = app.integrations.launchdarkly.update_project({
  project_key = "web-app",
  patch = {
    { op = "replace", path = "/name", value = "Web Application" }
  }
})
```

Deleting a project also deletes associated environments and flags. LaunchDarkly does not allow deleting the last project in an account.

## Environments

| Tool | Purpose |
|------|---------|
| `list_environments` | List normalized environments for a project |
| `get_environment` | Get one environment |
| `create_environment` | Create an environment |
| `update_environment` | Patch an environment with JSON Patch |
| `delete_environment` | Delete an environment |

```lua
local env = app.integrations.launchdarkly.create_environment({
  project_key = "web-app",
  key = "qa",
  name = "QA",
  color = "DADBEE",
  requireComments = true
})
```

## Feature Flags

| Tool | Purpose |
|------|---------|
| `list_flags` | List normalized flags and per-environment on/off states |
| `get_flag` | Get a normalized flag summary with variations and environment rules |
| `create_feature_flag` | Create a flag |
| `update_feature_flag` | Patch a flag |
| `toggle_flag` | Turn a flag on or off for one environment |
| `copy_feature_flag` | Copy flag settings between environments |
| `delete_feature_flag` | Delete a flag |

```lua
local flags = app.integrations.launchdarkly.list_flags({
  project_key = "web-app",
  env = "production",
  limit = 50
})

local flag = app.integrations.launchdarkly.create_feature_flag({
  project_key = "web-app",
  key = "checkout-flow",
  name = "Checkout Flow",
  kind = "boolean",
  temporary = true,
  tags = { "release" }
})

local toggled = app.integrations.launchdarkly.toggle_flag({
  project_key = "web-app",
  feature_flag_key = "checkout-flow",
  environment_key = "production",
  enabled = true
})
```

For advanced flag changes, `update_feature_flag` accepts either a JSON Patch list or a semantic patch-style body:

```lua
local patched = app.integrations.launchdarkly.update_feature_flag({
  project_key = "web-app",
  feature_flag_key = "checkout-flow",
  patch = {
    { op = "replace", path = "/environments/production/on", value = false }
  }
})

local semantic = app.integrations.launchdarkly.update_feature_flag({
  project_key = "web-app",
  feature_flag_key = "checkout-flow",
  body = {
    environmentKey = "production",
    instructions = {
      { kind = "turnFlagOn" }
    }
  }
})
```

The host currently sends normal JSON content headers. If a LaunchDarkly semantic patch requires the specialized semantic-patch content type in your account, use `api_patch` only after the host gains custom header support or fall back to JSON Patch.

## Segments

| Tool | Purpose |
|------|---------|
| `list_segments` | List segments for a project environment |
| `get_segment` | Get one segment |
| `create_segment` | Create a rule-based, list-based, or big segment |
| `update_segment` | Patch a segment |
| `delete_segment` | Delete a segment |

```lua
local segment = app.integrations.launchdarkly.create_segment({
  project_key = "web-app",
  environment_key = "production",
  key = "beta-users",
  name = "Beta Users",
  tags = { "example" }
})
```

Big segments and synced segments can be Enterprise-only in LaunchDarkly. The API may reject those operations depending on the account plan.

## Members

| Tool | Purpose |
|------|---------|
| `get_current_user` | Get the authenticated member |
| `list_members` | List account members |
| `get_member` | Get one member by `_id` |
| `invite_members` | Invite one or more members |
| `update_member` | Patch a member |
| `delete_member` | Remove a member |

```lua
local members = app.integrations.launchdarkly.list_members({
  limit = 20,
  filter = "query:alex"
})

local invited = app.integrations.launchdarkly.invite_members({
  body = {
    {
      email = "person@example.test",
      role = "reader"
    }
  }
})
```

Use member IDs from the `_id` field returned by `list_members` or `invite_members`.

## Teams

| Tool | Purpose |
|------|---------|
| `list_teams` | List teams with optional expansions |
| `get_team` | Get one team |
| `create_team` | Create a team |
| `update_team` | Patch a team |
| `delete_team` | Delete a team |

```lua
local teams = app.integrations.launchdarkly.list_teams({
  filter = "query:platform",
  expand = "members,maintainers"
})

local team = app.integrations.launchdarkly.create_team({
  key = "platform",
  name = "Platform",
  description = "Platform engineering"
})
```

Teams are an Enterprise feature in LaunchDarkly. Non-Enterprise accounts may receive permission or plan errors.

## Normalized Versus Raw Output

The legacy convenience tools `list_projects`, `get_project`, `list_environments`, `list_flags`, `get_flag`, `toggle_flag`, and `get_current_user` return smaller normalized payloads for agent workflows.

The newer endpoint-mapped tools return LaunchDarkly's parsed JSON response directly. For DELETE endpoints that return `204 No Content`, the tool returns an empty object.

## Multi-Account Usage

If multiple LaunchDarkly accounts are configured, use account-specific namespaces:

```lua
local result = app.integrations.launchdarkly.accounts.production.list_flags({
  project_key = "web-app",
  env = "production"
})
```

## Safety Notes

- Use `example.test` or other dummy values in generated examples and tests.
- Delete operations are destructive and may remove environments, flags, project data, members, or teams.
- LaunchDarkly API tokens are sent as the `Authorization` header value exactly as configured.
Metadata-derived Lua example
local result = app.integrations.launchdarkly.api_get({})
print(result)

Functions

api_get Read

Call any LaunchDarkly GET endpoint.

Lua path
app.integrations.launchdarkly.api_get
Full name
launchdarkly.launchdarkly_api_get
ParameterTypeRequiredDescription
No parameters.
api_post Write

Call any LaunchDarkly POST endpoint.

Lua path
app.integrations.launchdarkly.api_post
Full name
launchdarkly.launchdarkly_api_post
ParameterTypeRequiredDescription
No parameters.
api_patch Write

Call any LaunchDarkly PATCH endpoint.

Lua path
app.integrations.launchdarkly.api_patch
Full name
launchdarkly.launchdarkly_api_patch
ParameterTypeRequiredDescription
No parameters.
api_put Write

Call any LaunchDarkly PUT endpoint.

Lua path
app.integrations.launchdarkly.api_put
Full name
launchdarkly.launchdarkly_api_put
ParameterTypeRequiredDescription
No parameters.
api_delete Write

Call any LaunchDarkly DELETE endpoint.

Lua path
app.integrations.launchdarkly.api_delete
Full name
launchdarkly.launchdarkly_api_delete
ParameterTypeRequiredDescription
No parameters.
list_projects Read

List all LaunchDarkly projects. Returns project keys, names, and the number of environments in each project.

Lua path
app.integrations.launchdarkly.list_projects
Full name
launchdarkly.launchdarkly_list_projects
ParameterTypeRequiredDescription
No parameters.
get_project Read

Get detailed information about a specific LaunchDarkly project, including its environments and settings.

Lua path
app.integrations.launchdarkly.get_project
Full name
launchdarkly.launchdarkly_get_project
ParameterTypeRequiredDescription
project_key string yes The project key (e.g., "default", "my-backend-project").
create_project Write

Create a LaunchDarkly project.

Lua path
app.integrations.launchdarkly.create_project
Full name
launchdarkly.launchdarkly_create_project
ParameterTypeRequiredDescription
No parameters.
update_project Write

Update a LaunchDarkly project with JSON Patch.

Lua path
app.integrations.launchdarkly.update_project
Full name
launchdarkly.launchdarkly_update_project
ParameterTypeRequiredDescription
No parameters.
delete_project Write

Delete a LaunchDarkly project.

Lua path
app.integrations.launchdarkly.delete_project
Full name
launchdarkly.launchdarkly_delete_project
ParameterTypeRequiredDescription
No parameters.
list_environments Read

List all environments for a LaunchDarkly project. Returns environment keys, names, and their SDK keys for reference.

Lua path
app.integrations.launchdarkly.list_environments
Full name
launchdarkly.launchdarkly_list_environments
ParameterTypeRequiredDescription
project_key string no The project key (defaults to the configured project).
get_environment Read

Get a LaunchDarkly environment.

Lua path
app.integrations.launchdarkly.get_environment
Full name
launchdarkly.launchdarkly_get_environment
ParameterTypeRequiredDescription
No parameters.
create_environment Write

Create a LaunchDarkly environment.

Lua path
app.integrations.launchdarkly.create_environment
Full name
launchdarkly.launchdarkly_create_environment
ParameterTypeRequiredDescription
No parameters.
update_environment Write

Update a LaunchDarkly environment.

Lua path
app.integrations.launchdarkly.update_environment
Full name
launchdarkly.launchdarkly_update_environment
ParameterTypeRequiredDescription
No parameters.
delete_environment Write

Delete a LaunchDarkly environment.

Lua path
app.integrations.launchdarkly.delete_environment
Full name
launchdarkly.launchdarkly_delete_environment
ParameterTypeRequiredDescription
No parameters.
list_flags Read

List feature flags in a LaunchDarkly project. Returns flag keys, names, descriptions, and their on/off state per environment.

Lua path
app.integrations.launchdarkly.list_flags
Full name
launchdarkly.launchdarkly_list_flags
ParameterTypeRequiredDescription
project_key string no The project key (defaults to the configured project).
limit integer no Maximum number of flags to return (default: 20, max: 100).
offset integer no Offset for pagination (default: 0).
env string no Environment key to filter results (e.g., "production", "staging").
get_flag Read

Get detailed information about a specific LaunchDarkly feature flag, including targeting rules, variations, and per-environment state.

Lua path
app.integrations.launchdarkly.get_flag
Full name
launchdarkly.launchdarkly_get_flag
ParameterTypeRequiredDescription
feature_flag_key string yes The feature flag key (e.g., "enable-new-dashboard").
project_key string no The project key (defaults to the configured project).
env string no Environment key to filter results (e.g., "production", "staging").
create_feature_flag Write

Create a LaunchDarkly feature flag.

Lua path
app.integrations.launchdarkly.create_feature_flag
Full name
launchdarkly.launchdarkly_create_feature_flag
ParameterTypeRequiredDescription
No parameters.
update_feature_flag Write

Update a LaunchDarkly feature flag.

Lua path
app.integrations.launchdarkly.update_feature_flag
Full name
launchdarkly.launchdarkly_update_feature_flag
ParameterTypeRequiredDescription
No parameters.
toggle_flag Write

Turn a LaunchDarkly feature flag on or off in a specific environment. Use this to enable or disable a feature flag.

Lua path
app.integrations.launchdarkly.toggle_flag
Full name
launchdarkly.launchdarkly_toggle_flag
ParameterTypeRequiredDescription
feature_flag_key string yes The feature flag key (e.g., "enable-new-dashboard").
enabled boolean yes Set to true to turn the flag on, false to turn it off.
environment_key string yes The environment key (e.g., "production", "staging", "development").
project_key string no The project key (defaults to the configured project).
copy_feature_flag Write

Copy feature flag settings between environments.

Lua path
app.integrations.launchdarkly.copy_feature_flag
Full name
launchdarkly.launchdarkly_copy_feature_flag
ParameterTypeRequiredDescription
No parameters.
delete_feature_flag Write

Delete a LaunchDarkly feature flag.

Lua path
app.integrations.launchdarkly.delete_feature_flag
Full name
launchdarkly.launchdarkly_delete_feature_flag
ParameterTypeRequiredDescription
No parameters.
list_segments Read

List segments in a LaunchDarkly environment.

Lua path
app.integrations.launchdarkly.list_segments
Full name
launchdarkly.launchdarkly_list_segments
ParameterTypeRequiredDescription
No parameters.
get_segment Read

Get a LaunchDarkly segment.

Lua path
app.integrations.launchdarkly.get_segment
Full name
launchdarkly.launchdarkly_get_segment
ParameterTypeRequiredDescription
No parameters.
create_segment Write

Create a LaunchDarkly segment.

Lua path
app.integrations.launchdarkly.create_segment
Full name
launchdarkly.launchdarkly_create_segment
ParameterTypeRequiredDescription
No parameters.
update_segment Write

Update a LaunchDarkly segment.

Lua path
app.integrations.launchdarkly.update_segment
Full name
launchdarkly.launchdarkly_update_segment
ParameterTypeRequiredDescription
No parameters.
delete_segment Write

Delete a LaunchDarkly segment.

Lua path
app.integrations.launchdarkly.delete_segment
Full name
launchdarkly.launchdarkly_delete_segment
ParameterTypeRequiredDescription
No parameters.
get_current_user Read

Get information about the currently authenticated LaunchDarkly user. Useful for verifying API credentials.

Lua path
app.integrations.launchdarkly.get_current_user
Full name
launchdarkly.launchdarkly_get_current_user
ParameterTypeRequiredDescription
No parameters.
list_members Read

List LaunchDarkly account members.

Lua path
app.integrations.launchdarkly.list_members
Full name
launchdarkly.launchdarkly_list_members
ParameterTypeRequiredDescription
No parameters.
get_member Read

Get a LaunchDarkly account member.

Lua path
app.integrations.launchdarkly.get_member
Full name
launchdarkly.launchdarkly_get_member
ParameterTypeRequiredDescription
No parameters.
invite_members Write

Invite LaunchDarkly account members.

Lua path
app.integrations.launchdarkly.invite_members
Full name
launchdarkly.launchdarkly_invite_members
ParameterTypeRequiredDescription
No parameters.
update_member Write

Update a LaunchDarkly account member.

Lua path
app.integrations.launchdarkly.update_member
Full name
launchdarkly.launchdarkly_update_member
ParameterTypeRequiredDescription
No parameters.
delete_member Write

Delete a LaunchDarkly account member.

Lua path
app.integrations.launchdarkly.delete_member
Full name
launchdarkly.launchdarkly_delete_member
ParameterTypeRequiredDescription
No parameters.
list_teams Read

List LaunchDarkly teams.

Lua path
app.integrations.launchdarkly.list_teams
Full name
launchdarkly.launchdarkly_list_teams
ParameterTypeRequiredDescription
No parameters.
get_team Read

Get a LaunchDarkly team.

Lua path
app.integrations.launchdarkly.get_team
Full name
launchdarkly.launchdarkly_get_team
ParameterTypeRequiredDescription
No parameters.
create_team Write

Create a LaunchDarkly team.

Lua path
app.integrations.launchdarkly.create_team
Full name
launchdarkly.launchdarkly_create_team
ParameterTypeRequiredDescription
No parameters.
update_team Write

Update a LaunchDarkly team.

Lua path
app.integrations.launchdarkly.update_team
Full name
launchdarkly.launchdarkly_update_team
ParameterTypeRequiredDescription
No parameters.
delete_team Write

Delete a LaunchDarkly team.

Lua path
app.integrations.launchdarkly.delete_team
Full name
launchdarkly.launchdarkly_delete_team
ParameterTypeRequiredDescription
No parameters.