---
title: "Api Limit Policies Create 2"
method: POST
path: "/api/limit-policies/{id}/"
tags: ["platformApi"]
---

# Api Limit Policies Create 2

`POST /api/limit-policies/{id}/`

POST handler with superadmin-only field protection.

Strips superadmin-only fields from non-superadmin requests before
delegating to OrganizationInjectionMixin.post() for org injection.

## Path parameters

- `id` string, required

## Headers

- `Authorization` string, required

## Response `200`

- LimitPolicyDetail — Detail adds the full config blobs for the edit view. ``current_state`` and ``tags`` are inherited from the list shape — same Redis HGET + cached-tags resolution as a list row.
  - `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
  - `rules` object[], required
  - `anchor` 'calendar' | 'first_event' | 'explicit_ts', required — * `calendar` - Calendar * `first_event` - First event * `explicit_ts` - Explicit timestamp
  - `anchor_at` string, date-time, nullable, required
  - `refill_rate` number, double, nullable, 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)
