---
title: "Update organization API key"
method: PATCH
path: "/v1/management/api-keys/{keyId}"
tags: ["Management"]
---

# Update organization API key

`PATCH /v1/management/api-keys/{keyId}`

## Request

- Base URL: `https://api.tokenlab.sh`
- URL: `https://api.tokenlab.sh/v1/management/api-keys/{keyId}`
- Auth: HTTP bearer

Updates a user-managed API key for the current organization management token.

## Path parameters

- `keyId` string, required

## Request body

- object: At least one field must be provided.
  - `status` 'active' | 'inactive' | 'suspended' | 'revoked': Lifecycle status for the user API key.
  - `name` string: Updated display name. Length must be 1-50 characters after trimming.
  - `limitAmount` number, nullable: Updated spending limit input in USD. `null` means unlimited and `0` means zero quota.
  - `limitCurrency` 'USD': Currency for `limitAmount`. USD is the only active currency. Sending `CNY` returns 400 `currency_retired`.
  - `models` string[]: Updated model allowlist.
  - `expiresAt` string, date-time, nullable: Updated RFC3339 expiry timestamp. null clears the expiry.
  - `deliveryPolicy` 'auto' | 'verified' | 'official' | 'null', nullable: Per-key Delivery policy. null inherits the Workspace default.

## Response `200`

Updated API key

- ManagementApiKey
  - `id` string, required
  - `name` string, required
  - `key_prefix` string, required
  - `status` 'active' | 'inactive' | 'suspended' | 'revoked', required: Lifecycle status for the user API key: active, inactive, or revoked.
  - `limit_amount` number, nullable, required: API key spending cap in USD as a JSON number for display. null means unlimited.
  - `used_amount` number, required: Accumulated API key usage in USD as a JSON number for display.
  - `models` string[], required
  - `expires_at` string, date-time, nullable, required
  - `last_used_at` string, date-time, nullable, required
  - `created_at` string, date-time, required
  - `key` string: Returned only on creation
  - `limit_amount_decimal` string, nullable, required: Exact API key spending cap in USD as a decimal string. null means unlimited.
  - `used_amount_decimal` string, required: Exact accumulated API key usage in USD as a decimal string for reconciliation.
  - `delivery_policy` 'auto' | 'verified' | 'official' | 'null', nullable, required: Per-key Delivery policy. null inherits the Workspace default.

## Other responses

- `400`: Bad Request - Invalid input
- `401`: Unauthorized - Invalid or missing API key
- `403`: Forbidden
- `404`: Not Found
- `409`: A revoked API key cannot be reactivated. Create a new key.

---

[API](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway.md) · [All operations](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/revisions/3208bfbcda22?raw)
