---
title: "Api Limit Policies Update"
method: PUT
path: "/api/limit-policies/"
tags: ["platformApi"]
---

# Api Limit Policies Update

`PUT /api/limit-policies/`

PUT handler with superadmin lock and field protection.

Same as patch() - checks lock and field protection before delegating.

## Headers

- `Authorization` string, required

## Response `200`

- LimitPolicyList — Standard CRUD list — PG fields + live counter state + tags. ``threshold_value`` is derived from ``rules`` (there is no stand- alone ``amount`` column after #2333 — "rules dominate"). Picks the first hard rule's counter trigger value, or the largest soft rule value if no hard rule is present. The helper lives in ``limit.utils.enrichment`` so the live-``/list/`` endpoint and this CRUD list surface the same field semantics. ``current_state`` exposes the live Redis counter so the FE table can render usage / threshold without a second round-trip. ``tags`` is the ``GenericTag`` rows assigned to this policy via the generic tag- assignment system (``feature_type=limit_policies``).
  - `id` string, required
  - `name` string, required
  - `scope` string, required
  - `scope_value` string, required
  - `compose` string[], required
  - `metric` 'cost' | 'request_count' | 'token_count', required — * `cost` - Cost * `request_count` - Request count * `token_count` - Token count
  - `algorithm` 'balance_fixed_window' | 'token_bucket', required — * `balance_fixed_window` - Balance fixed window * `token_bucket` - Token bucket
  - `period` string, nullable, required
  - `effective_at` string, date-time, nullable, required
  - `expires_at` string, date-time, nullable, required
  - `priority` integer, required
  - `is_active` boolean, required
  - `threshold_value` number, double, required
  - `meter_definition_id` string, required
  - `updated_by` Editor, required
    - `id` integer, required
    - `email` string, required
    - `name` string, required
    - `username` string
    - `first_name` string
    - `last_name` string
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required
  - `current_state` LimitPolicyCurrentState, required — Live counter state for ONE policy in its current window. Nested on ``LimitPolicyListSerializer`` / ``LimitPolicyDetailSerializer``. Produced by one Redis ``HGET limit:fw:{meter_id} counter`` — the detail endpoint knows the exact ``meter_definition_id`` so it can skip CH and hit Redis directly. The list endpoint batches the HGETs into a single pipeline RTT via ``LimitPoliciesView``'s prefetch hook so every row in a page resolves without N round-trips. Same field names as the per-row live fields on ``LimitPolicyStateRowSerializer`` so the FE reuses one gauge component across both shapes. Fail-open: Redis errors, unresolvable period, unsupported algorithm (``token_bucket`` is stubbed in v1) all collapse to zeros + null bounds rather than 5xx-ing the config read.
    - `meter_id` string, required — Instance-level meter id — ``{meter_definition_id}:{window_start_epoch}``. Empty when the current window can't be computed (e.g. unsupported algorithm).
    - `interval_start` integer, nullable, required — Epoch seconds. Inclusive start of the window instance the counter accumulates into. Null for algorithms without a window (``token_bucket``) or when fail-open fell through.
    - `interval_end` integer, nullable, required — Epoch seconds. Exclusive end — ``interval_start + period_seconds``. Null under the same conditions as ``interval_start``.
    - `current_value` number, double, required — Consumed value in the current window (same unit as ``threshold_value``). ``0.0`` for missing counter keys (no events yet in this window) and for every fail-open branch so the FE gauge degrades gracefully instead of surfacing an error.
  - `tags` GenericTagDisplay[], required — ``GenericTag`` rows assigned to this policy. Managed via ``/api/tag-assignments/limit_policies/...`` — read-only here.
    - `id` string, required
    - `name` string, required
    - `color` string, required
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required

---

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