> ## Documentation Index
> Fetch the complete documentation index at: https://feather.mupeni.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Flag Config

> Creates a new flag version (updates the config) for a specific environment.

This endpoint **appends** a new version — it never mutates existing rows. The new version becomes the active config immediately and the edge cache is updated.

If the environment is [protected](/docs/concepts/environments#protected-environments), this endpoint returns `403`. Use [Create Proposal](/docs/api-reference/proposals/create-proposal) instead.

## Path parameters

<ParamField path="projectId" type="string" required />

<ParamField path="envId" type="string" required />

<ParamField path="flagKey" type="string" required>
  The flag's `key`.
</ParamField>

## Body

<ParamField body="version" type="number" required>
  Must equal the current latest version plus one. If the flag has no existing version in this
  environment, send `1`. If the value does not match, the server returns `409 VERSION_CONFLICT` —
  fetch the latest version and retry.
</ParamField>

<ParamField body="enabled" type="boolean" required>
  Master toggle. `false` short-circuits all rules and returns `defaultValue`.
</ParamField>

<ParamField body="defaultValue" type="boolean | string | number" required>
  Returned when no rule matches. Must match the flag's `type`.
</ParamField>

<ParamField body="rules" type="Rule[]" required>
  Ordered list of targeting rules. See [Flag Config](/docs/concepts/flag-config) for the full rule
  schema. Pass an empty array for a simple on/off flag.
</ParamField>

<ParamField body="variants" type="Variant[]">
  Named value definitions for `string` or `number` flags.
</ParamField>

<Note>
  Using `regex` or `geo_country` operators, or setting `rolloutPercentage` on a rule, requires a
  **Pro or Enterprise** plan.
</Note>

<RequestExample>
  ```bash theme={null}
  # Simple enable
  curl -X PUT https://nest.feather.mupeni.dev/v1/projects/proj_01hx.../environments/env_01hx.../flags/new-checkout \
    -H "Authorization: Bearer <server_key>" \
    -H "Content-Type: application/json" \
    -d '{
      "version": 1,
      "enabled": true,
      "defaultValue": false,
      "rules": []
    }'
  ```

  ```bash theme={null}
  # With targeting rule
  curl -X PUT https://nest.feather.mupeni.dev/v1/projects/proj_01hx.../environments/env_01hx.../flags/new-checkout \
    -H "Authorization: Bearer <server_key>" \
    -H "Content-Type: application/json" \
    -d '{
      "version": 2,
      "enabled": true,
      "defaultValue": false,
      "rules": [
        {
          "id": "rule-beta",
          "name": "Beta users",
          "enabled": true,
          "conditionOperator": "AND",
          "conditions": [
            { "attribute": "plan", "operator": "equals", "value": "beta" }
          ],
          "value": true
        }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "fv_02hx...",
    "flagId": "flag_01hx...",
    "environmentId": "env_01hx...",
    "version": 2,
    "config": {
      "version": 2,
      "enabled": true,
      "defaultValue": false,
      "rules": []
    },
    "createdAt": "2024-04-02T08:00:00.000Z"
  }
  ```

  ```json 403 theme={null}
  {
    "error": {
      "code": "PROTECTED_ENVIRONMENT",
      "message": "This environment requires a change proposal. Use POST /proposals instead."
    }
  }
  ```

  ```json 409 theme={null}
  {
    "error": {
      "code": "VERSION_CONFLICT",
      "message": "Expected version 3, got 2. Fetch the latest version and retry."
    }
  }
  ```

  ```json 207 theme={null}
  {
    "id": "fv_02hx...",
    "version": 2,
    "syncWarning": "Edge cache sync failed: timeout. Config saved but evaluations may serve stale data."
  }
  ```
</ResponseExample>
