{"command":{"effect":"write","timeoutSeconds":30,"inputSchema":{"type":"object","description":"Replaces the entire flag definition. Omitted fields are cleared, not preserved — read before writing. The path key identifies the flag and cannot be renamed by changing the body `key`. A changelog entry is appended when the flag content actually changes; identical updates are no-ops.","properties":{"path":{"type":"object","properties":{"account_id":{"description":"Cloudflare account ID that owns the Flagship app.","type":"string"},"app_id":{"description":"Flagship app ID returned when the app was created.","type":"string"},"flag_key":{"description":"Case-sensitive key identifying the flag within the app.","type":"string"}},"required":["account_id","app_id","flag_key"],"additionalProperties":false},"body":{"type":"object","properties":{"default_variation":{"description":"Variation the API serves when the flag is off, or when it's on but no rule matches the context. Must be a key in `variations`.","type":"string","minLength":1},"description":{"description":"Optional operator-facing description. It does not affect flag evaluation.","type":["string","null"],"maxLength":512},"enabled":{"description":"When false, the flag bypasses all rules and always serves `default_variation`.","type":"boolean"},"key":{"description":"Unique identifier for the flag within an app. Used in all evaluation and SDK calls.","type":"string","maxLength":64,"minLength":1,"pattern":"^[a-zA-Z0-9_-]+$"},"metadata":{"description":"Key-value metadata associated with the flag. `null` or an empty object clears existing metadata; omission semantics depend on the endpoint (PUT clears it, PATCH preserves it).","type":["object","null"],"additionalProperties":{"anyOf":[{"type":"boolean"},{"type":"string"},{"type":"number"}]},"maxProperties":32},"rules":{"description":"Targeting rules evaluated in ascending `priority`; the first matching rule wins. An empty array means the flag always serves `default_variation`.","type":"array","items":{"$ref":"#/definitions/flagship_Rule"}},"type":{"description":"Deprecated compatibility field. Omit it; the API ignores this value and infers the type from the flag's variations.","type":"string","enum":["boolean","string","number","json"]},"variations":{"description":"Map of variation name to value. All values share the same type (boolean, string, number, or JSON object/array), and each serialized value stays within 10KB.","type":"object","additionalProperties":{"$ref":"#/definitions/flagship_JsonValue"}}},"additionalProperties":false,"required":["key","default_variation","variations","rules","enabled"]}},"required":["path","body"],"additionalProperties":false,"definitions":{"flagship_Rule":{"type":"object","properties":{"conditions":{"description":"Conditions the context must satisfy for this rule to match. An empty array matches all contexts.","type":"array","items":{"$ref":"#/definitions/flagship_Condition"}},"priority":{"description":"Evaluation order: the API evaluates rules with lower numbers first. Must be unique across the flag's rules.","type":"integer","minimum":1},"rollout":{"type":"object","additionalProperties":false,"properties":{"attribute":{"description":"Context attribute used for sticky bucketing. Defaults to `targetingKey`. If absent at evaluation time, bucketing is random per request.","type":"string","maxLength":64,"minLength":1},"percentage":{"description":"Percentage of matching traffic (0–100, up to 2 decimal places) served this variation. For multi-way splits, use cumulative upper bounds across rules (e.g. 30, 70, 100).","type":"number","maximum":100,"minimum":0,"multipleOf":0.01}},"required":["percentage"]},"serve_variation":{"description":"Variation the API serves when this rule matches. Must be a key in `variations`.","type":"string","minLength":1}},"additionalProperties":false,"required":["priority","conditions","serve_variation"]},"flagship_JsonValue":{"oneOf":[{"type":["string","null"]},{"type":"number"},{"type":"boolean"},{"additionalProperties":{"$ref":"#/definitions/flagship_JsonValue"},"type":"object"},{"items":{"$ref":"#/definitions/flagship_JsonValue"},"type":"array"}]},"flagship_Condition":{"anyOf":[{"$ref":"#/definitions/flagship_BaseCondition"},{"$ref":"#/definitions/flagship_LogicalCondition"}]},"flagship_BaseCondition":{"type":"object","properties":{"attribute":{"type":"string","maxLength":64,"minLength":1},"operator":{"type":"string","enum":["equals","not_equals","greater_than","less_than","greater_than_or_equals","less_than_or_equals","contains","starts_with","ends_with","in","not_in","has","not_has"]},"value":{"$ref":"#/definitions/flagship_JsonValue"}},"additionalProperties":false,"required":["attribute","operator","value"]},"flagship_LogicalCondition":{"type":"object","properties":{"clauses":{"type":"array","items":{"$ref":"#/definitions/flagship_Condition1"},"minItems":1},"logical_operator":{"type":"string","enum":["AND","OR"]}},"additionalProperties":false,"required":["logical_operator","clauses"]},"flagship_Condition1":{"anyOf":[{"$ref":"#/definitions/flagship_BaseCondition"},{"$ref":"#/definitions/flagship_LogicalCondition1"}]},"flagship_LogicalCondition1":{"type":"object","properties":{"clauses":{"type":"array","items":{"$ref":"#/definitions/flagship_Condition2"},"minItems":1},"logical_operator":{"type":"string","enum":["AND","OR"]}},"additionalProperties":false,"required":["logical_operator","clauses"]},"flagship_Condition2":{"anyOf":[{"$ref":"#/definitions/flagship_BaseCondition"},{"$ref":"#/definitions/flagship_LogicalCondition2"}]},"flagship_LogicalCondition2":{"type":"object","properties":{"clauses":{"type":"array","items":{"$ref":"#/definitions/flagship_Condition3"},"minItems":1},"logical_operator":{"type":"string","enum":["AND","OR"]}},"additionalProperties":false,"required":["logical_operator","clauses"]},"flagship_Condition3":{"anyOf":[{"$ref":"#/definitions/flagship_BaseCondition"},{"$ref":"#/definitions/flagship_LogicalCondition3"}]},"flagship_LogicalCondition3":{"type":"object","properties":{"clauses":{"type":"array","items":{"$ref":"#/definitions/flagship_Condition4"},"minItems":1},"logical_operator":{"type":"string","enum":["AND","OR"]}},"additionalProperties":false,"required":["logical_operator","clauses"]},"flagship_Condition4":{"anyOf":[{"$ref":"#/definitions/flagship_BaseCondition"},{"$ref":"#/definitions/flagship_LogicalCondition4"}]},"flagship_LogicalCondition4":{"type":"object","properties":{"clauses":{"type":"array","items":{"$ref":"#/definitions/flagship_BaseCondition"},"minItems":1},"logical_operator":{"type":"string","enum":["AND","OR"]}},"additionalProperties":false,"required":["logical_operator","clauses"]}}},"name":"Update flag","id":"cloudflare.flagship_update_flag","example":{"path":{"account_id":"example","app_id":"example","flag_key":"example"},"body":{"key":"example","default_variation":"example","variations":{},"rules":[],"enabled":false}},"maxRequests":1,"summary":false}}