---
title: "Set a flag's value in one environment, and/or flip its kill switch."
method: PUT
path: "/projects/{project_id}/flags/{key}/environments/{environment_id}"
tags: ["Feature Flags"]
---

# Set a flag's value in one environment, and/or flip its kill switch.

`PUT /projects/{project_id}/flags/{key}/environments/{environment_id}`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/flags/{key}/environments/{environment_id}`
- Auth: HTTP bearer

## Path parameters

- `project_id` integer, required
- `key` string, required
- `environment_id` integer, required

## Request body

- SetFlagEnvironmentRequest
  - `enabled` boolean, nullable: The kill switch. `false` makes the flag serve its default regardless of any override — and, once targeting exists, regardless of any rule.
  - `value` unknown

## Response `200`

Environment value set

- FlagEnvironmentResponse
  - `enabled` boolean, required
  - `environment_id` integer, required
  - `rules` FlagRule[], required: Ordered targeting rules; first match wins.
    - `conditions` RuleCondition[]: All must hold. Empty means every subject.
      - `attribute` string, required: Context attribute name, e.g. `plan`, `country`, `email`.
      - `operator` 'eq' | 'neq' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'matches' | 'gt' | 'gte' | 'lt' | 'lte' | 'exists' | 'not_exists', required: Comparison applied by one rule condition.
      - `value` union: The right-hand side of a condition: one value, or a list for `in`/`not_in`.
        - AttributeValue[]
          - union: A targeting attribute: what the caller (or the server, implicitly) knows about the subject.
            - boolean
            - number, double
            - string
        - union: A targeting attribute: what the caller (or the server, implicitly) knows about the subject.
          - boolean
          - number, double
          - string
    - `description` string, nullable: Free text shown in the console, e.g. "Beta customers".
    - `rollout_percentage` number, double, nullable: Share of matching subjects the rule applies to, `0..=100`. `None` means all of them. Ramping it up never removes anyone already included.
    - `serve` union, required: What a matching rule serves.
      - object: A literal value of the flag's type.
        - `kind` 'value', required
        - `value` unknown, required
      - object: One declared variant.
        - `kind` 'variant', required
        - `variant` string, required
      - object: Subjects split across declared variants by weight, stably per subject.
        - `kind` 'split', required
        - `split` VariantWeight[], required
          - `variant` string, required: A variant key declared on the flag.
          - `weight` integer, required: Share of the rule's subjects, in whole percent. A split's weights sum to 100.
  - `rules_valid` boolean, required: `false` when the stored rules could not be decoded. The flag then serves its default with reason `ERROR` until they are replaced.
  - `updated_at` string, required: Send back as `expected_updated_at` when replacing the rules.
  - `value` unknown

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Flag or environment not found
- `500`: Internal server error

## Changes

- **2026-11-20** `68c970dc603c`: 3 info
  - added the required property `rules` to the response with the `200` status
  - added the required property `rules_valid` to the response with the `200` status
  - added the required property `updated_at` to the response with the `200` status
- **2026-08-04** `c647b6ab1d2c`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/flags/:key/environments/:environment_id/put.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
