Developer guide: 10. Feature flags

Create and evaluate feature flags: conditions, rollouts, payloads, exposure, scheduling and approvals.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide-feature-flags"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/260bc97d-9bc1-4229-a4c4-cfbb0eda45fe/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: 10. Feature flags" width="600" height="315"></a>

10. Feature flags

A flag is a named switch that Lucida evaluates for one person at a time. Use flags to release code gradually, target by person properties, serve variants and JSON config, and to power experiments (section 11). Every call below was run against a real project.

Shorthand used in this part: P="$LUCIDA_API/v1/projects/$PROJECT_ID". In tables {p} is /v1/projects/{project_id}. Scopes are flag:read and flag:write unless the table says admin. Account keys that hold *:read and *:write cover both.

10.1 Flag kinds and create

Route

Scope

Purpose

GET {p}/flags?limit=&cursor=&q=

flag:read

list, q searches key and name; answer {data, next_cursor}

POST {p}/flags

flag:write

create, answer 201 with the flag

GET {p}/flags/{id}

flag:read

one flag

PATCH {p}/flags/{id}

flag:write

partial update (null or absent = unchanged). While an experiment is running on the flag, a patch that changes what it serves (variant weights, enabled, conditions) is 409 problem+json with type .../experiment_running naming the experiment; stop the experiment first or retry with ?force=true. A paused experiment does not block edits, and POST .../kill stays allowed (it is the emergency control)

DELETE {p}/flags/{id}?force=

flag:write

soft delete (restorable); force overrides the dependents check

POST {p}/flags/{id}/restore

flag:write

undelete; the flag comes back disabled (turn it on yourself)

GET {p}/flags-deleted?limit=&cursor=

flag:read

deleted flags {id, key, name, deleted_at}

GET {p}/flags/{id}/history

flag:read

versions: version, change_kind, before, after, actor_user_id, reason

GET {p}/flags/{id}/dependents

flag:read

flags that use this one as a prerequisite; blocking says whether delete is refused

Create body: key (required, 1-100 chars of letters, digits, _ - ., unique, else 400/409), name, description, kind, enabled (default false), filters, variants, payloads, stickiness, tags, encrypt_payload.

kind

Rules

boolean (default)

no variants

multivariate

2 or more variants {key, rollout_pct, payload?}; rollout_pct is >= 0 and sums to 100, else 400

remote_config

serves a JSON payload; put it in payloads: {"default": {...}}. encrypt_payload: true seals it at rest; only secret keys see the plaintext

migration

exactly the variants off, dualwrite, shadow, live, rampdown, complete

ai_config

variants carry model config payloads (model, messages; mode: "agent" takes instructions and tools instead). Lucida adds version to the payload

# boolean, on for 50% of pro-plan people
lc -X POST "$P/flags" -d '{"key":"new-checkout","name":"New checkout","enabled":true,
  "filters":{"conditions":[{"rollout_pct":50,"filters":[{"type":"person","key":"plan","op":"eq","value":"pro"}]}]}}'

# multivariate with payloads and a stored (sticky) assignment
lc -X POST "$P/flags" -d '{"key":"cta-color","name":"CTA color","kind":"multivariate","enabled":true,
  "variants":[{"key":"control","rollout_pct":50},{"key":"green","rollout_pct":50,"payload":{"color":"green"}}],
  "filters":{"sticky":true,"conditions":[{"rollout_pct":100}]}}'

# remote config
lc -X POST "$P/flags" -d '{"key":"limits","name":"Limits","kind":"remote_config","enabled":true,
  "payloads":{"default":{"max_items":10}},"filters":{"conditions":[{"rollout_pct":100}]}}'

# AI config
lc -X POST "$P/flags" -d '{"key":"assistant","name":"Assistant","kind":"ai_config",
  "variants":[{"key":"default","rollout_pct":100,"payload":{"model":"x","messages":[{"role":"system","content":"You help."}]}}]}'

The flag answer holds id, key, kind, enabled, filters, variants, payloads, stickiness, tags, version (integer, bumps on every save), lifecycle, expires_at, protected_envs, environment_state, owner_user_id, namespace_id, holdout_id.

Gotchas:

  • A new flag is enabled: false and a flag with no conditions matches nobody. A usable flag is enabled and has at least one condition.

  • PATCH accepts name, description, kind, enabled, filters (replaces the whole object), variants, payloads, stickiness, tags, expires_at, lifecycle (draft, active, launched, deprecated), owner_user_id, protected_envs, environment, reason (stored in history). Bad values answer 400 with the valid list.

  • top-level stickiness picks the hash unit (see 10.3). filters.sticky stores assignments.

  • Per-flag extras: PUT|GET|DELETE {p}/flags/{id}/value-schema (body {"schema": JSON-Schema subset}, max 32 KB; saves that break it are 400), PUT {p}/flags/{id}/purpose (below), GET|POST {p}/flags/{id}/links and POST .../links/issue (link tickets; kind is jira, linear, github, gitlab, docs or other; max 50 links per object), GET {p}/flags/{id}/usage?from=&to= (daily evaluation counts), GET .../impact?metric_id=&event=&days=, GET .../blast-radius (how many known people each condition serves), GET {p}/flags/code-refs and POST (report code references), GET {p}/flags/shared and GET|PUT|DELETE .../flags/{id}/shares[/{target_id}] (share a flag with other projects), POST .../flags/{id}/copy-to-projects ({targets:[project ids], overwrite?, copy_schedules?}).

10.2 The filters grammar

filters is an object. Everything is optional; conditions does the work.

Key

Type

Meaning

conditions

array

ordered; the first matching condition decides

sticky

bool

store on-assignments so allocation changes do not move people

early_exit

bool

stop at the first condition whose filters match; a rollout miss there is final (out_of_rollout)

kill_switch

bool

force off for everyone (use the kill route)

salt

string

hash salt (rotate with rerandomize)

prerequisites

array

[{"flag":"other-key","value":true}]: this flag is on only when the other flag evaluates to value

app_contexts

string[]

serve only to SDKs that declare one of these app contexts (max 50)

evaluation_runtime

client or server

public keys never see server flags, secret keys never see client flags; empty = both

continuity

bool

an identified person keeps the bucket of their pre-identify anonymous id

holdout, namespace, design

object

set by experiments (holdout, layer range, switchback or geo design); do not hand-edit

compat

string

posthog for imported flags

A condition is {rollout_pct, filters[], segment?, aggregation?, variant_override?, payload_patch?}:

  • rollout_pct (required, 0-100): share of units that pass once the filters match.

  • filters[]: all must pass (AND). Conditions are ORed by order.

  • segment: key of a flag segment (10.6); matches units in any segment rule AND this condition's own filters.

  • aggregation: {kind: person|group|device|context, group_type?, context_kind?} per-condition bucketing unit.

  • variant_override: serve this variant key when the condition matches (multivariate).

  • payload_patch: RFC 7386 merge patch applied to the payload this condition serves.

A filter is {type, key, op, value}:

type

key is read from

Extra fields

person

person_properties of the request

group

group_properties

group_type

cohort

cohort membership (key = cohort id)

device, geo

device_properties, geo_properties

app_version

the SDK's app version

semver ops

flag

another flag's value

context

multi-kind context

context_kind: user, device or org

event

an event count in the session or page

scope: session or page; properties[] of event_property filters; ops limited to eq neq gt gte lt lte is_set is_not_set between not_between

op is exactly one of: eq, neq, in, not_in; contains, ncontains, icontains, not_icontains, starts_with, not_starts_with, ends_with, not_ends_with, regex, nregex; gt, gte, lt, lte, between, not_between; is_set, is_not_set; is_date_before, is_date_after; semver_eq, semver_neq, semver_gt, semver_gte, semver_lt, semver_lte, semver_tilde, semver_caret, semver_wildcard; array_contains_any, array_contains_all, array_contains_none; ip_in_cidr, ip_not_in_cidr. Anything else is 400.

# pro or team, in the EU, app version >= 3.2, not in the "internal" cohort
lc -X POST "$P/flags" -d '{"key":"eu-feature","name":"EU feature","enabled":true,"filters":{"early_exit":true,"conditions":[
  {"rollout_pct":100,"filters":[
    {"type":"person","key":"plan","op":"in","value":["pro","team"]},
    {"type":"geo","key":"continent","op":"eq","value":"EU"},
    {"type":"app_version","key":"app_version","op":"semver_gte","value":"3.2.0"}]},
  {"rollout_pct":10,"filters":[{"type":"person","key":"beta","op":"is_set"}]}]}}'

10.3 Variants, rollout, sticky bucketing, environments

  • Each unit hashes to a fixed point in 0-100 from the flag key, the salt and the unit id. A unit is in when its point is below rollout_pct. Raising a rollout only adds people.

  • stickiness (top level) chooses the hashed unit: distinct_id (default), person_id, device_id, group:<type> or context:<user|device|org>.

  • filters.sticky: true stores the assignment (only "on" results: the boolean true or the served variant). A stored person keeps their value (reason: sticky_bucket) even if rollout or weights change. A decide call writes sticky rows only for the flags it evaluated: those in flag_keys, or all flags when you name none. GET {p}/flags/{id}/sticky-assignments answers {total, values:[{value, units}]}; DELETE forgets them.

  • POST {p}/flags/{id}/rerandomize body {"confirm":"<flag key>","reason":"...","reset_sticky":false} rotates the salt. Everyone is bucketed again. Answer {flag_id, environments, sticky_removed, results_reset_at, warning}. While an experiment is running on the flag it answers 409 experiment_running; with ?force=true it rotates the salt and restarts the experiment's analysis window, and results_reset_at is set (as with POST {p}/experiments/{id}/rerandomize).

  • Environments: a project starts with production (default) and development. A key belongs to one environment and that is the environment the flag is evaluated in. PATCH with "environment":"development" writes an override of enabled and filters for that environment only; the base flag stays. Remove an override with DELETE {p}/flags/{id}/environments/{env}. GET {p}/flags/{id}/copy-preview?from=&to= shows a diff and POST {p}/flags/{id}/copy {"from":"production","to":"development"} copies state across. protected_envs lists environments where edits need approval (10.9).

10.4 Toggle, rollout, kill, dry-run, bulk

Route

Body

Purpose

POST {p}/flags/{id}/toggle

{"enabled":true}

turn on or off

PATCH {p}/flags/{id}/rollout

{"rollout_pct":100}

set the rollout of the first condition (creates one when there is none)

POST {p}/flags/{id}/kill

{"active":true,"reason":"..."}

set or clear filters.kill_switch; active defaults to true. A killed flag evaluates kill_switch for everyone, and enabled stays true

POST {p}/flags/dry-run

{"environment":"production","context":{"distinct_id":"u1","person_properties":{...}}}

returns {environment, flags, context}: the exact definitions the gateway serves for that environment (segments expanded) plus the context with big-segment membership resolved. It does not return results, writes nothing (no exposure, no sticky). Evaluate locally with the SDK core. context.distinct_id is required

POST {p}/flags/bulk

{"action","ids":[...],...}

up to 100 flags; each commits alone; answer [{id, ok, error?}]

The running-experiment guard (section 10.1) also covers these routes. While an experiment is running on the flag, toggle, rollout, POST .../copy (environment copy), DELETE .../environments/{env} (override removal), POST .../rerandomize, POST .../release/advance (a phase the pipeline applies directly), early access create and a PATCH that changes stage (they edit the flag's conditions), and bulk enable, disable and copy_environment answer 409 with type .../experiment_running, and every one takes ?force=true to override it (in a bulk call the refusal is that flag's error in the per-flag result, not an HTTP 409). POST .../kill always works. Not guarded: starting a gradual rollout plan (POST .../rollouts), a cross-project copy (POST {p}/transfers), applying a change request, and the system writers (the release pipeline's automatic progression, schedules, bandits). Treat those as bypasses and check for a running experiment yourself.

Bulk action values: add_tags and remove_tags (with tags), enable and disable (optional environment), copy_environment (with from and to). Anything else is reported per flag as unknown action.

FLAG_ID=$(lc "$P/flags?q=new-checkout" | jq -r '.data[0].id')
lc -X PATCH "$P/flags/$FLAG_ID/rollout" -d '{"rollout_pct":100}'
lc -X POST  "$P/flags/$FLAG_ID/toggle"  -d '{"enabled":true}'
lc -X POST  "$P/flags/$FLAG_ID/kill"    -d '{"active":true,"reason":"incident 42"}'   # off for everyone
lc -X POST  "$P/flags/$FLAG_ID/kill"    -d '{"active":false}'                         # back to normal
lc -X POST  "$P/flags/bulk" -d '{"action":"add_tags","ids":["'$FLAG_ID'"],"tags":["checkout"]}'

10.5 Evaluate: server polling and the decide call

Two hosts serve flags to apps. Both are on the capture host $LUCIDA_CAPTURE.

Route

Auth

Purpose

POST /v1/flags

public or secret key

decide: values for one person

POST /v1/flags/batch

project key

batched decide; the key is checked before the body, so a bad or missing key is 401 even with an invalid body

GET /v1/flags/definitions

secret key with flag:read, *:read or admin, or a legacy scope-less one (public key is 401, a capture-only key 403)

all definitions of the key's environment for local evaluation; ETag header, send If-None-Match and get 304; answer {flags:[{key, type, active, salt, conditions, variants, aggregation, ...}]}. Types: boolean, multivariate, json

GET /v1/flags/{key}/remote-config

secret key with a flag-read scope, as above (capture-only 403)

plaintext payload of one remote-config flag without evaluating targeting: {key, enabled, payload}

GET /v1/flags/stream

project key

push of definition changes

POST /ofrep/v1/evaluate/flags[/{key}]

project key

OpenFeature OFREP

GET /v1/config

public key

SDK config (autocapture, replay, consent mode)

GET {p}/flag-definitions?environment=

flag:read

the same definitions on the API host, for tools

Server SDKs poll /v1/flags/definitions with a secret key that has flag:read (mint it with ["capture","flag:read"] to send events too) and evaluate locally. Cohort and big-segment filters need the server and come back as requires_server.

Decide request:

curl -sS -X POST "$LUCIDA_CAPTURE/v1/flags" -H "Content-Type: application/json" -d '{
  "api_key":"'"$PK"'","distinct_id":"user_123",
  "person_properties":{"plan":"pro"},"flag_keys":["new-checkout","cta-color","limits","typo"]}'

Field

Meaning

api_key

or Authorization: Bearer <key> or ?api_key=; tenant and environment come from the key

distinct_id

required unless bucketing_key (hash unit used instead) is sent; otherwise 400

person_properties, group_properties, device_properties, geo_properties

inputs for the matching filter types

groups

{group_type: group_key}

contexts

multi-kind context entries (user, device, org)

app_version, device_id, anon_distinct_id

for app_version filters, device unit and continuity

app_contexts (alias evaluation_contexts)

declared app contexts

flag_keys

only these flags; omitted = all

preview

{flag: variant} forced for QA (signed preview links only)

send_exposure

true: Lucida records the two exposure events for flags that decided

Response:

{"flags":{"new-checkout":{"enabled":true,"value":true,"reason":"condition_match","condition_index":0},
          "cta-color":{"enabled":true,"variant":"green","value":"green","payload":{"color":"green"},"reason":"condition_match","condition_index":0},
          "limits":{"enabled":true,"value":true,"payload":{"max_items":10},"reason":"condition_match","condition_index":0}},
 "request_id":"4057e9cf...","unknown_flags":["typo"]}

Per flag: enabled, value (true/false or the variant key), variant and payload when present, reason, condition_index (-1 when no condition decided), optional runtime branches for event-count filters. Top level: request_id, unknown_flags (requested keys the project does not have, only when there are some), quota_limited (plan quota exhausted: 200 with no flags, keep cached values), layer_defaults.

reason is exactly one of:

reason

Meaning

condition_match

a condition's filters and rollout matched

no_condition_match

nothing matched, value is off

sticky_bucket

a stored assignment decided

out_of_rollout

early_exit: filters matched, hash outside rollout

inactive

flag disabled (or archived)

kill_switch

kill switch on

prerequisite_failed, prerequisite_missing, prerequisite_cycle

a prerequisite decided it

requires_server

needs server evaluation (cohort or big-segment filter on a client-side path)

no_bucketing_key

no unit to hash

holdout

held out by an experiment holdout

namespace_excluded

outside the experiment layer range

app_context_excluded

flag not served to the declared app contexts

preview

forced by the request preview map

user_preview

forced by a stored person preview (10.7)

Errors are problem+json: 400 malformed or no unit, 401 bad key, 403 request origin on the flag blocklist (10.7), 429 rate limit (read Retry-After), 503 definitions unavailable (retry).

10.6 Exposure events

POST /v1/flags only decides. Experiment results count a person from their first exposure event, so HTTP callers must record one. SDKs do it for you. Either:

# one call: decide and record
curl -sS -X POST "$LUCIDA_CAPTURE/v1/flags" -H "Content-Type: application/json" \
  -d '{"api_key":"'"$PK"'","distinct_id":"user_123","flag_keys":["cta-color"],"send_exposure":true}'

# or send both events yourself when you act on the value
curl -sS -X POST "$LUCIDA_CAPTURE/v1/batch" -H "Content-Type: application/json" -d '{"api_key":"'"$PK"'","batch":[
 {"uuid":"0192f4c4-7f0e-7c3a-9d21-5b1f0e8a4c51","event":"$feature_flag_called","distinct_id":"user_123",
  "properties":{"$feature_flag":"cta-color","$feature_flag_response":"green","locally_evaluated":false,"$feature_flag_request_id":"<request_id>"}},
 {"uuid":"0192f4c4-7f0e-7c3a-9d21-5b1f0e8a4c52","event":"$exposure","distinct_id":"user_123",
  "properties":{"$feature_flag":"cta-color","$feature_flag_response":"green","locally_evaluated":false}}]}'

Results read event IN ('$exposure','$feature_flag_called') with $feature_flag = the flag key and the variant in $feature_flag_response (a string; empty is ignored). Either event is enough. send_exposure is not deduped across calls; do not send an exposure when your own fallback was served.

10.7 Segments, templates, previews, notifications, blocklist, settings, policy, purposes

Route

Scope

Purpose

`GET

POST {p}/flag-segments, GET

PUT

POST {p}/flag-segments/{id}/members

flag:write

{add:[...], remove:[...], replace?:bool}, max 10,000 keys per call; GET pages members

POST {p}/flag-segments/{id}/sync

flag:write

re-materialise a synced segment now

`GET

POST {p}/flag-segments/{id}/change-requests`

`GET

POST {p}/flag-segments/{id}/schedules, DELETE .../schedules/{sid}`

`GET

POST {p}/flag-templates, DELETE {p}/flag-templates/{id}`

flag:write

`GET

POST

DELETE {p}/flag-previews`

`GET

POST {p}/flag-notifications, DELETE .../{id}`

admin to write

`GET

POST {p}/flag-blocklist, DELETE .../{id}`

admin to write

`GET

PUT {p}/flag-settings`

admin to write

`GET

PUT {p}/flag-policy`

admin to write

GET {p}/flag-purposes, PUT {p}/flag-purposes/lifetimes, PUT {p}/flags/{id}/purpose

admin for lifetimes

flag purpose and expected lifetime

  • Segment kind: rules (rules:[{filters:[...]}], OR of AND-ed filters), list (explicit member keys, no rules) or synced (needs source:{table, column?} naming a mirrored warehouse table, else 400). The key is what a condition's segment field names. Unknown segment keys match nobody.

  • Notification channels: [{"type":"email","to":"..."}, {"type":"slack","url":"..."}]; type is email, slack, teams, discord, webhook or account_team. Up to 100 flag keys; empty list = all flags; at least one channel. URLs are stored sealed and never returned (the answer shows only {type}).

  • Blocklist kind is host or cidr.

  • Flag settings: {confirm_on_save, default_conditions[], max_conditions, max_flags}.

  • Flag policy: {required_tags[], require_owner, require_description, allowed_contexts[]}. Allowed contexts are distinct_id, person_id, device_id, group:<type>, context:<user|device|org>. Applies to saves from now on.

  • Purposes (exactly): release, experiment, operational, kill_switch, permission, sunset. Default lifetimes in days: release 40, experiment 40, operational 7, sunset 14, kill_switch and permission none. PUT .../flag-purposes/lifetimes takes {purpose: days|null}.

lc -X POST "$P/flag-segments" -d '{"key":"pro-users","name":"Pro users","kind":"rules",
  "rules":[{"filters":[{"type":"person","key":"plan","op":"eq","value":"pro"}]}]}'
lc -X POST "$P/flag-segments" -d '{"key":"beta-list","name":"Beta list","kind":"list"}'
lc -X POST "$P/flag-segments/$SEG_ID/members" -d '{"add":["user_123","user_456"]}'    # {"member_count":2}
lc -X POST "$P/flags" -d '{"key":"beta-ui","name":"Beta UI","enabled":true,
  "filters":{"conditions":[{"rollout_pct":100,"segment":"beta-list"}]}}'
lc -X POST "$P/flag-previews" -d '{"distinct_id":"qa1","flag_key":"cta-color","variant":"green"}'
lc -X POST "$P/flag-blocklist" -d '{"kind":"cidr","value":"203.0.113.0/24","note":"scraper"}'
lc -X POST "$P/flag-notifications" -d '{"name":"to webhook","flag_keys":["new-checkout"],"channels":[{"type":"webhook","url":"https://example.com/hook"}]}'
lc -X PUT  "$P/flag-policy" -d '{"required_tags":[],"require_owner":false,"require_description":true,"allowed_contexts":[]}'

10.8 Health, stale flags, coverage, audit

Route

Scope

Purpose

GET {p}/flag-health

flag:read

every current health state (badges)

GET {p}/flags/{id}/health, .../health/history?limit=&cursor=

flag:read

states {status, reason, links, environment, dismissed_at} and unhealthy flag; history

POST {p}/flags/{id}/health/dismiss

flag:write

{environment?} dismiss until the next status change

`GET

POST {p}/flag-health-hooks`

admin to write

POST /v1/flag-health/{token}

token (no key)

alert receiver; unknown or revoked token is 404, bad signature 401

GET {p}/flag-stale?min_age_days=&exclude=&limit=&cursor=

flag:read

{stale:[{id, key, reasons, purpose, winner, variants}], next_cursor}; reasons such as fully_rolled_out

GET {p}/flag-coverage?days=

flag:read

per flag evaluation series

GET {p}/flag-audit?days=

flag:read

{debt_score, debt, ghosts, cliffs, shifts}: flags in code but not defined, sudden drops, distribution shifts

Create a hook with {"name","format","signed?","trigger_id?"}; format is generic, alertmanager or watchtower (Watchtower hooks are always signed). The answer is {hook, url, secret}; url and secret appear once. Report with the generic format:

HOOK_URL=$(lc -X POST "$P/flag-health-hooks" -d '{"name":"pager","format":"generic"}' | jq -r .url)
curl -sS -X POST "$HOOK_URL" -H "Content-Type: application/json" \
  -d '{"flag":"new-checkout","environment":"production","status":"unhealthy","reason":"error rate up","links":["https://example.com/alerts/1"]}'
# {"applied":1,"received":1,"triggered":null,"unmatched":[]}

generic status values: healthy, unhealthy, ok, firing, resolved. A report without flag covers every flag in that environment. Signed hooks need Lucida-Signature: t=<unix>,v1=<hex HMAC-SHA256 of "<t>.<body>"> (5 minute tolerance). With trigger_id, an unhealthy report fires that flag trigger.

10.9 Schedules, rollout plans, guarded rollout, release pipelines, triggers

Route

Scope

Purpose

`GET

POST {p}/flags/{id}/schedules, PATCH

DELETE .../schedules/{sid}`

POST {p}/flag-schedules/preview

next runs of a recurrence

`GET

POST {p}/flags/{id}/rollouts, DELETE .../rollouts/{plan}`

flag:write

`GET

POST {p}/flags/{id}/guarded-rolloutand.../abort, /acknowledge, /advance`

flag:write

GET {p}/flags/{id}/rollout-timeline?limit=&cursor=

flag:read

every move from rollouts, pipelines and guarded rollouts

`GET

POST {p}/release-pipelines, GET

PUT

`GET

POST {p}/flags/{id}/release, .../release/advance, /pause, /resume, /abort`

flag:write

`GET

POST {p}/flags/{id}/triggers, DELETE .../{tid}, POST .../{tid}/rotate`

admin

POST /v1/flag-triggers/{token}

token

fire a trigger

  • Schedule body: {action, run_at, payload?, recurrence?, cron?, ends_at?, timezone?, then?}. action is enable, disable, set_rollout (payload {rollout_pct, condition_index?}), apply_filters ({filters}), add_condition ({condition, position: first|last}), apply_variants ({variants}) or apply_payloads ({payloads}); payload.environment selects an environment (not for variants or payloads). recurrence is daily, weekly, monthly, yearly or cron (then cron is a five-field expression). ends_at needs a recurrence and must be after run_at. then is the paired second half (enable at 9, disable at 17) with its own run_at.

  • Rollout plan: steps:[{pct, hold_minutes?, guardrail_experiments?[]}], optional environment and start_at. The answer has status (running) and current_step.

  • Guarded rollout needs a multivariate flag (the first variant is the safe control). Body {steps?:[10,50,100], advance_every_hours?, guardrails:[{metric:<metric uuid>, direction, threshold, action}]}; direction is lower_is_better or higher_is_better; action is rollback or notify (notify pauses until acknowledge).

  • Release pipeline body: {name, description?, phases:[{name, environment, rollout_pct?, hold_minutes?(5-43200), requires_approval?, guardrail_experiments?[<=10], on_breach?: pause|rollback}]}. Start with POST .../release {"pipeline_id"}; the release starts at current_phase: -1 and advance applies the next phase or, for a gated phase, opens a change request (the answer holds release and change_request).

  • Trigger body {name, action, environment?}; action is enable, disable or kill. The answer is {trigger, url, secret} shown once.

lc -X POST "$P/flags/$FLAG_ID/schedules" -d '{"action":"set_rollout","run_at":"2027-01-01T09:00:00Z","payload":{"rollout_pct":100}}'
lc -X POST "$P/flags/$FLAG_ID/rollouts" -d '{"steps":[{"pct":10,"hold_minutes":60},{"pct":50,"hold_minutes":60},{"pct":100}]}'
lc -X POST "$P/release-pipelines" -d '{"name":"dev-then-prod","phases":[
  {"name":"Development","environment":"development","rollout_pct":100},
  {"name":"Prod 10%","environment":"production","rollout_pct":10,"hold_minutes":60,"on_breach":"pause"},
  {"name":"Prod 100%","environment":"production","rollout_pct":100,"requires_approval":true}]}'
lc -X POST "$P/flags/$FLAG_ID/triggers" -d '{"name":"pager","action":"kill"}'      # keep .url secret

10.10 Approvals, change requests, confirmations

The project approval policy puts risky actions behind a reviewed change request.

Route

Scope

Purpose

`GET

PUT {p}/approval-policy`

settings:read / admin

POST {p}/flags/{id}/change-requests

flag:write

propose a flag edit (same body as PATCH)

GET {p}/change-requests?status=&limit=&cursor=

flag:read

list; status is pending, approved, rejected, applied, cancelled, expired or failed; any other value is 400 and the detail lists the valid ones

POST {p}/change-requests/{cr}/approve

{apply?: bool, note?}

POST {p}/change-requests/{cr}/reject, /apply, /cancel

POST {p}/approvals

request approval for `{subject: cohort

POST /v1/confirmations/claim

none

{signature}: spend a write-proposal confirmation token once (204, then 409)

Policy keys (exactly): cohort.delete, dashboard.delete, experiment.start, experiment.pause, experiment.stop, experiment.update, flag.release, flag.enable, flag.disable, flag.rollout, flag.conditions, flag.variants, experiment.custom_code, segment.update. A rule is {quorum (default 1), approver_roles[], approver_users[], allow_self_approve (default false), condition, expires_hours (1-2160, default 168)}. condition.kind is any, rollout_above (pct), rollout_change (points), freeze_window (from_hour, to_hour, days) or flag_tagged (tags).

lc -X PUT "$P/approval-policy" -d '{"required":["flag.rollout"],"rules":{"flag.rollout":{"quorum":1,"allow_self_approve":false,"condition":{"kind":"any"},"expires_hours":24}}}'
lc -X PATCH "$P/flags/$FLAG_ID/rollout" -d '{"rollout_pct":50}'
# 409 problem type .../approval-required: "flag.rollout needs approval in this project; submit a change request"
CR=$(lc -X POST "$P/flags/$FLAG_ID/change-requests" -d '{"filters":{"conditions":[{"rollout_pct":50}]},"reason":"gradual"}' | jq -r .id)
lc -X POST "$P/change-requests/$CR/approve" -d '{"apply":true,"note":"ok"}'     # a different admin unless allow_self_approve

An approved request applies as status: applied with applied_version. A request is stale if the flag changed after it was made. Clear the policy with PUT {p}/approval-policy {"required":[]}.

Updated