Feature flags
Runtime toggles for off/on variants, typed payloads, rollout percentages, targeting, and source-experiment promotion.
Simple terms
Feature flags are controlled switches or payloads for engineering rollouts, not visual A/B test DOM changes.
Runtime toggles for off/on variants, typed payloads, rollout percentages, targeting, and source-experiment promotion.
Routes
/flags
Implementation behavior
- Flags use the same targeting and rollout concepts as experiments but return a decision payload instead of DOM mutation behavior.
- A flag has status, key, rollout, targeting, variants, default/off value, and optional source experiment.
- Decision debugger explains why a visitor would receive a variant.
- Flags can be activated, paused, archived, or created from successful experiments.
How to use it
- Use flags when engineering needs a controlled rollout or remote configuration.
- Keep payloads typed and stable so application code can consume them safely.
- Test decisions with the debugger before activating.
- Archive flags that are permanently shipped in application code.
When not to use it
- Do not use a flag when you need experiment analytics and variant conversion tracking.
- Do not put secret or unsafe values in flag payloads consumed by the browser.
- Do not keep temporary rollout flags alive after the feature is permanently shipped.
Implementation source
- Pages live under
src/app/(dashboard)/flags. - Handlers live under
/api/flagsplus activate, pause, and archive routes. - Flags share targeting and rollout ideas with experiments but return typed decision payloads instead of DOM mutations.
Data and API
- Flag and flag variant models plus targeting JSON.
- APIs under
/api/flags,/api/flags/[id],/api/flags/[id]/activate,/api/flags/[id]/pause,/api/flags/[id]/archive, and experiment-to-flag creation. - Runtime decisions are delivered through configuration and flag evaluation endpoints.
Failure modes
- Application sees default value: flag paused, key mismatch, targeting miss, or rollout percentage excludes visitor.
- Bad payload breaks consuming app code: validate schema and defaults before activation.
- Old flags create confusion: archive retired rollouts.
Ordered audiences through the API and CLI
A personalization can show different versions to different audiences. Audiences are evaluated in order. Each audience chooses an experience and a rollout; its holdback sees the flag's Off version. When “stop after match” is enabled, later audiences are skipped after a match, including a holdback assignment.
Use apex flags experiences create or update with a JSON file to save the
experience's value, visual changes, CSS or JavaScript. Use apex flags rules set
to replace the audience list and apex flags rules reorder to change its order.
The API offers the same actions under a flag's rules and experiences paths.
Writes check the parent flag version to prevent overwriting another editor's
changes. If a save reports a conflict, reload the flag before saving again.
Removing an audience preserves its history. Experiences that an active or historical audience references cannot be deleted. The flag's Off and On versions stay in place, and goals remain attached to the whole personalization. A flag with no audiences keeps its existing rollout behavior.
Owners, end dates and history
A personalization can have one assigned Apex teammate and an end date. Existing
personalizations stay unassigned and have no end date. Owner choices contain
only active members of the store's organization. They contain names and IDs,
never email addresses. Reading the current owner uses normal flag read access;
opening the owner menu requires flags:write.
Use PATCH /api/v1/flags/{id} to set owner_user_id or ends_at. Omit a field
to preserve it, or send null to clear it. Include the flag's current
expected_updated_at whenever either field is present. A stale version returns
409; reload before deciding whether to save again. End dates must be future ISO
instants with an explicit offset. Responses include shop_timezone,
evaluated_at and is_ended so callers can display the store's local date.
An active personalization stops receiving new assignments at its end instant, including when a current SDK or edge evaluator reads a cached configuration containing that deadline. A minute job republishes expired configurations; raw cached configuration cleanup takes a successful tick plus the existing cache propagation window. A disconnected browser running an older SDK or a payload cached before an end was added still needs the updated artifact or configuration. Content already applied to an open page is not remotely removed at the deadline. Rules, IDs, conclusions and results remain available. Clearing or extending an end date can resume an active personalization. Paused ones stay Off. Concluding a personalization preserves its end date.
The assigned teammate receives an operational reminder on the first successful scheduled run within 72 hours of the end. The per-end identity prevents a new reminder when only the owner changes or a date is changed away and back. Suppressed and uncertain provider outcomes remain explicit; a lost receipt is never treated as permission to send a new message with a different key.
POST /api/v1/flags/{id}/unarchive requires expected_updated_at and restores an
archived personalization Off. It keeps the owner, end date, rules and conclusion.
GET /api/v1/flags/{id}/history?limit=20&offset=0 returns factual changes and
pagination.total/has_more. It requires a secret API key with both flags:read
and experiments:code:read. Publishable keys cannot read history. Load more pages to show the full trail, deduplicate
by log ID during concurrent edits, and count log entries rather than individual
changes. Older sparse entries retain only the action, actor and time actually
recorded. Detail rules include history_summary for recorded removal and
rollout events, independently of the visible history page.
apex flags update <id> --owner-user-id <teammate-uuid> --ends-at 2032-07-08T21:59:59.999Z
apex flags update <id> --clear-owner --clear-end-date
apex flags unarchive <id>
apex flags history <id> --limit 20 --offset 0 --jsonThese CLI writes read the parent version once when no explicit version was
provided. They never retry a 409 automatically. --owner-user-id conflicts with
--clear-owner; --ends-at conflicts with --clear-end-date.