> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# API 키 업데이트

> 현재 조직의 기존 사용자 API 키를 업데이트합니다.

## 개요

이 엔드포인트는 기존 사용자 API 키의 이름, 사용 한도, 허용 모델, 만료, 상태를 업데이트할 때 사용합니다.

## 요청 본문

최소 1개 이상의 필드를 제공해야 합니다.

| 필드              | 타입             | 기본값 / 제한                | 설명                                                                        |
| --------------- | -------------- | ----------------------- | ------------------------------------------------------------------------- |
| `status`        | enum           | -                       | `active`, `inactive`, `revoked`                                           |
| `name`          | string         | 길이 `1-50`               | 업데이트된 표시 이름                                                               |
| `limitAmount`   | number \| null | 최소 `0`, 입력 최대 `1000000` | `null` = 무제한, `0` = 0 한도. 양수는 저장된 상한으로 정규화되며 USD 환산 기준 `100000` 을 넘지 않습니다 |
| `limitCurrency` | enum           | default `USD`           | USD만 지원됩니다. `CNY`를 보내면 `400 currency_retired`가 반환됩니다.                     |
| `models`        | string\[]      | -                       | 업데이트된 모델 허용 목록                                                            |
| `expiresAt`     | string \| null | RFC3339 datetime        | `null` 은 만료 제거                                                            |

## 참고 사항

* Management API v1 에서는 하드 삭제를 의도적으로 지원하지 않습니다.
* `revoked` 는 일반 운영에서 종료 상태로 취급되므로, 나중에 다시 살리는 흐름을 기대하기보다 새 키를 만드는 편이 낫습니다.

## 예시

<RequestExample>
  ```bash cURL theme={null}
  curl -X PATCH "https://api.tokenlab.sh/v1/management/api-keys/key_abc123def456" \
    -H "Authorization: Bearer mt-your-management-token" \
    -H "Content-Type: application/json" \
    -d '{
      "status": "inactive",
      "limitAmount": 0
    }'
  ```
</RequestExample>

## 요청 / 응답

정확한 스키마와 응답 필드는 상단의 대화형 OpenAPI 패널을 참고하세요.

## Response example

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "key_abc123def456",
    "name": "Backend Worker",
    "key_prefix": "sk-live...",
    "status": "inactive",
    "limit_amount": 0,
    "limit_amount_decimal": "0",
    "used_amount": 148.25,
    "used_amount_decimal": "148.25",
    "models": [
      "gpt-5-mini",
      "claude-3-7-sonnet"
    ],
    "expires_at": "2026-12-31T23:59:59.000Z",
    "last_used_at": "2026-07-08T03:12:45.000Z",
    "created_at": "2026-07-01T10:00:00.000Z"
  }
  ```
</ResponseExample>

## Important fields

<ResponseField name="id" type="string">API key identifier used in follow-up Management API calls.</ResponseField>
<ResponseField name="name" type="string">Display name for the API key.</ResponseField>
<ResponseField name="key_prefix" type="string">Non-secret key prefix for display and support.</ResponseField>
<ResponseField name="status" type="string">One of `active`, `inactive`, or `revoked`.</ResponseField>
<ResponseField name="limit_amount" type="number | null">Spending cap in USD as a JSON number for display. `null` means unlimited.</ResponseField>
<ResponseField name="limit_amount_decimal" type="string | null">Exact spending cap in USD as a decimal string. `null` means unlimited.</ResponseField>
<ResponseField name="used_amount" type="number">Accumulated usage in USD as a JSON number for display.</ResponseField>
<ResponseField name="used_amount_decimal" type="string">Exact accumulated usage in USD as a decimal string.</ResponseField>
<ResponseField name="models" type="string[]">Per-key model allowlist. Empty array means no additional key-level model restriction.</ResponseField>
<ResponseField name="expires_at" type="string | null">ISO timestamp when the key expires, or `null` for no expiry.</ResponseField>
<ResponseField name="last_used_at" type="string | null">ISO timestamp for the most recent use, or `null` when unused.</ResponseField>
<ResponseField name="created_at" type="string">ISO creation timestamp.</ResponseField>
