---
title: "Update Key Fn"
method: POST
path: "/key/update"
tags: ["key management"]
---

# Update Key Fn

`POST /key/update`

Update an existing API key's parameters.

Parameters:
- key: str - The key to update
- key_alias: Optional[str] - User-friendly key alias
- user_id: Optional[str] - User ID associated with key
- team_id: Optional[str] - Team ID associated with key
- agent_id: Optional[str] - The agent id associated with the key.
- organization_id: Optional[str] - The organization id of the key.
- budget_id: Optional[str] - The budget id associated with the key. Created by calling `/budget/new`.
- models: Optional[list] - Model_name's a user is allowed to call
- tags: Optional[List[str]] - Tags for organizing keys (Enterprise only)
- prompts: Optional[List[str]] - List of prompts that the key is allowed to use.
- enforced_params: Optional[List[str]] - List of enforced params for the key (Enterprise only). [Docs](https://docs.litellm.ai/docs/proxy/enterprise#enforce-required-params-for-llm-requests)
- spend: Optional[float] - Amount spent by key
- max_budget: Optional[float] - Max budget for key
- model_max_budget: Optional[Dict[str, BudgetConfig]] - Model-specific budgets {"gpt-4": {"budget_limit": 0.0005, "time_period": "30d"}}
- budget_duration: Optional[str] - Budget reset period ("30d", "1h", etc.)
- soft_budget: Optional[float] - [TODO] Soft budget limit (warning vs. hard stop). Will trigger a slack alert when this soft budget is reached.
- max_parallel_requests: Optional[int] - Rate limit for parallel requests
- metadata: Optional[dict] - Metadata for key. Example {"team": "core-infra", "app": "app2"}
- tpm_limit: Optional[int] - Tokens per minute limit
- rpm_limit: Optional[int] - Requests per minute limit
- model_rpm_limit: Optional[dict] - Model-specific RPM limits {"gpt-4": 100, "claude-v1": 200}
- model_tpm_limit: Optional[dict] - Model-specific TPM limits {"gpt-4": 100000, "claude-v1": 200000}
- tpm_limit_type: Optional[str] - TPM rate limit type - "best_effort_throughput", "guaranteed_throughput", or "dynamic"
- rpm_limit_type: Optional[str] - RPM rate limit type - "best_effort_throughput", "guaranteed_throughput", or "dynamic"
- allowed_cache_controls: Optional[list] - List of allowed cache control values
- duration: Optional[str] - Key validity duration ("30d", "1h", etc.), null to never expire, or "-1" to never expire (deprecated, use null)
- permissions: Optional[dict] - Key-specific permissions
- send_invite_email: Optional[bool] - Send invite email to user_id
- guardrails: Optional[List[str]] - List of active guardrails for the key
- policies: Optional[List[str]] - List of policy names to apply to the key. Policies define guardrails, conditions, and inheritance rules.
- disable_global_guardrails: Optional[bool] - Whether to disable global guardrails for the key.
- prompts: Optional[List[str]] - List of prompts that the key is allowed to use.
- blocked: Optional[bool] - Whether the key is blocked
- aliases: Optional[dict] - Model aliases for the key - [Docs](https://litellm.vercel.app/docs/proxy/virtual_keys#model-aliases)
- config: Optional[dict] - [DEPRECATED PARAM] Key-specific config.
- temp_budget_increase: Optional[float] - Temporary budget increase for the key (Enterprise only).
- temp_budget_expiry: Optional[str] - Expiry time for the temporary budget increase (Enterprise only).
- allowed_routes: Optional[list] - List of allowed routes for the key. Store the actual route or store a wildcard pattern for a set of routes. Example - ["/chat/completions", "/embeddings", "/keys/*"]
- allowed_passthrough_routes: Optional[list] - List of allowed pass through routes for the key. Store the actual route or store a wildcard pattern for a set of routes. Example - ["/my-custom-endpoint"]. Use this instead of allowed_routes, if you just want to specify which pass through routes the key can access, without specifying the routes. If allowed_routes is specified, allowed_passthrough_routes is ignored.
- prompts: Optional[List[str]] - List of allowed prompts for the key. If specified, the key will only be able to use these specific prompts.
- object_permission: Optional[LiteLLM_ObjectPermissionBase] - key-specific object permission. Example - {"vector_stores": ["vector_store_1", "vector_store_2"], "agents": ["agent_1", "agent_2"], "agent_access_groups": ["dev_group"]}. IF null or {} then no object permission.
- auto_rotate: Optional[bool] - Whether this key should be automatically rotated
- rotation_interval: Optional[str] - How often to rotate this key (e.g., '30d', '90d'). Required if auto_rotate=True
- allowed_vector_store_indexes: Optional[List[dict]] - List of allowed vector store indexes for the key. Example - [{"index_name": "my-index", "index_permissions": ["write", "read"]}]. If specified, the key will only be able to use these specific vector store indexes. Create index, using `/v1/indexes` endpoint.
- router_settings: Optional[UpdateRouterConfig] - key-specific router settings. Example - {"model_group_retry_policy": {"max_retries": 5}}. IF null or {} then no router settings.
- access_group_ids: Optional[List[str]] - List of access group IDs to associate with the key. Access groups define which models a key can access. Example - ["access_group_1", "access_group_2"].

Example:
```bash
curl --location 'http://0.0.0.0:4000/key/update'     --header 'Authorization: Bearer sk-1234'     --header 'Content-Type: application/json'     --data '{
    "key": "sk-1234",
    "key_alias": "my-key",
    "user_id": "user-1234",
    "team_id": "team-1234",
    "max_budget": 100,
    "metadata": {"any_key": "any-val"},
}'
```

## Headers

- `litellm-changed-by` string, nullable — The litellm-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability

## Request body

- UpdateKeyRequest
  - `key_alias` string, nullable
  - `duration` string, nullable
  - `models` unknown[], nullable
    - unknown
  - `spend` number, nullable
  - `max_budget` number, nullable
  - `user_id` string, nullable
  - `team_id` string, nullable
  - `agent_id` string, nullable
  - `max_parallel_requests` integer, nullable
  - `metadata` object, nullable
  - `tpm_limit` integer, nullable
  - `rpm_limit` integer, nullable
  - `budget_duration` string, nullable
  - `allowed_cache_controls` unknown[], nullable
    - unknown
  - `config` object, nullable
  - `permissions` object, nullable
  - `model_max_budget` object, nullable
  - `model_rpm_limit` object, nullable
  - `model_tpm_limit` object, nullable
  - `guardrails` string[], nullable
  - `policies` string[], nullable
  - `prompts` string[], nullable
  - `blocked` boolean, nullable
  - `aliases` object, nullable
  - `object_permission` LiteLLMObjectPermissionBase
    - `mcp_servers` string[], nullable
    - `mcp_access_groups` string[], nullable
    - `mcp_tool_permissions` object, nullable
    - `vector_stores` string[], nullable
    - `agents` string[], nullable
    - `agent_access_groups` string[], nullable
    - `models` string[], nullable
  - `key` string, required
  - `budget_id` string, nullable
  - `tags` string[], nullable
  - `enforced_params` string[], nullable
  - `allowed_routes` unknown[], nullable
    - unknown
  - `allowed_passthrough_routes` unknown[], nullable
    - unknown
  - `allowed_vector_store_indexes` AllowedVectorStoreIndexItem[], nullable
    - `index_name` string, required
    - `index_permissions` string[], required
  - `rpm_limit_type` 'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic', nullable
  - `tpm_limit_type` 'guaranteed_throughput' | 'best_effort_throughput' | 'dynamic', nullable
  - `router_settings` UpdateRouterConfig — Set of params that you can modify via `router.update_settings()`.
    - `routing_strategy_args` object, nullable
    - `routing_strategy` string, nullable
    - `model_group_retry_policy` object, nullable
    - `allowed_fails` integer, nullable
    - `cooldown_time` number, nullable
    - `num_retries` integer, nullable
    - `timeout` number, nullable
    - `max_retries` integer, nullable
    - `retry_after` number, nullable
    - `fallbacks` object[], nullable
    - `context_window_fallbacks` object[], nullable
    - `model_group_alias` object, nullable
  - `access_group_ids` string[], nullable
  - `temp_budget_increase` number, nullable
  - `temp_budget_expiry` string, date-time, nullable
  - `auto_rotate` boolean, nullable
  - `rotation_interval` string, nullable
  - `organization_id` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/sea-lion/apis/litellm-api.md) · [All operations](https://skmtc.net/sea-lion/apis/litellm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sea-lion/litellm-api/revisions/79928a3d37d3/schema)
