---
title: "Update a limit policy"
description: "Update the policy configuration. Immutable fields are ignored. Changing or deleting a policy needs the dashboard, or an API key explicitly granted the `limit_policies` permission; the `*` permission doesn't count. Any key can create policies."
---

<a id="playground-button:docs/apis/limit-policies/update-limit-policy"></a>

**PATCH** `https://api.respan.ai/api/limit-policies/{id}/`

Update the policy configuration. Immutable fields are ignored. Changing or deleting a policy needs the dashboard, or an API key explicitly granted the `limit_policies` permission; the `*` permission doesn't count. Any key can create policies.

## Servers

`https://api.respan.ai`: Respan API Server

<a id="request.auth"></a>

## Authentication

<a id="request.auth.Authorization"></a>

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


<a id="request.path"></a>

## Path parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.path.id"></a>`id` | `string` | Required | Limit policy id.<br />Format: `uuid` |


<a id="request"></a>

## Request body

A request body is required.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | Only `name`, `scope`, `rules`, `priority`, and `is_active` are mutable. Other fields would change the policy identity and are ignored.<br />Reference: `#/components/schemas/LimitPolicyUpdateRequest` |
| <a id="request.body.name"></a>`name` | `string` | Optional | - |
| <a id="request.body.scope"></a>`scope` | `string` | Optional | - |
| <a id="request.body.rules"></a>`rules` | `array<object>` | Optional | - |
| `rules[]` | `object` | Array item | Reference: `#/components/schemas/LimitPolicyRule` |
| `rules[].trigger` | `object` | Required in parent | Threshold condition. Common shape: `{"counter": {"operator": "gte", "value": 10000}}`.<br />Additional properties are allowed |
| `rules[].severity` | `string` | Required in parent | `soft` fires an alert without blocking; `hard` blocks the request with 429.<br />Allowed: `"soft"`, `"hard"` |
| `rules[].description` | `string or null` | Optional | Shown in events and alert payloads. |
| `rules[].is_active` | `boolean` | Optional | Default: `true` |
| `rules[].notification_method_id` | `string or null` | Optional | Optional OrganizationNotificationMethod id to ping when this rule trips. |
| <a id="request.body.priority"></a>`priority` | `integer` | Optional | - |
| <a id="request.body.is_active"></a>`is_active` | `boolean` | Optional | - |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "$ref": "#/components/schemas/LimitPolicyUpdateRequest"
}
```

</details>

<a id="response"></a>

## Responses

### 200

The updated policy.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | A stored cap: watch a scope, measure a metric, refill on a cadence, and fire rules at thresholds.<br />Reference: `#/components/schemas/LimitPolicy` |
| <a id="response.body.id"></a>`id` | `string` | Optional | Format: `uuid`<br />Read only |
| <a id="response.body.name"></a>`name` | `string` | Optional | Human label. |
| <a id="response.body.scope"></a>`scope` | `string` | Optional | Display category (e.g. `API Key`, `Model`). Not used for matching. |
| <a id="response.body.scope_value"></a>`scope_value` | `string` | Optional | Identity to meter. For composites, a JSON list of values in `compose` order. |
| <a id="response.body.compose"></a>`compose` | `array<string>` | Optional | Empty for single-dimension policies. Members: `organization_id`, `api_key_id`, `user_id`, `customer_identifier`, `model`, `endpoint`. |
| `compose[]` | `string` | Array item | - |
| <a id="response.body.metric"></a>`metric` | `string` | Optional | What the cap counts. `cost` is US dollars, `token_count` is total tokens, `request_count` is calls.<br />Allowed: `"cost"`, `"request_count"`, `"token_count"`<br />Default: `cost` |
| <a id="response.body.algorithm"></a>`algorithm` | `string` | Optional | `balance_fixed_window` is the shipped algorithm. `token_bucket` is reserved and not yet enforced.<br />Allowed: `"balance_fixed_window"`<br />Default: `balance_fixed_window` |
| <a id="response.body.period"></a>`period` | `string or null` | Optional | Cadence. A named bucket (`minute`, `hour`, `day`, `week`, `month`), a positive integer of seconds as a string, or `null` for a cumulative (lifetime) cap that never resets. |
| <a id="response.body.anchor"></a>`anchor` | `string` | Optional | When a recurring window aligns. `calendar` resets on the boundary (e.g. the 1st of the month).<br />Allowed: `"calendar"`, `"first_event"`, `"explicit_ts"`<br />Default: `calendar` |
| <a id="response.body.anchor_at"></a>`anchor_at` | `string or null` | Optional | Required when `anchor` is not `calendar`.<br />Format: `date-time` |
| <a id="response.body.effective_at"></a>`effective_at` | `string or null` | Optional | Active-range start. `null` = live since forever.<br />Format: `date-time` |
| <a id="response.body.expires_at"></a>`expires_at` | `string or null` | Optional | Active-range end. `null` = live until deactivated. Must be after `effective_at`.<br />Format: `date-time` |
| <a id="response.body.priority"></a>`priority` | `integer` | Optional | Higher is checked first.<br />Default: `0` |
| <a id="response.body.is_active"></a>`is_active` | `boolean` | Optional | Default: `true` |
| <a id="response.body.rules"></a>`rules` | `array<object>` | Optional | Any number of soft rules and at most one effective hard rule. |
| `rules[]` | `object` | Array item | Reference: `#/components/schemas/LimitPolicyRule` |
| `rules[].trigger` | `object` | Required in parent | Threshold condition. Common shape: `{"counter": {"operator": "gte", "value": 10000}}`.<br />Additional properties are allowed |
| `rules[].severity` | `string` | Required in parent | `soft` fires an alert without blocking; `hard` blocks the request with 429.<br />Allowed: `"soft"`, `"hard"` |
| `rules[].description` | `string or null` | Optional | Shown in events and alert payloads. |
| `rules[].is_active` | `boolean` | Optional | Default: `true` |
| `rules[].notification_method_id` | `string or null` | Optional | Optional OrganizationNotificationMethod id to ping when this rule trips. |
| <a id="response.body.threshold_value"></a>`threshold_value` | `number` | Optional | First hard-rule threshold; falls back to the largest soft threshold.<br />Read only |
| <a id="response.body.meter_definition_id"></a>`meter_definition_id` | `string` | Optional | Stable hash of the policy identity. Same identity resolves to the same id across recreations.<br />Read only |
| <a id="response.body.current_state"></a>`current_state` | `object` | Optional | Live counter for the current window instance.<br />Reference: `#/components/schemas/LimitPolicyCurrentState` |
| `current_state.meter_id` | `string` | Optional | - |
| `current_state.interval_start` | `integer or null` | Optional | Epoch seconds, inclusive. |
| `current_state.interval_end` | `integer or null` | Optional | Epoch seconds, exclusive. |
| `current_state.current_value` | `number` | Optional | Accumulated value in this window. |
| <a id="response.body.created_at"></a>`created_at` | `string` | Optional | Format: `date-time`<br />Read only |
| <a id="response.body.updated_at"></a>`updated_at` | `string` | Optional | Format: `date-time`<br />Read only |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "$ref": "#/components/schemas/LimitPolicy"
}
```

</details>

<a id="response.error"></a>

### 403

The API key is missing, invalid or expired, or it isn't explicitly granted the `limit_policies` permission.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Limits can only be changed from the dashboard, or by an API key explicitly granted the matching 'limit_policies' permission. No API key can change the spending limit, rate limit, usage quota, or limit policies that cap the key itself."
}
```


### 404

Limit policy not found.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "No LimitPolicy matches the given query."
}
```


## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Update a limit policy",
  "operationId": "update_limit_policy",
  "tags": [
    "Limit Policies"
  ],
  "description": "Update the policy configuration. Immutable fields are ignored. Changing or deleting a policy needs the dashboard, or an API key explicitly granted the `limit_policies` permission; the `*` permission doesn't count. Any key can create policies.",
  "parameters": [
    {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string",
        "format": "uuid"
      },
      "description": "Limit policy id."
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/LimitPolicyUpdateRequest"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "The updated policy.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/LimitPolicy"
          }
        }
      }
    },
    "403": {
      "description": "The API key is missing, invalid or expired, or it isn't explicitly granted the `limit_policies` permission.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Limits can only be changed from the dashboard, or by an API key explicitly granted the matching 'limit_policies' permission. No API key can change the spending limit, rate limit, usage quota, or limit policies that cap the key itself."
          }
        }
      }
    },
    "404": {
      "description": "Limit policy not found.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "No LimitPolicy matches the given query."
          }
        }
      }
    }
  },
  "security": [
    {
      "RespanApiKey": []
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "schemas": {
    "LimitPolicy": {
      "type": "object",
      "description": "A stored cap: watch a scope, measure a metric, refill on a cadence, and fire rules at thresholds.",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "readOnly": true
        },
        "name": {
          "type": "string",
          "description": "Human label."
        },
        "scope": {
          "type": "string",
          "description": "Display category (e.g. `API Key`, `Model`). Not used for matching."
        },
        "scope_value": {
          "type": "string",
          "description": "Identity to meter. For composites, a JSON list of values in `compose` order."
        },
        "compose": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Empty for single-dimension policies. Members: `organization_id`, `api_key_id`, `user_id`, `customer_identifier`, `model`, `endpoint`."
        },
        "metric": {
          "type": "string",
          "enum": [
            "cost",
            "request_count",
            "token_count"
          ],
          "default": "cost",
          "description": "What the cap counts. `cost` is US dollars, `token_count` is total tokens, `request_count` is calls."
        },
        "algorithm": {
          "type": "string",
          "enum": [
            "balance_fixed_window"
          ],
          "default": "balance_fixed_window",
          "description": "`balance_fixed_window` is the shipped algorithm. `token_bucket` is reserved and not yet enforced."
        },
        "period": {
          "type": "string",
          "nullable": true,
          "description": "Cadence. A named bucket (`minute`, `hour`, `day`, `week`, `month`), a positive integer of seconds as a string, or `null` for a cumulative (lifetime) cap that never resets."
        },
        "anchor": {
          "type": "string",
          "enum": [
            "calendar",
            "first_event",
            "explicit_ts"
          ],
          "default": "calendar",
          "description": "When a recurring window aligns. `calendar` resets on the boundary (e.g. the 1st of the month)."
        },
        "anchor_at": {
          "type": "string",
          "format": "date-time",
          "nullable": true,
          "description": "Required when `anchor` is not `calendar`."
        },
        "effective_at": {
          "type": "string",
          "format": "date-time",
          "nullable": true,
          "description": "Active-range start. `null` = live since forever."
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "nullable": true,
          "description": "Active-range end. `null` = live until deactivated. Must be after `effective_at`."
        },
        "priority": {
          "type": "integer",
          "default": 0,
          "description": "Higher is checked first."
        },
        "is_active": {
          "type": "boolean",
          "default": true
        },
        "rules": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/LimitPolicyRule"
          },
          "description": "Any number of soft rules and at most one effective hard rule."
        },
        "threshold_value": {
          "type": "number",
          "readOnly": true,
          "description": "First hard-rule threshold; falls back to the largest soft threshold."
        },
        "meter_definition_id": {
          "type": "string",
          "readOnly": true,
          "description": "Stable hash of the policy identity. Same identity resolves to the same id across recreations."
        },
        "current_state": {
          "$ref": "#/components/schemas/LimitPolicyCurrentState"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "readOnly": true
        }
      }
    },
    "LimitPolicyCurrentState": {
      "type": "object",
      "description": "Live counter for the current window instance.",
      "properties": {
        "meter_id": {
          "type": "string"
        },
        "interval_start": {
          "type": "integer",
          "nullable": true,
          "description": "Epoch seconds, inclusive."
        },
        "interval_end": {
          "type": "integer",
          "nullable": true,
          "description": "Epoch seconds, exclusive."
        },
        "current_value": {
          "type": "number",
          "description": "Accumulated value in this window."
        }
      }
    },
    "LimitPolicyRule": {
      "type": "object",
      "required": [
        "trigger",
        "severity"
      ],
      "properties": {
        "trigger": {
          "type": "object",
          "additionalProperties": true,
          "description": "Threshold condition. Common shape: `{\"counter\": {\"operator\": \"gte\", \"value\": 10000}}`."
        },
        "severity": {
          "type": "string",
          "enum": [
            "soft",
            "hard"
          ],
          "description": "`soft` fires an alert without blocking; `hard` blocks the request with 429."
        },
        "description": {
          "type": "string",
          "description": "Shown in events and alert payloads.",
          "nullable": true
        },
        "is_active": {
          "type": "boolean",
          "default": true
        },
        "notification_method_id": {
          "type": "string",
          "nullable": true,
          "description": "Optional OrganizationNotificationMethod id to ping when this rule trips."
        }
      }
    },
    "LimitPolicyUpdateRequest": {
      "type": "object",
      "description": "Only `name`, `scope`, `rules`, `priority`, and `is_active` are mutable. Other fields would change the policy identity and are ignored.",
      "properties": {
        "name": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "rules": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/LimitPolicyRule"
          }
        },
        "priority": {
          "type": "integer"
        },
        "is_active": {
          "type": "boolean"
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
