Skip to content

LaunchDarkly

LaunchDarkly flags, targeting, segments, audit log, approvals, members and experiments as SQL tables

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/launchdarkly/index.md to help me query LaunchDarkly with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find production feature flags ready for cleanup

This example uses the default project and production environment. Replace them with your project and environment keys.

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT flag_key, status, last_requested
FROM launchdarkly.main.flag_status(project_key := 'default', environment_key := 'production')
WHERE status IN ('inactive', 'launched')
ORDER BY flag_key

Quick start

Choose where to run LaunchDarkly, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'launchdarkly' AS launchdarkly (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-launchdarkly'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

launchdarkly credentials

A LaunchDarkly API access token or service token, plus the instance URL for EU / Federal accounts

Get these credentials →
secret.sql
CREATE SECRET launchdarkly (
    TYPE launchdarkly,
    access_token '<ACCESS_TOKEN>',  -- secret
    base_url     '<base_url>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT flag_key, status, last_requested
FROM launchdarkly.main.flag_status(project_key := 'default', environment_key := 'production')
WHERE status IN ('inactive', 'launched')
ORDER BY flag_key
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'launchdarkly' AS launchdarkly (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

LaunchDarkly feature management as SQL: projects, environments, flags and their targeting, segments, the audit log, approvals, members and experiments, read-only from the LaunchDarkly REST API.

Catalog

Everything launchdarkly exposes once attached — read straight from the worker's released build.

launchdarkly 1 schema
main 7 tables · 12 functions

LaunchDarkly flags, targeting, change management, access and experiments, read-only.

Schema examples (12)
Examples (12)

Every environment and its change controls

SELECT project_key, key, critical, approvals_required
FROM launchdarkly.main.environments()
ORDER BY project_key, key;

Critical environments that do not require approvals

SELECT project_key, key
FROM launchdarkly.main.environments()
WHERE critical AND NOT approvals_required
ORDER BY ALL;

Production flags, most recently changed first

SELECT key, targeting_on, rule_count, last_modified
FROM launchdarkly.main.flags(project_key := 'default', environment_key := 'production')
ORDER BY last_modified DESC;

Temporary flags switched on per environment (temporary is sent as filter=type:temporary)

SELECT environment_key, count(*) FILTER (WHERE targeting_on) AS flags_on,
  count(*) AS flags
FROM launchdarkly.main.flags(project_key := 'default')
WHERE temporary
GROUP BY ALL
ORDER BY ALL;
8 more examples

Every production targeting clause

SELECT flag_key, rule_index, attribute, op, clause_values
FROM launchdarkly.main.flag_rules(project_key := 'default', environment_key := 'production')
ORDER BY flag_key, rule_index, clause_index;

Which segments each production flag targets

SELECT DISTINCT flag_key, unnest(clause_values) AS segment
FROM launchdarkly.main.flag_rules(project_key := 'default', environment_key := 'production')
WHERE op = 'segmentMatch'
ORDER BY ALL;

Production flags that are cleanup candidates

SELECT flag_key, status, last_requested
FROM launchdarkly.main.flag_status(project_key := 'default', environment_key := 'production')
WHERE status IN ('inactive', 'launched')
ORDER BY flag_key;

Flag status mix per environment

SELECT environment_key, status, count(*) AS flags
FROM launchdarkly.main.flag_status(project_key := 'default')
GROUP BY ALL
ORDER BY ALL;

Production segments and their sizes

SELECT key, rule_count, included_count, excluded_count
FROM launchdarkly.main.segments(project_key := 'default', environment_key := 'production')
ORDER BY key;

Big segments in every environment (sent as filter=unbounded equals true)

SELECT environment_key, key
FROM launchdarkly.main.segments(project_key := 'default')
WHERE unbounded
ORDER BY ALL;

Context kinds and when each was last seen

SELECT project_key, key, last_seen
FROM launchdarkly.main.context_kinds()
ORDER BY project_key, key;

Upcoming scheduled flag changes

SELECT flag_key, environment_key, execution_date, instruction_kinds
FROM launchdarkly.main.scheduled_changes(project_key := 'default')
ORDER BY execution_date;
Tables
approval_requests 1 example20 cols

Approval requests for flag and segment changes, with review status

Columns
idnot null VARCHAR
Approval request id.
description VARCHAR
Request description.
requestor_id VARCHAR
Member id of the requester.
review_status VARCHAR
pending, approved or declined.
status VARCHAR
pending, scheduled, failed or completed.
resource_id VARCHAR
Resource specifier of the changed resource.
project_key VARCHAR
Project key parsed from resource_id.
environment_key VARCHAR
Environment key parsed from resource_id.
resource_kind VARCHAR
Kind of resource (flag, segment, aiConfig).
resource_key VARCHAR
Key of the resource.
notify_member_ids VARCHAR[]
Members asked to review.
notify_team_keys VARCHAR[]
Teams asked to review.
reviews STRUCT of 3 fields[]
Reviews: kind (approve / decline / comment), member_id and comment.
STRUCT[] 3 fields
  • kindVARCHAR
  • member_idVARCHAR
  • commentVARCHAR
instruction_kinds VARCHAR[]
Semantic-patch instruction kinds the request applies.
instructions JSON
The semantic-patch instructions, as JSON.
creation_date TIMESTAMP WITH TIME ZONE
When the request was created.
applied_date TIMESTAMP WITH TIME ZONE
When the change was applied.
applied_by_member_id VARCHAR
Member who applied the change.
execution_date TIMESTAMP WITH TIME ZONE
When a scheduled change will execute.
service_kind VARCHAR
Approval service (launchdarkly or external).
ConstraintsPRIMARY KEY (id)
Example

Pending approvals, oldest first (sent as filter=reviewStatus anyOf)

SELECT id, resource_key, environment_key, creation_date
FROM launchdarkly.main.approval_requests
WHERE review_status = 'pending'
ORDER BY creation_date;
Link
code_ref_repositories 1 example9 cols

Repositories scanned for flag code references (ld-find-code-refs)

Columns
namenot null VARCHAR
Repository name.
type VARCHAR
github, gitlab, bitbucket or custom.
source_link VARCHAR
URL of the repository.
default_branch VARCHAR
Branch whose references code_references reports.
enabled BOOLEAN
Code reference scanning is enabled.
version INTEGER
Version number of the saved repository data (increments on each sync).
branch_count INTEGER
Count of branches scanned for references.
branches VARCHAR[]
Names of the scanned branches.
last_synced TIMESTAMP WITH TIME ZONE
When a branch was last scanned.
ConstraintsPRIMARY KEY (name)
Example

Scanned repositories

SELECT name, type, default_branch, last_synced
FROM launchdarkly.main.code_ref_repositories
ORDER BY name;
Link
custom_role_statements 1 example8 cols

Custom role policy statements, one row each

Columns
role_keynot null VARCHAR
Custom role key.
role_name VARCHAR
Custom role name.
statement_indexnot null INTEGER
Position of the statement in the policy.
effect VARCHAR
allow or deny.
actions VARCHAR[]
Actions the statement covers.
not_actions VARCHAR[]
Actions excluded (the statement covers all others).
resources VARCHAR[]
Resource specifiers the statement covers.
not_resources VARCHAR[]
Resource specifiers excluded.
ConstraintsPRIMARY KEY (role_key, statement_index)
Example

Statements that apply to every production flag

SELECT role_key, effect, actions FROM launchdarkly.main.custom_role_statements WHERE list_contains(resources, 'proj/*:env/production:flag/*') ORDER BY role_key, statement_index;
Link
custom_roles 1 example10 cols

Custom roles with their policy statements

Columns
id VARCHAR
Role id.
keynot null VARCHAR
Role key.
name VARCHAR
Role name.
description VARCHAR
Role description.
base_permissions VARCHAR
Base permissions (reader or no_access).
resource_category VARCHAR
Resource category the role manages.
statement_count INTEGER
Number of policy statements.
assigned_members INTEGER
Count of members the role is assigned to.
assigned_teams INTEGER
Count of teams the role is assigned to.
policy STRUCT of 6 fields[]
Policy statements in order: idx (0-based position), effect, actions, not_actions, resources, not_resources.
STRUCT[] 6 fields
  • idxINTEGER
  • effectVARCHAR
  • actionsVARCHAR[]
  • not_actionsVARCHAR[]
  • resourcesVARCHAR[]
  • not_resourcesVARCHAR[]
ConstraintsPRIMARY KEY (key)
Example

Custom roles and their use

SELECT key, statement_count, assigned_members
FROM launchdarkly.main.custom_roles
ORDER BY key;
Link
members 2 examples12 cols

Account members: role, custom roles, teams, MFA and last seen

Columns
idnot null VARCHAR
Member id.
email VARCHAR
Member email.
first_name VARCHAR
Given name as stored in LaunchDarkly.
last_name VARCHAR
Family name as stored in LaunchDarkly.
role VARCHAR
Base role: reader, writer, admin, owner or no_access.
custom_roles VARCHAR[]
Keys of additional custom roles.
team_keys VARCHAR[]
Teams the member belongs to.
mfa VARCHAR
MFA state: enabled or disabled.
pending_invite BOOLEAN
The member has not accepted their invitation.
verified BOOLEAN
The member's email is verified.
last_seen TIMESTAMP WITH TIME ZONE
Last session (NULL if never).
creation_date TIMESTAMP WITH TIME ZONE
When the member was created.
ConstraintsPRIMARY KEY (id)
Examples (2)

Members per base role

SELECT role, count(*) AS members
FROM launchdarkly.main.members
GROUP BY role
ORDER BY members DESC;

Admins without MFA

SELECT email, role
FROM launchdarkly.main.members
WHERE role IN ('admin', 'owner') AND mfa <> 'enabled'
ORDER BY email;
Link
projects 2 examples7 cols

LaunchDarkly projects (keys, names, tags, client-side defaults)

Columns
id VARCHAR
Project id.
keynot null VARCHAR
Project key (used in API paths and resource specifiers).
name VARCHAR
Project name.
tags VARCHAR[]
Project tags.
client_side_using_environment_id BOOLEAN
New flags default to being available to client-side (browser) SDKs.
client_side_using_mobile_key BOOLEAN
New flags default to being available to mobile SDKs.
default_release_pipeline_key VARCHAR
Key of the project's default release pipeline.
ConstraintsPRIMARY KEY (key)
Examples (2)

Every project

SELECT key, name, tags FROM launchdarkly.main.projects ORDER BY key;

Projects tagged web (the tag filter is sent to LaunchDarkly)

SELECT key, name
FROM launchdarkly.main.projects
WHERE list_contains(tags, 'web')
ORDER BY key;
Link
teams 1 example9 cols

Teams with member counts and custom roles

Columns
keynot null VARCHAR
Team key.
name VARCHAR
Team name.
description VARCHAR
Team description.
member_count INTEGER
Count of members on the team.
custom_role_keys VARCHAR[]
Custom roles assigned to the team.
idp_synced BOOLEAN
Synced from an identity provider.
version INTEGER
Team version number (increments on each change).
creation_date TIMESTAMP WITH TIME ZONE
When the team was created.
last_modified TIMESTAMP WITH TIME ZONE
When the team last changed.
ConstraintsPRIMARY KEY (key)
Example

Teams by size

SELECT key, member_count, custom_role_keys
FROM launchdarkly.main.teams
ORDER BY member_count DESC;
Link
Table functions
audit_log (include_diff := BOOLEAN, lookback_days := BIGINT, page_size := BIGINT, q := VARCHAR) 2 examples

The account audit log: who changed what, when — the record of every flag, segment and settings change

Named arguments
include_diff := BOOLEAN
Fetch each entry's delta / previous_version / current_version (one extra call per entry). · default false
lookback_days := BIGINT
Days of history to read when no lower bound on date is given (0 = all history). · default 30
page_size := BIGINT
Entries per page (LaunchDarkly allows 1–20). · default 20
q := VARCHAR
Full-text search over the audit log (LaunchDarkly `q`), e.g. a resource name. · default null
Returns columns
id VARCHAR
Audit log entry id.
date TIMESTAMP WITH TIME ZONE
When the change happened.
resource_kind VARCHAR
Kind of resource changed (flag, segment, environment, project, member, role, …).
resource_name VARCHAR
Name of the resource changed.
resource_key VARCHAR
Key of the resource (parsed from the target specifier).
project_key VARCHAR
Project of the resource (parsed from the target specifier).
environment_key VARCHAR
Environment of the resource (parsed from the target specifier).
title VARCHAR
One-line summary: who did what to which resource.
title_verb VARCHAR
The action phrase ("turned on the flag").
description VARCHAR
Markdown description of the change.
short_description VARCHAR
Short description of the change.
comment VARCHAR
Comment entered with the change.
actor VARCHAR
Who made the change: member email, else token name, app name or subject name.
member_id VARCHAR
Member who made the change.
member_email VARCHAR
Email of that member.
member_name VARCHAR
Name of that member.
token_id VARCHAR
Access token that made the change.
token_name VARCHAR
Name of that token.
service_token BOOLEAN
The token is a service token.
app_name VARCHAR
Authorized application that made the change.
actions VARCHAR[]
Actions performed (updateOn, updateRules, createFlag, …).
resources VARCHAR[]
Target resource specifiers.
parent_resource VARCHAR
Parent resource specifier.
related_flag_key VARCHAR
Flag updated as a side effect.
delta JSON
JSON patch of the change (include_diff := true).
previous_version JSON
The resource before the change (include_diff := true).
current_version JSON
The resource after the change (include_diff := true).
Examples (2)

Production flag changes in the hour before an incident (pushed as spec + after/before)

SELECT date, actor, title
FROM launchdarkly.main.audit_log()
WHERE resource_kind = 'flag' AND environment_key = 'production' AND date BETWEEN TIMESTAMPTZ '2026-11-14 09:00:00+00' AND TIMESTAMPTZ '2026-11-14 12:00:00+00'
ORDER BY date DESC;

Who changed the most in the last week

SELECT actor, count(*) AS changes
FROM launchdarkly.main.audit_log(lookback_days := 7)
GROUP BY actor
ORDER BY changes DESC;
Link
code_references (flag_key := VARCHAR, project_key := VARCHAR) 1 example

Flag references found in code on each repository's default branch, one row per hunk

Named arguments
flag_key := VARCHAR
Only references to this flag (LaunchDarkly `flagKey`). · default null
project_key := VARCHAR
Only references to flags of this project (LaunchDarkly `projKey`). · default null
Returns columns
repository VARCHAR
Repository name.
repository_type VARCHAR
github, gitlab, bitbucket or custom.
branch VARCHAR
Branch name.
head VARCHAR
Commit the branch was scanned at.
sync_time TIMESTAMP WITH TIME ZONE
When the branch was scanned.
path VARCHAR
File path.
language_hint VARCHAR
Language of the file.
starting_line INTEGER
First line of the hunk.
project_key VARCHAR
Project of the referenced flag.
flag_key VARCHAR
Referenced flag key.
aliases VARCHAR[]
Flag key aliases matched.
lines VARCHAR
The code around the reference.
Example

How widely each flag is referenced in code

SELECT flag_key, count(*) AS refs, count(DISTINCT repository) AS repos
FROM launchdarkly.main.code_references(project_key := 'default')
GROUP BY flag_key
ORDER BY refs DESC;
Link
context_kinds (project_key := VARCHAR) 1 example

Context kinds defined in each project (user, organization, device …)

Named arguments
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
key VARCHAR
Context kind key.
name VARCHAR
Context kind name.
description VARCHAR
Description.
version INTEGER
Context kind version.
created_from VARCHAR
How the kind was created (default, auto-add, manual).
archived BOOLEAN
Archived (unavailable for targeting).
creation_date TIMESTAMP WITH TIME ZONE
When the kind was created.
last_modified TIMESTAMP WITH TIME ZONE
When the kind last changed.
last_seen TIMESTAMP WITH TIME ZONE
When a context of this kind was last evaluated.
Example

Context kinds and when each was last seen

SELECT project_key, key, last_seen
FROM launchdarkly.main.context_kinds()
ORDER BY project_key, key;
Link
environments (project_key := VARCHAR) 2 examples

LaunchDarkly environments per project, without SDK or mobile keys

Named arguments
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
key VARCHAR
Environment key.
name VARCHAR
Environment name.
client_side_id VARCHAR
The environment's client-side ID (public: embedded in browser SDK bundles). SDK and mobile keys are never exposed.
color VARCHAR
UI colour (hex, no #).
critical BOOLEAN
Whether the environment is marked critical.
default_ttl INTEGER
Default PHP SDK cache TTL in minutes.
secure_mode BOOLEAN
Client-side secure mode (contexts cannot inspect each other's variations).
default_track_events BOOLEAN
Initial trackEvents value for new flags.
require_comments BOOLEAN
Members must comment when changing flags and segments in the UI.
confirm_changes BOOLEAN
Members must confirm flag and segment changes in the UI.
tags VARCHAR[]
Environment tags.
approvals_required BOOLEAN
Flag changes need an approval request.
min_approvals INTEGER
Approvals needed before a change can be applied.
can_review_own_request BOOLEAN
Requesters may approve their own requests.
approval_service VARCHAR
Approval service: launchdarkly or an external one.
approval_required_tags VARCHAR[]
Approvals are required only for flags with these tags (empty = all flags).
Examples (2)

Every environment and its change controls

SELECT project_key, key, critical, approvals_required
FROM launchdarkly.main.environments()
ORDER BY project_key, key;

Critical environments that do not require approvals

SELECT project_key, key
FROM launchdarkly.main.environments()
WHERE critical AND NOT approvals_required
ORDER BY ALL;
Link
experiments (lifecycle_state := VARCHAR, page_size := BIGINT, project_key := VARCHAR) 2 examples

Experiments across every environment of each project, with the current iteration

Named arguments
lifecycle_state := VARCHAR
Which experiments: active (default), archived, or active,archived for both. · default "active"
page_size := BIGINT
Rows requested per LaunchDarkly page (named; clamped to the endpoint's maximum). · default 50
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
key VARCHAR
Experiment key.
id VARCHAR
Experiment id.
name VARCHAR
Experiment name.
description VARCHAR
Description.
environment_key VARCHAR
Environment the experiment runs in.
maintainer_id VARCHAR
Member who maintains it.
creation_date TIMESTAMP WITH TIME ZONE
When it was created.
archived_date TIMESTAMP WITH TIME ZONE
When it was archived.
tags VARCHAR[]
Experiment tags.
type VARCHAR
Experiment type.
methodology VARCHAR
bayesian, frequentist or export_only.
data_source VARCHAR
Metric data source (launchdarkly, snowflake).
iteration_id VARCHAR
Current iteration id.
iteration_status VARCHAR
Current iteration status: not_started, running or stopped.
hypothesis VARCHAR
Current iteration hypothesis.
started_at TIMESTAMP WITH TIME ZONE
When the current iteration started.
ended_at TIMESTAMP WITH TIME ZONE
When the current iteration ended.
randomization_unit VARCHAR
Randomization unit (context kind).
flag_keys VARCHAR[]
Flags the experiment uses.
primary_metric_key VARCHAR
Primary metric key.
metric_keys VARCHAR[]
Every metric of the current iteration.
treatments STRUCT of 3 fields[]
Treatments: name, allocation_percent and baseline.
STRUCT[] 3 fields
  • nameVARCHAR
  • allocation_percentVARCHAR
  • baselineBOOLEAN
winning_treatment_id VARCHAR
Treatment chosen when the iteration stopped.
winning_reason VARCHAR
Why the iteration was stopped.
Examples (2)

Experiments and what they measure

SELECT key, environment_key, iteration_status, primary_metric_key
FROM launchdarkly.main.experiments(project_key := 'default')
ORDER BY key;

Running experiments in every project (sent as filter=status:running)

SELECT key, started_at
FROM launchdarkly.main.experiments()
WHERE iteration_status = 'running'
ORDER BY started_at;
Link
flag_rules (environment_key := VARCHAR, evaluated_since_days := BIGINT, page_size := BIGINT, project_key := VARCHAR, query := VARCHAR, sort := VARCHAR) 2 examples

Flag targeting rules and their clauses, one row per clause per flag and environment

Named arguments
environment_key := VARCHAR
Environment key (named). NULL reads every environment of each project; a pushed WHERE environment_key = / IN (...) works the same way. · default null
evaluated_since_days := BIGINT
Only flags evaluated in this environment within the last N days (LaunchDarkly `filter=evaluated:` + `filterEnv`). · default null
page_size := BIGINT
Rows requested per LaunchDarkly page (named; clamped to the endpoint's maximum). · default 100
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
query := VARCHAR
Substring matched against flag keys and names, case-insensitively (LaunchDarkly `filter=query:`). · default null
sort := VARCHAR
LaunchDarkly sort field: creationDate, key, name or maintainerId; prefix - for descending. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
environment_key VARCHAR
The environment key the row belongs to.
flag_key VARCHAR
Flag key.
flag_name VARCHAR
Flag name.
targeting_on BOOLEAN
Targeting is on for the flag in this environment.
rule_index INTEGER
Position of the rule (0 = evaluated first).
rule_id VARCHAR
Rule id.
rule_description VARCHAR
Rule description.
rule_disabled BOOLEAN
The rule is disabled.
rule_ref VARCHAR
Rule reference key, if set.
variation INTEGER
Variation index the rule serves (NULL for a rollout).
rollout STRUCT(variation INTEGER, weight INTEGER)[]
Percentage rollout: variation index and weight (thousandths of a percent).
rollout_bucket_by VARCHAR
Attribute the rollout buckets by.
rollout_context_kind VARCHAR
Context kind the rollout buckets.
track_events BOOLEAN
Detailed events are sent for evaluations matching this rule.
clause_index INTEGER
Position of the clause in the rule (all clauses must match).
clause_id VARCHAR
Clause id.
context_kind VARCHAR
Context kind the clause tests (user, organization, …).
attribute VARCHAR
Context attribute the clause tests (key, email, country, segmentMatch …).
op VARCHAR
Operator: in, endsWith, startsWith, matches, contains, lessThan, before, segmentMatch, semVerEqual, …
negate BOOLEAN
The clause is negated.
clause_values VARCHAR[]
Values the clause compares against (JSON text for non-strings).
Examples (2)

Every production targeting clause

SELECT flag_key, rule_index, attribute, op, clause_values
FROM launchdarkly.main.flag_rules(project_key := 'default', environment_key := 'production')
ORDER BY flag_key, rule_index, clause_index;

Which segments each production flag targets

SELECT DISTINCT flag_key, unnest(clause_values) AS segment
FROM launchdarkly.main.flag_rules(project_key := 'default', environment_key := 'production')
WHERE op = 'segmentMatch'
ORDER BY ALL;
Link
flag_status (environment_key := VARCHAR, project_key := VARCHAR) 2 examples

Flag evaluation status per environment: new, active, inactive or launched, and when last requested

Named arguments
environment_key := VARCHAR
Environment key (named). NULL reads every environment of each project; a pushed WHERE environment_key = / IN (...) works the same way. · default null
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
environment_key VARCHAR
The environment key the row belongs to.
flag_key VARCHAR
Flag key.
status VARCHAR
new, active, inactive or launched.
last_requested TIMESTAMP WITH TIME ZONE
When an SDK last evaluated the flag in this environment.
default_value VARCHAR
The fallback value SDKs reported for the flag (JSON text for non-strings).
Examples (2)

Production flags that are cleanup candidates

SELECT flag_key, status, last_requested
FROM launchdarkly.main.flag_status(project_key := 'default', environment_key := 'production')
WHERE status IN ('inactive', 'launched')
ORDER BY flag_key;

Flag status mix per environment

SELECT environment_key, status, count(*) AS flags
FROM launchdarkly.main.flag_status(project_key := 'default')
GROUP BY ALL
ORDER BY ALL;
Link
flags (environment_key := VARCHAR, evaluated_since_days := BIGINT, page_size := BIGINT, project_key := VARCHAR, query := VARCHAR, sort := VARCHAR) 2 examples

Feature flags with their per-environment targeting state, one row per flag and environment

Named arguments
environment_key := VARCHAR
Environment key (named). NULL reads every environment of each project; a pushed WHERE environment_key = / IN (...) works the same way. · default null
evaluated_since_days := BIGINT
Only flags evaluated in this environment within the last N days (LaunchDarkly `filter=evaluated:` + `filterEnv`). · default null
page_size := BIGINT
Rows requested per LaunchDarkly page (named; clamped to the endpoint's maximum). · default 100
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
query := VARCHAR
Substring matched against flag keys and names, case-insensitively (LaunchDarkly `filter=query:`). · default null
sort := VARCHAR
LaunchDarkly sort field: creationDate, key, name or maintainerId; prefix - for descending. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
environment_key VARCHAR
The environment key the row belongs to.
environment_name VARCHAR
The environment's display name.
key VARCHAR
Flag key (what code evaluates).
name VARCHAR
Flag name.
description VARCHAR
Flag description.
kind VARCHAR
boolean or multivariate.
state VARCHAR
live, deprecated or archived.
temporary BOOLEAN
Temporary (release) flag rather than permanent.
archived BOOLEAN
The flag is archived.
deprecated BOOLEAN
The flag is deprecated.
tags VARCHAR[]
Flag tags.
maintainer_id VARCHAR
Member id of the flag maintainer.
maintainer_email VARCHAR
Email of the flag maintainer (as returned by LaunchDarkly).
maintainer_team_key VARCHAR
Key of the maintaining team.
client_side_using_environment_id BOOLEAN
Available to browser SDKs (client-side ID).
client_side_using_mobile_key BOOLEAN
Available to mobile SDKs (mobile key).
variations STRUCT of 5 fields[]
Variations: idx, id, name, description, value (JSON text for non-strings).
STRUCT[] 5 fields
  • idxINTEGER
  • idVARCHAR
  • nameVARCHAR
  • descriptionVARCHAR
  • valueVARCHAR
default_on_variation INTEGER
Variation index new environments serve when on.
default_off_variation INTEGER
Variation index new environments serve when off.
creation_date TIMESTAMP WITH TIME ZONE
When the flag was created.
archived_date TIMESTAMP WITH TIME ZONE
When the flag was archived.
deprecated_date TIMESTAMP WITH TIME ZONE
When the flag was deprecated.
flag_version INTEGER
Flag version (all environments).
ready_to_archive BOOLEAN
LaunchDarkly flags it stale: ready to archive.
ready_for_code_removal BOOLEAN
LaunchDarkly flags it ready for code removal.
targeting_on BOOLEAN
Targeting is on in this environment.
off_variation INTEGER
Variation index served when targeting is off.
fallthrough_variation INTEGER
Default-rule variation idx (NULL for a rollout).
fallthrough_rollout STRUCT(variation INTEGER, weight INTEGER)[]
Default-rule rollout: variation idx and weight (1/1000 %).
rule_count INTEGER
Number of targeting rules in this environment.
target_count INTEGER
Contexts targeted individually in this environment.
prerequisites STRUCT(key VARCHAR, variation INTEGER)[]
Prerequisite flags: key and required variation idx.
track_events BOOLEAN
Every evaluation sends a detailed event.
last_modified TIMESTAMP WITH TIME ZONE
When the flag config in this environment last changed.
env_version INTEGER
Version of this environment's flag configuration.
site_url VARCHAR
LaunchDarkly UI link for this environment.
custom_properties JSON
Custom properties attached to the flag, as JSON.
Examples (2)

Production flags, most recently changed first

SELECT key, targeting_on, rule_count, last_modified
FROM launchdarkly.main.flags(project_key := 'default', environment_key := 'production')
ORDER BY last_modified DESC;

Temporary flags switched on per environment (temporary is sent as filter=type:temporary)

SELECT environment_key, count(*) FILTER (WHERE targeting_on) AS flags_on,
  count(*) AS flags
FROM launchdarkly.main.flags(project_key := 'default')
WHERE temporary
GROUP BY ALL
ORDER BY ALL;
Link
metrics (page_size := BIGINT, project_key := VARCHAR) 1 example

Metric definitions per project (custom, page view, click)

Named arguments
page_size := BIGINT
Rows requested per LaunchDarkly page (named; clamped to the endpoint's maximum). · default 50
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
key VARCHAR
Metric key.
id VARCHAR
Metric id.
version_id VARCHAR
Metric version id.
name VARCHAR
Metric name.
description VARCHAR
Description.
kind VARCHAR
custom, pageview, click or trace.
category VARCHAR
Metric category.
event_key VARCHAR
Event key sent by code (custom metrics).
is_numeric BOOLEAN
Tracks a numeric value rather than conversion.
unit VARCHAR
Unit of a numeric metric.
success_criteria VARCHAR
HigherThanBaseline or LowerThanBaseline.
unit_aggregation_type VARCHAR
average, sum or count_distinct.
analysis_type VARCHAR
mean or percentile.
percentile_value INTEGER
Target percentile for percentile analysis.
analysis_units VARCHAR[]
Context kinds allowed as analysis units.
tags VARCHAR[]
Metric tags.
maintainer_id VARCHAR
Member who maintains the metric.
data_source_key VARCHAR
Data source key.
attached_flag_count INTEGER
Flags attached to the metric.
experiment_count INTEGER
Experiments using the metric.
creation_date TIMESTAMP WITH TIME ZONE
When it was created.
last_seen TIMESTAMP WITH TIME ZONE
Most recent data for the metric (hour fidelity).
archived BOOLEAN
The metric version is archived.
Example

Metric definitions

SELECT key, kind, is_numeric, experiment_count
FROM launchdarkly.main.metrics(project_key := 'default')
ORDER BY key;
Link
release_pipelines (project_key := VARCHAR) 1 example

Release pipelines per project with their phases

Named arguments
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
key VARCHAR
Pipeline key.
name VARCHAR
Pipeline name.
description VARCHAR
Description.
tags VARCHAR[]
Pipeline tags.
is_project_default BOOLEAN
The project's default pipeline.
is_legacy BOOLEAN
A legacy pipeline.
version INTEGER
Pipeline version.
created_at TIMESTAMP WITH TIME ZONE
When it was created.
phase_count INTEGER
Number of phases.
phases STRUCT of 4 fields[]
Ordered phases: idx, id, name and the environment keys of their audiences.
STRUCT[] 4 fields
  • idxINTEGER
  • idVARCHAR
  • nameVARCHAR
  • environment_keysVARCHAR[]
Example

Pipeline phases in order with their environments

SELECT p.key, ph.name, ph.environment_keys
FROM launchdarkly.main.release_pipelines(project_key := 'default') p,
     unnest(p.phases) AS u(ph)
ORDER BY p.key, ph.idx;
Link
scheduled_changes (environment_key := VARCHAR, flag_key := VARCHAR, project_key := VARCHAR) 1 example

Scheduled flag changes per flag and environment

Named arguments
environment_key := VARCHAR
Environment key (named). NULL reads every environment of each project; a pushed WHERE environment_key = / IN (...) works the same way. · default null
flag_key := VARCHAR
Flag key (named). NULL reads every live flag of each project (one extra call per flag and environment); a pushed WHERE flag_key = / IN (...) works the same way. · default null
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
environment_key VARCHAR
The environment key the row belongs to.
flag_key VARCHAR
Flag key.
id VARCHAR
Scheduled change id.
execution_date TIMESTAMP WITH TIME ZONE
When the change will be applied.
instruction_kinds VARCHAR[]
Instruction kinds to apply.
instructions JSON
The semantic-patch instructions, as JSON.
maintainer_id VARCHAR
Member who maintains the scheduled change.
creation_date TIMESTAMP WITH TIME ZONE
When it was created.
version INTEGER
Version.
has_conflicts BOOLEAN
LaunchDarkly reports conflicting scheduled changes.
Example

Upcoming scheduled flag changes

SELECT flag_key, environment_key, execution_date, instruction_kinds
FROM launchdarkly.main.scheduled_changes(project_key := 'default')
ORDER BY execution_date;
Link
segments (environment_key := VARCHAR, include_members := BOOLEAN, page_size := BIGINT, project_key := VARCHAR, query := VARCHAR) 2 examples

Segments per project and environment: rules and included/excluded counts

Named arguments
environment_key := VARCHAR
Environment key (named). NULL reads every environment of each project; a pushed WHERE environment_key = / IN (...) works the same way. · default null
include_members := BOOLEAN
Also return the individually included/excluded target keys (included_keys / excluded_keys). Off by default. · default false
page_size := BIGINT
Rows requested per LaunchDarkly page (named; clamped to the endpoint's maximum). · default 50
project_key := VARCHAR
Project key (named). NULL reads every project; a pushed WHERE project_key = / IN (...) works the same way. · default null
query := VARCHAR
Fuzzy search across segment key, name and description (LaunchDarkly `filter=query equals`). · default null
Returns columns
project_key VARCHAR
The project key the row belongs to.
environment_key VARCHAR
The environment key the row belongs to.
key VARCHAR
Segment key.
name VARCHAR
Segment name.
description VARCHAR
Segment description.
tags VARCHAR[]
Segment tags.
unbounded BOOLEAN
Big segment (list-based or synced) rather than a standard segment.
unbounded_context_kind VARCHAR
Context kind of a big segment.
external VARCHAR
External data store backing a synced segment.
included_count INTEGER
Targets individually included (all context kinds).
excluded_count INTEGER
Targets individually excluded (all context kinds).
included_keys VARCHAR[]
Included target keys (only with include_members := true).
excluded_keys VARCHAR[]
Excluded target keys (only with include_members := true).
rule_count INTEGER
Number of segment rules.
rules STRUCT of 5 fields[]
Segment rules: id, description, clause_count, weight (rollout, thousandths of a percent) and bucket_by.
STRUCT[] 5 fields
  • idVARCHAR
  • descriptionVARCHAR
  • clause_countINTEGER
  • weightINTEGER
  • bucket_byVARCHAR
rules_json JSON
The full segment rules with clauses, as JSON.
creation_date TIMESTAMP WITH TIME ZONE
When the segment was created.
last_modified TIMESTAMP WITH TIME ZONE
When the segment last changed.
version INTEGER
Segment version.
deleted BOOLEAN
The segment is deleted.
Examples (2)

Production segments and their sizes

SELECT key, rule_count, included_count, excluded_count
FROM launchdarkly.main.segments(project_key := 'default', environment_key := 'production')
ORDER BY key;

Big segments in every environment (sent as filter=unbounded equals true)

SELECT environment_key, key
FROM launchdarkly.main.segments(project_key := 'default')
WHERE unbounded
ORDER BY ALL;
Link

Credentials

The secret type launchdarkly declares, as reported by the worker itself.

launchdarkly

How to get these credentials

A LaunchDarkly API access token or service token, plus the instance URL for EU / Federal accounts

secret.sql
CREATE SECRET launchdarkly (
    TYPE launchdarkly,
    access_token '<ACCESS_TOKEN>',  -- secret
    base_url     '<base_url>'
);
Key Type Required Description
access_token secret VARCHAR — LaunchDarkly API access token or service token (Account settings > Authorization), e.g. api-…
base_url VARCHAR — Instance URL: https://app.launchdarkly.com (default), https://app.eu.launchdarkly.com (EU) or https://app.launchdarkly.us (Federal). http:// is accepted only for 127.0.0.1/localhost.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching launchdarkly — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

flags_columns — The flags() result columns (binds only; create a launchdarkly secret and drop LIMIT 0 for rows)

SELECT project_key, environment_key, key, targeting_on, rule_count
FROM launchdarkly.main.flags()
LIMIT 0;

Uses flags

audit_log_columns — The audit_log() result columns (binds only; create a launchdarkly secret and drop LIMIT 0 for rows)

SELECT date, actor, resource_kind, title
FROM launchdarkly.main.audit_log()
LIMIT 0;

Uses audit_log

Every environment and its change controls

SELECT project_key, key, critical, approvals_required
FROM launchdarkly.main.environments()
ORDER BY project_key, key

Uses environments

Every production targeting clause

SELECT flag_key, rule_index, attribute, op, clause_values
FROM launchdarkly.main.flag_rules(project_key := 'default', environment_key := 'production')
ORDER BY flag_key, rule_index, clause_index

Uses flag_rules

Flag status mix per environment

SELECT environment_key, status, count(*) AS flags
FROM launchdarkly.main.flag_status(project_key := 'default')
GROUP BY ALL
ORDER BY ALL

Uses flag_status

Production segments and their sizes

SELECT key, rule_count, included_count, excluded_count
FROM launchdarkly.main.segments(project_key := 'default', environment_key := 'production')
ORDER BY key

Uses segments

23 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • List the keys of all LaunchDarkly projects.
  • Which flags in the default project are switched on in production?
  • How many temporary flags does the default project have?
  • Which flags in the default project are archived?
  • Which flags target the beta-testers segment in production in the default project?
  • Which flags in the default project have launched status in production?

LaunchDarkly is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.