API Keys

Update an API key

Changed on

Update an existing API key. Authenticate with a management key.

Set workspace_id to move the key to another workspace.

<Warning> The request body accepts only the fields listed below, and unrecognized fields are ignored. If the body contains none of the accepted fields, the request fails with `400` and the message `No update fields provided`. </Warning>
patch/keys/{hash}

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Path parameters

hash, string required

The hash identifier of the API key to update

Example:f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943

Request body

object required
disabled, boolean

Whether to disable the API key

include_byok_in_limit, boolean

Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against limit.

limit, number double nullable

New spending limit for the API key in USD

limit_reset, 'daily' | 'weekly' | 'monthly' | 'null' nullable

New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.

name, string

New name for the API key

workspace_id, string uuid

Move the API key to this workspace. The key keeps its value; guardrail selections move with it, except direct guardrail assignments owned by the key's current workspace, which are removed along with the selections derived from them, while other workspace-scoped settings (presets, BYOK keys, broadcast destinations, routing rules) do not. Sending the key's current workspace is a no-op.

Example request

{
  "disabled": false,
  "include_byok_in_limit": true,
  "limit": 75,
  "limit_reset": "daily",
  "name": "Updated API Key Name"
}

Response

API key updated successfully

object required
data, object required

The updated API key information

Example response

{
  "data": {
    "byok_usage": 17.38,
    "byok_usage_daily": 17.38,
    "byok_usage_monthly": 17.38,
    "byok_usage_weekly": 17.38,
    "created_at": "2025-08-24T10:30:00Z",
    "creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",
    "disabled": false,
    "expires_at": null,
    "external_user": null,
    "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",
    "include_byok_in_limit": true,
    "label": "Updated API Key Name",
    "last_used_at": "2026-09-15T15:45:00Z",
    "limit": 75,
    "limit_remaining": 32.12,
    "limit_reset": "daily",
    "name": "Updated API Key Name",
    "updated_at": "2025-08-24T16:00:00Z",
    "usage": 25.5,
    "usage_daily": 25.5,
    "usage_monthly": 25.5,
    "usage_weekly": 25.5,
    "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
  }
}

Changes

    • breaking

      the name request property's minLength was increased from 0 to 1

    • warning

      the limit request property's exclusiveMaximum was set to 1000000.00

    • warning

      the name request property's maxLength was set to 256

    1 more change in this revision