KosmoKrator

devtools

LaunchDarkly Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write Bearer token auth

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.

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

list_flags

List feature flags in a LaunchDarkly project.

Parameters

NameTypeRequiredDescription
project_keystringnoProject key (defaults to configured project)
limitintegernoMax flags to return (default: 20, max: 100)
offsetintegernoPagination offset (default: 0)
envstringnoEnvironment key to filter results (e.g., "production")

Examples

-- List flags in default project
local result = app.integrations.launchdarkly.list_flags({})

-- Filter by environment
local result = app.integrations.launchdarkly.list_flags({
  env = "production"
})

for _, flag in ipairs(result.flags) do
  print(flag.key .. ": " .. flag.name)
  for env, state in pairs(flag.environments) do
    print("  " .. env .. ": " .. (state and "ON" or "OFF"))
  end
end

-- Paginated listing
local result = app.integrations.launchdarkly.list_flags({
  limit = 50,
  offset = 0
})

-- Specific project
local result = app.integrations.launchdarkly.list_flags({
  project_key = "my-backend-project"
})

get_flag

Get detailed information about a specific feature flag.

Parameters

NameTypeRequiredDescription
feature_flag_keystringyesThe flag key, e.g. "enable-new-dashboard"
project_keystringnoProject key (defaults to configured project)
envstringnoEnvironment key to filter results (e.g., "production")

Examples

local result = app.integrations.launchdarkly.get_flag({
  feature_flag_key = "enable-new-dashboard"
})

-- Get flag filtered to production environment
local result = app.integrations.launchdarkly.get_flag({
  feature_flag_key = "enable-new-dashboard",
  env = "production"
})

print("Flag: " .. result.name)
print("Kind: " .. result.kind)
print("Temporary: " .. tostring(result.temporary))

for env_key, env in pairs(result.environments) do
  print(env_key .. ": " .. (env.on and "ON" or "OFF"))
  print("  Rules: " .. env.rules)
end

toggle_flag

Turn a feature flag on or off in a specific environment.

Parameters

NameTypeRequiredDescription
feature_flag_keystringyesThe flag key
enabledbooleanyestrue to turn on, false to turn off
environment_keystringyesEnvironment key, e.g. "production"
project_keystringnoProject key (defaults to configured project)

Examples

-- Enable a flag in production
local result = app.integrations.launchdarkly.toggle_flag({
  feature_flag_key = "enable-new-dashboard",
  enabled = true,
  environment_key = "production"
})
print(result.message)

-- Disable a flag in staging
local result = app.integrations.launchdarkly.toggle_flag({
  feature_flag_key = "enable-new-dashboard",
  enabled = false,
  environment_key = "staging"
})
print(result.message)

list_environments

List all environments for a LaunchDarkly project.

Parameters

NameTypeRequiredDescription
project_keystringnoProject key (defaults to configured project)

Examples

local result = app.integrations.launchdarkly.list_environments({})

for _, env in ipairs(result.environments) do
  print(env.key .. " (" .. env.name .. ")")
  print("  Color: " .. env.color)
  print("  Secure mode: " .. tostring(env.secureMode))
end

list_projects

List all LaunchDarkly projects.

Parameters

This tool takes no parameters.

Examples

local result = app.integrations.launchdarkly.list_projects({})

for _, project in ipairs(result.projects) do
  print(project.key .. ": " .. project.name)
  print("  Environments: " .. project.environment_count)
  for _, env_key in ipairs(project.environment_keys) do
    print("  - " .. env_key)
  end
end

get_project

Get detailed information about a specific LaunchDarkly project.

Parameters

NameTypeRequiredDescription
project_keystringyesThe project key (e.g., "default", "my-backend-project")

Examples

local result = app.integrations.launchdarkly.get_project({
  project_key = "default"
})

print("Project: " .. result.name)
print("Description: " .. result.description)
print("Environments: " .. result.environment_count)

for env_key, env in pairs(result.environments) do
  print("  " .. env_key .. ": " .. env.name .. " (color: " .. env.color .. ")")
end

get_current_user

Get the currently authenticated LaunchDarkly user.

Parameters

This tool takes no parameters.

Examples

local result = app.integrations.launchdarkly.get_current_user({})

print("User: " .. result.first_name .. " " .. result.last_name)
print("Email: " .. result.email)
print("Role: " .. result.role)

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.launchdarkly.work.function_name({...})
app.integrations.launchdarkly.staging.function_name({...})

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

Raw agent markdown
# LaunchDarkly — Lua API Reference

## list_flags

List feature flags in a LaunchDarkly project.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_key` | string | no | Project key (defaults to configured project) |
| `limit` | integer | no | Max flags to return (default: 20, max: 100) |
| `offset` | integer | no | Pagination offset (default: 0) |
| `env` | string | no | Environment key to filter results (e.g., `"production"`) |

### Examples

```lua
-- List flags in default project
local result = app.integrations.launchdarkly.list_flags({})

-- Filter by environment
local result = app.integrations.launchdarkly.list_flags({
  env = "production"
})

for _, flag in ipairs(result.flags) do
  print(flag.key .. ": " .. flag.name)
  for env, state in pairs(flag.environments) do
    print("  " .. env .. ": " .. (state and "ON" or "OFF"))
  end
end

-- Paginated listing
local result = app.integrations.launchdarkly.list_flags({
  limit = 50,
  offset = 0
})

-- Specific project
local result = app.integrations.launchdarkly.list_flags({
  project_key = "my-backend-project"
})
```

---

## get_flag

Get detailed information about a specific feature flag.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `feature_flag_key` | string | yes | The flag key, e.g. `"enable-new-dashboard"` |
| `project_key` | string | no | Project key (defaults to configured project) |
| `env` | string | no | Environment key to filter results (e.g., `"production"`) |

### Examples

```lua
local result = app.integrations.launchdarkly.get_flag({
  feature_flag_key = "enable-new-dashboard"
})

-- Get flag filtered to production environment
local result = app.integrations.launchdarkly.get_flag({
  feature_flag_key = "enable-new-dashboard",
  env = "production"
})

print("Flag: " .. result.name)
print("Kind: " .. result.kind)
print("Temporary: " .. tostring(result.temporary))

for env_key, env in pairs(result.environments) do
  print(env_key .. ": " .. (env.on and "ON" or "OFF"))
  print("  Rules: " .. env.rules)
end
```

---

## toggle_flag

Turn a feature flag on or off in a specific environment.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `feature_flag_key` | string | yes | The flag key |
| `enabled` | boolean | yes | `true` to turn on, `false` to turn off |
| `environment_key` | string | yes | Environment key, e.g. `"production"` |
| `project_key` | string | no | Project key (defaults to configured project) |

### Examples

```lua
-- Enable a flag in production
local result = app.integrations.launchdarkly.toggle_flag({
  feature_flag_key = "enable-new-dashboard",
  enabled = true,
  environment_key = "production"
})
print(result.message)

-- Disable a flag in staging
local result = app.integrations.launchdarkly.toggle_flag({
  feature_flag_key = "enable-new-dashboard",
  enabled = false,
  environment_key = "staging"
})
print(result.message)
```

---

## list_environments

List all environments for a LaunchDarkly project.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_key` | string | no | Project key (defaults to configured project) |

### Examples

```lua
local result = app.integrations.launchdarkly.list_environments({})

for _, env in ipairs(result.environments) do
  print(env.key .. " (" .. env.name .. ")")
  print("  Color: " .. env.color)
  print("  Secure mode: " .. tostring(env.secureMode))
end
```

---

## list_projects

List all LaunchDarkly projects.

### Parameters

This tool takes no parameters.

### Examples

```lua
local result = app.integrations.launchdarkly.list_projects({})

for _, project in ipairs(result.projects) do
  print(project.key .. ": " .. project.name)
  print("  Environments: " .. project.environment_count)
  for _, env_key in ipairs(project.environment_keys) do
    print("  - " .. env_key)
  end
end
```

---

## get_project

Get detailed information about a specific LaunchDarkly project.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_key` | string | yes | The project key (e.g., `"default"`, `"my-backend-project"`) |

### Examples

```lua
local result = app.integrations.launchdarkly.get_project({
  project_key = "default"
})

print("Project: " .. result.name)
print("Description: " .. result.description)
print("Environments: " .. result.environment_count)

for env_key, env in pairs(result.environments) do
  print("  " .. env_key .. ": " .. env.name .. " (color: " .. env.color .. ")")
end
```

---

## get_current_user

Get the currently authenticated LaunchDarkly user.

### Parameters

This tool takes no parameters.

### Examples

```lua
local result = app.integrations.launchdarkly.get_current_user({})

print("User: " .. result.first_name .. " " .. result.last_name)
print("Email: " .. result.email)
print("Role: " .. result.role)
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.launchdarkly.work.function_name({...})
app.integrations.launchdarkly.staging.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.launchdarkly.launchdarkly_list_flags({
  project_key = "example_project_key",
  limit = 1,
  offset = 1,
  env = "example_env"
})
print(result)

Functions

launchdarkly_list_flags

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

Operation
Read read
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").

launchdarkly_get_flag

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

Operation
Read read
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").

launchdarkly_toggle_flag

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

Operation
Write write
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).

launchdarkly_list_environments

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

Operation
Read read
Full name
launchdarkly.launchdarkly_list_environments
ParameterTypeRequiredDescription
project_key string no The project key (defaults to the configured project).

launchdarkly_list_projects

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

Operation
Read read
Full name
launchdarkly.launchdarkly_list_projects
ParameterTypeRequiredDescription
No parameters.

launchdarkly_get_project

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

Operation
Read read
Full name
launchdarkly.launchdarkly_get_project
ParameterTypeRequiredDescription
project_key string yes The project key (e.g., "default", "my-backend-project").

launchdarkly_get_current_user

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

Operation
Read read
Full name
launchdarkly.launchdarkly_get_current_user
ParameterTypeRequiredDescription
No parameters.