Wrangler commands (6)

Last updated Oct 19, 2026 Use wrangler flagship to manage Flagship apps and feature flags from the command line. Every wrangler flagship flags command takes the app ID as the first argument. Most subcommands then take a flag key, for example wrangler flagship flags get <APP_ID> <KEY>. List-style commands, such as wrangler flagship flags list <APP_ID>, take only the app ID.

Before you begin

Authenticate Wrangler

wrangler flagship calls the Cloudflare API. Authenticate Wrangler before running commands:

wrangler login

For automation, set CLOUDFLARE_API_TOKEN to an API token with the appropriate Flagship permissions.

Permission Use it for
flagship:read Listing apps, getting apps, listing flags, inspecting flags, evaluating flags, and reading changelogs.
flagship:write Creating apps, updating apps, deleting apps, creating flags, updating flags, changing defaults, rollouts, splits, enable/disable, and deleting flags.

Most commands that modify an existing flag first read the current flag and then write back the updated definition. For those workflows, grant both flagship:read and flagship:write.

Bind Flagship to your Worker

Add a Flagship binding to your Worker project so your Worker code can evaluate flags with low latency at runtime:

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "flagship": [
    {
      "binding": "FLAGS",
      "app_id": "<APP_ID>"
    }
  ]
}
[[flagship]]
binding = "FLAGS"
app_id = "<APP_ID>"

Note

This binding is only used by your Worker's runtime code (env.FLAGS). wrangler flagship commands always take the app ID as an explicit argument and do not read it from this binding.

Quick start

Create a boolean flag, evaluate it for a user, and disable it as a kill switch:

# With no variations, Wrangler creates on=true, off=false,
# and serves off by default.
wrangler flagship flags create <APP_ID> new-checkout

# Evaluate the flag for a user.
wrangler flagship flags evaluate <APP_ID> new-checkout --targeting-key user-42

# Disable the flag instantly. Disabled flags always serve their default variation.
wrangler flagship flags disable <APP_ID> new-checkout

Manage apps

Apps group related flags. A common pattern is one app per service, Worker, or product surface.

Task Command
Create app wrangler flagship apps create <NAME>
List apps wrangler flagship apps list
Get app wrangler flagship apps get <APP_ID>
Rename app wrangler flagship apps update <APP_ID> --name <NAME>
Delete app wrangler flagship apps delete <APP_ID>

wrangler flagship apps ls is an alias for apps list. wrangler flagship apps rm is an alias for apps delete.

wrangler flagship apps list follows pagination automatically and displays all apps in the account.

Creating an app returns the app ID and shows the binding snippet to add to your Wrangler configuration:

wrangler flagship apps create checkout-service

To add the new app to your wrangler.json or wrangler.jsonc file as a Worker binding, pass --binding:

wrangler flagship apps create checkout-service --binding FLAGS

Wrangler also supports --update-config to update your JSON or JSONC configuration after prompting for a binding name.

For non-JSON configuration files, Wrangler prints the binding snippet but does not edit the file automatically.

When --json is used, apps create prints the created app as JSON and does not prompt for or update configuration.

For scripts, capture the app ID from JSON output:

APP_ID=$(wrangler flagship apps create checkout-service --json | jq -r '.id')

Deleting an app deletes all of its flags and changelog history. The API rejects app deletion if a Worker still references the app through a Flagship binding.

Use --force or -y to skip the delete confirmation prompt. If you also use --json, you must pass --force so the confirmation prompt cannot appear in JSON output.

wrangler flagship apps delete <APP_ID> --force

Delete multiple apps by passing multiple app IDs:

wrangler flagship apps delete <APP_ID_1> <APP_ID_2> <APP_ID_3> --force

Create flags

Flag keys are unique within an app. Use stable keys that describe the behavior being controlled, such as new-checkout, pricing-page-layout, or upload-limit.

Boolean flags

If you omit variations, Wrangler creates a boolean flag with on=true, off=false, and off as the default variation.

wrangler flagship flags create <APP_ID> new-checkout

Explicit variations

Use --variation (-V) to add each variation as name=value. Use --default to choose the fallback variation.

# String flag.
wrangler flagship flags create <APP_ID> checkout-flow \
    -V v1=old-checkout \
    -V v2=new-checkout \
    --default v1 \
    --type string

# Number flag.
wrangler flagship flags create <APP_ID> upload-limit \
    -V free=10 \
    -V pro=100 \
    -V enterprise=1000 \
    --default free \
    --type number

# JSON flag.
wrangler flagship flags create <APP_ID> theme-config \
    -V 'light={"bg":"#ffffff","fg":"#111111"}' \
    -V 'dark={"bg":"#111111","fg":"#ffffff"}' \
    --default light \
    --type json

Supported value types are boolean, string, number, and json. If --type is omitted, Wrangler infers each value's scalar type independently.

All variations on a flag must use the same value type. Wrangler rejects a flag whose variations resolve to mixed types, for example one boolean and one number, before sending the request. Pass --type explicitly to coerce every variation to the same type.

Use --description (-d) to document the purpose of a flag:

wrangler flagship flags create <APP_ID> checkout-flow \
    -V v1=old-checkout \
    -V v2=new-checkout \
    --default v1 \
    --type string \
    --description "Controls which checkout experience is served"

Flag keys and variation names can contain letters, numbers, hyphens, and underscores. Keep keys stable, because application code evaluates flags by key.

Disabled flags

Use --disabled to create a flag that serves its default variation until you enable it.

wrangler flagship flags create <APP_ID> coming-soon \
    -V on=true \
    -V off=false \
    --default off \
    --disabled

Target users with rules

Targeting rules decide which variation to serve for a given evaluation context. Pass rules with --rule or --rule-json.

Rule syntax

The compact --rule syntax uses semicolon-separated segments:

serve=<VARIATION>; when=<CONDITIONS>; rollout=<PERCENT>%@<ATTRIBUTE>; priority=<NUMBER>
Segment Required Description
serve Yes Variation served when the rule matches. Must reference an existing variation.
when No Conditions matched against evaluation context. If omitted, the rule matches every context.
rollout No Percentage of matching traffic to receive the variation. The attribute controls sticky bucketing.
priority No Evaluation order. Lower numbers run first. If omitted, Wrangler assigns priorities by order.
wrangler flagship flags create <APP_ID> premium-banner \
    -V on=true \
    -V off=false \
    --default off \
    --rule "serve=on; when=plan equals enterprise AND country in [US,CA]; rollout=25%@user_id"

Conditions

Conditions compare attributes from the evaluation context with rule values. The compact syntax supports all Flagship operators:

--rule "serve=on; when=plan equals pro"
--rule "serve=on; when=country in [US,CA,UK]"
--rule "serve=on; when=tags has beta"
--rule "serve=off; when=email ends_with @example.com"
--rule "serve=strict; when=score less_than 20"

Use AND and OR to combine conditions. AND has higher precedence than OR.

# Both conditions must match.
--rule "serve=on; when=plan equals pro AND country equals US"

# Either condition can match.
--rule "serve=on; when=plan equals enterprise OR plan equals team"

# Equivalent to: (plan=pro AND country=US) OR plan=enterprise.
--rule "serve=on; when=plan equals pro AND country equals US OR plan equals enterprise"

AND and OR are reserved as logical operators when they appear outside quoted values or lists. Wrap values in single or double quotes when they contain reserved words or separators such as AND, OR, ;, or ,:

--rule 'serve=on; when=title equals "WAR AND PEACE" OR title equals "tom; jerry"'
--rule 'serve=on; when=country in ["US","CA"]'

For in and not_in, pass a bracketed list. For has and not_has, pass the scalar array member to find. Wrangler rejects malformed lists, empty list items, unterminated quotes, and unbalanced brackets before sending the request.

Use --rule-json for deeply nested logical groups or if you prefer to pass the API rule shape directly. Wrangler validates --rule-json against the Flagship rule schema and rejects unknown or conflicting fields.

wrangler flagship flags create <APP_ID> beta-features \
    -V on=true \
    -V off=false \
    --default off \
    --rule-json '{"serve_variation":"on","conditions":[{"logical_operator":"OR","clauses":[{"attribute":"beta","operator":"equals","value":true},{"attribute":"plan","operator":"equals","value":"enterprise"}]}]}'

Multiple rules

Repeat --rule or --rule-json to declare multiple rules. Rules are evaluated in priority order. The first matching rule wins.

wrangler flagship flags create <APP_ID> rate-limit-tier \
    -V strict=50 \
    -V normal=200 \
    -V relaxed=1000 \
    --default normal \
    --type number \
    --rule "serve=strict; when=score less_than 20" \
    --rule "serve=relaxed; when=score greater_than_or_equals 90"

Wrangler validates duplicate rule priorities, duplicate variation names, malformed lists, non-finite numeric values such as Infinity, and unknown variation names before sending the request.

Inspect flags

List flags in an app:

wrangler flagship flags list <APP_ID>

The list command is paginated. Use --limit and --cursor for manual pagination, or --all to fetch every page.

wrangler flagship flags list <APP_ID> --limit 50
wrangler flagship flags list <APP_ID> --cursor <CURSOR>
wrangler flagship flags list <APP_ID> --all

Inspect a full flag definition:

wrangler flagship flags get <APP_ID> new-checkout

wrangler flagship flags ls is an alias for flags list. wrangler flagship flags inspect is an alias for flags get.

Update flags

wrangler flagship flags update reads the current flag, applies your changes, and writes the full flag definition back to the API.

Update metadata and variations

wrangler flagship flags update <APP_ID> new-checkout \
    --description "Redesigned checkout experience"

wrangler flagship flags update <APP_ID> upload-limit \
    --set-variation team=500

wrangler flagship flags update <APP_ID> upload-limit \
    --remove-variation team

To add a variant to an existing flag, set a new variation name and value:

wrangler flagship flags update <APP_ID> checkout-flow \
    --set-variation experiment=new-checkout-v2

Pass an empty description to clear it:

wrangler flagship flags update <APP_ID> new-checkout --description ""

When you add or replace variations on an existing flag, use --type if Wrangler should coerce the new values to a specific type:

wrangler flagship flags update <APP_ID> upload-limit \
    --type number \
    --set-variation team=500

Wrangler validates that the resulting variation set still has a single value type and that the default variation and targeting rules still reference known variations.

You can also enable or disable a flag through flags update, although flags enable and flags disable are shorter for kill-switch workflows:

wrangler flagship flags update <APP_ID> new-checkout --disable
wrangler flagship flags update <APP_ID> new-checkout --enable

Change the default variation

wrangler flagship flags set <APP_ID> checkout-flow --variation v2

Use --clear-rules if the new default should be served to everyone.

wrangler flagship flags set <APP_ID> checkout-flow --variation v2 --clear-rules

Replace, append, or clear all rules

Use --rule or --rule-json to replace the full rule set:

wrangler flagship flags update <APP_ID> premium-banner \
    --rule "serve=on; when=plan equals pro AND country not_in [CN,RU]"

Use --add-rule or --add-rule-json to append rules without changing existing rules:

wrangler flagship flags update <APP_ID> premium-banner \
    --add-rule "serve=off; when=account_age less_than 7"

wrangler flagship flags update <APP_ID> premium-banner \
    --add-rule-json '{"serve_variation":"off","conditions":[{"attribute":"country","operator":"in","value":["CN","RU"]}]}'

Clear all rules:

wrangler flagship flags update <APP_ID> premium-banner --clear-rules

Note

Do not combine replacement flags (--rule, --rule-json) with append flags (--add-rule, --add-rule-json), or with --clear-rules, in the same command.

List rules

Use rules list to see the priorities you can target with rule-specific commands:

wrangler flagship flags rules list <APP_ID> premium-banner

Reorder rules

Flagship evaluates rules by ascending priority; the first matching rule wins. Use rules reorder to reorder existing rules without rewriting every condition.

Pass the existing priorities in the new order. Wrangler renumbers them to 1..n in that order:

wrangler flagship flags rules reorder <APP_ID> rate-limit-tier --order 2,1

If the existing priorities were 1=strict and 2=relaxed, this makes relaxed priority 1 and strict priority 2.

Change one rule

Use rules update to edit one rule by priority while preserving the rest of the rule set.

Change only a rollout percentage:

wrangler flagship flags rules update <APP_ID> premium-banner \
    --priority 1 \
    --rollout 50%@user_id

Change the variation served by a rule:

wrangler flagship flags rules update <APP_ID> premium-banner \
    --priority 1 \
    --serve off

Change the conditions on a rule:

wrangler flagship flags rules update <APP_ID> premium-banner \
    --priority 1 \
    --when "plan equals enterprise OR plan equals team"

Remove conditions from a rule so it matches every evaluation context:

wrangler flagship flags rules update <APP_ID> premium-banner \
    --priority 1 \
    --clear-conditions

Caution

A rule with no conditions matches every evaluation context. Flagship requires unconditional rules to come after all rules that have conditions. If the rule you are clearing is not the last rule in the set, the API will reject the update with Rules with empty conditions must come after rules with conditions.

Use rules reorder first to move the rule to the last position, then clear its conditions. If you want to serve a single variation to everyone and discard all other rules, use --clear-rules on flags set instead.