---
title: "Update flag rules"
method: PUT
path: "/flags/{flag_id}/rules"
tags: ["features"]
---

# Update flag rules

`PUT /flags/{flag_id}/rules`

## Path parameters

- `flag_id` string, required

## Request body

- UpdateFlagRulesRequestBody
  - `rules` CreateOrUpdateRuleRequestBody[], required
    - `condition_groups` CreateOrUpdateConditionGroupRequestBody[], required
      - `conditions` CreateOrUpdateConditionRequestBody[], required
        - `comparison_trait_id` string, nullable — Optionally provide a trait ID to compare a metric or trait value against instead of a value
        - `condition_type` 'base_plan' | 'billing_product' | 'company' | 'credit' | 'metric' | 'plan' | 'plan_version' | 'trait' | 'user', required
        - `credit_cost` number, double, nullable — Cost of credit to use to measure this condition
        - `credit_id` string, nullable — ID of credit to use to measure this condition
        - `event_subtype` string, nullable — Name of track event type used to measure this condition
        - `id` string, nullable
        - `metric_period` 'all_time' | 'current_day' | 'current_month' | 'current_week'
        - `metric_period_month_reset` 'billing_cycle' | 'first_of_month'
        - `metric_value` integer, nullable — Value to compare the track event metric against
        - `operator` 'eq' | 'gt' | 'gte' | 'is_empty' | 'lt' | 'lte' | 'not_empty' | 'ne', required
        - `resource_ids` string[], required — List of resource IDs (companies, users, or plans) targeted by this condition
        - `trait_id` string, nullable — ID of trait to use to measure this condition
        - `trait_value` string, nullable — Value to compare the trait value against
      - `flag_id` string, nullable
      - `id` string, nullable
    - `conditions` CreateOrUpdateConditionRequestBody[], required
      - `comparison_trait_id` string, nullable — Optionally provide a trait ID to compare a metric or trait value against instead of a value
      - `condition_type` 'base_plan' | 'billing_product' | 'company' | 'credit' | 'metric' | 'plan' | 'plan_version' | 'trait' | 'user', required
      - `credit_cost` number, double, nullable — Cost of credit to use to measure this condition
      - `credit_id` string, nullable — ID of credit to use to measure this condition
      - `event_subtype` string, nullable — Name of track event type used to measure this condition
      - `id` string, nullable
      - `metric_period` 'all_time' | 'current_day' | 'current_month' | 'current_week'
      - `metric_period_month_reset` 'billing_cycle' | 'first_of_month'
      - `metric_value` integer, nullable — Value to compare the track event metric against
      - `operator` 'eq' | 'gt' | 'gte' | 'is_empty' | 'lt' | 'lte' | 'not_empty' | 'ne', required
      - `resource_ids` string[], required — List of resource IDs (companies, users, or plans) targeted by this condition
      - `trait_id` string, nullable — ID of trait to use to measure this condition
      - `trait_value` string, nullable — Value to compare the trait value against
    - `id` string, nullable
    - `name` string, required
    - `priority` integer, required
    - `rule_type` 'company_override' | 'company_override_usage_exceeded' | 'default' | 'global_override' | 'plan_entitlement' | 'plan_entitlement_usage_exceeded' | 'standard'
    - `value` boolean, required

## Response `200`

OK

- object
  - `data` RulesDetailResponseData, required
    - `flag` FlagResponseData
      - `created_at` string, date-time, required
      - `default_value` boolean, required
      - `description` string, required
      - `feature_id` string, nullable
      - `flag_type` 'boolean', required
      - `id` string, required
      - `key` string, required
      - `maintainer_account_member_id` string, nullable
      - `name` string, required
      - `updated_at` string, date-time, required
    - `rules` RuleDetailResponseData[], required
      - `condition_groups` RuleConditionGroupDetailResponseData[], required
        - `conditions` RuleConditionDetailResponseData[], required
          - `comparison_trait` EntityTraitDefinitionResponseData
            - `created_at` string, date-time, required
            - `display_name` string, required
            - `entity_type` 'company' | 'user', required
            - `hierarchy` string[], required
            - `id` string, required
            - `trait_type` 'boolean' | 'currency' | 'date' | 'number' | 'string' | 'url', required
            - `updated_at` string, date-time, required
          - `comparison_trait_id` string, nullable
          - `condition_group_id` string, nullable
          - `condition_type` 'base_plan' | 'billing_product' | 'company' | 'credit' | 'metric' | 'plan' | 'plan_version' | 'trait' | 'user', required
          - `created_at` string, date-time, required
          - `environment_id` string, required
          - `event_subtype` string, nullable
          - `flag_id` string, nullable
          - `id` string, required
          - `metric_period` 'all_time' | 'current_day' | 'current_month' | 'current_week'
          - `metric_period_month_reset` 'billing_cycle' | 'first_of_month'
          - `metric_value` integer, nullable
          - `operator` 'eq' | 'gt' | 'gte' | 'is_empty' | 'lt' | 'lte' | 'not_empty' | 'ne', required
          - `resource_ids` string[], required
          - `resources` PreviewObjectResponseData[], required
            - `description` string, nullable
            - `id` string, required
            - `image_url` string, nullable
            - `name` string, required
          - `rule_id` string, required
          - `trait` EntityTraitDefinitionResponseData
            - `created_at` string, date-time, required
            - `display_name` string, required
            - `entity_type` 'company' | 'user', required
            - `hierarchy` string[], required
            - `id` string, required
            - `trait_type` 'boolean' | 'currency' | 'date' | 'number' | 'string' | 'url', required
            - `updated_at` string, date-time, required
          - `trait_entity_type` 'company' | 'user'
          - `trait_id` string, nullable
          - `trait_value` string, required
          - `updated_at` string, date-time, required
        - `created_at` string, date-time, required
        - `environment_id` string, required
        - `flag_id` string, nullable
        - `id` string, required
        - `rule_id` string, required
        - `updated_at` string, date-time, required
      - `conditions` RuleConditionDetailResponseData[], required
        - `comparison_trait` EntityTraitDefinitionResponseData
          - `created_at` string, date-time, required
          - `display_name` string, required
          - `entity_type` 'company' | 'user', required
          - `hierarchy` string[], required
          - `id` string, required
          - `trait_type` 'boolean' | 'currency' | 'date' | 'number' | 'string' | 'url', required
          - `updated_at` string, date-time, required
        - `comparison_trait_id` string, nullable
        - `condition_group_id` string, nullable
        - `condition_type` 'base_plan' | 'billing_product' | 'company' | 'credit' | 'metric' | 'plan' | 'plan_version' | 'trait' | 'user', required
        - `created_at` string, date-time, required
        - `environment_id` string, required
        - `event_subtype` string, nullable
        - `flag_id` string, nullable
        - `id` string, required
        - `metric_period` 'all_time' | 'current_day' | 'current_month' | 'current_week'
        - `metric_period_month_reset` 'billing_cycle' | 'first_of_month'
        - `metric_value` integer, nullable
        - `operator` 'eq' | 'gt' | 'gte' | 'is_empty' | 'lt' | 'lte' | 'not_empty' | 'ne', required
        - `resource_ids` string[], required
        - `resources` PreviewObjectResponseData[], required
          - `description` string, nullable
          - `id` string, required
          - `image_url` string, nullable
          - `name` string, required
        - `rule_id` string, required
        - `trait` EntityTraitDefinitionResponseData
          - `created_at` string, date-time, required
          - `display_name` string, required
          - `entity_type` 'company' | 'user', required
          - `hierarchy` string[], required
          - `id` string, required
          - `trait_type` 'boolean' | 'currency' | 'date' | 'number' | 'string' | 'url', required
          - `updated_at` string, date-time, required
        - `trait_entity_type` 'company' | 'user'
        - `trait_id` string, nullable
        - `trait_value` string, required
        - `updated_at` string, date-time, required
      - `created_at` string, date-time, required
      - `environment_id` string, required
      - `flag_id` string, nullable
      - `id` string, required
      - `name` string, required
      - `priority` integer, required
      - `rule_type` 'company_override' | 'company_override_usage_exceeded' | 'default' | 'global_override' | 'plan_entitlement' | 'plan_entitlement_usage_exceeded' | 'standard', required
      - `updated_at` string, date-time, required
      - `value` boolean, required
  - `params` object, required — Input parameters

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not found
- `500` — Server error

---

[API](https://skmtc.net/schematichq/apis/schematic-api.md) · [All operations](https://skmtc.net/schematichq/apis/schematic-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/schematichq/schematic-api/versions/873fb318b08a/schema)
