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

# 更新 API Key

> 更新 API Key 的元数据。

## PUT /api-keys/{keyId}

更新已有 API Key 的名称与描述等元数据。

### 路径参数

<ParamField path="keyId" type="string" required>
  要更新的 API Key ID。
</ParamField>

### 请求体

<ParamField body="name" type="string">
  新名称（1–100 个字符）。
</ParamField>

<ParamField body="description" type="string">
  新描述（最多 500 个字符）。
</ParamField>

<ParamField body="permissions" type="array">
  新的权限列表。
</ParamField>

### 响应

<ResponseField name="success" type="boolean">
  更新是否成功。
</ResponseField>

<ResponseField name="message" type="string">
  状态说明。
</ResponseField>

<ResponseField name="apiKey" type="object">
  更新后的详情。

  <Expandable title="apiKey 字段">
    <ResponseField name="id" type="string">
      API Key 唯一标识。
    </ResponseField>

    <ResponseField name="name" type="string">
      更新后的名称。
    </ResponseField>

    <ResponseField name="description" type="string">
      更新后的描述。
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      更新时间（ISO 8601）。
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT https://api.llmgenerator.com/api/v1/api-keys/llm_1706123456_abc123def456 \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Production Key",
      "description": "Updated description"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.llmgenerator.com/api/v1/api-keys/llm_1706123456_abc123def456',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'Updated Production Key'
      })
    }
  );
  ```
</RequestExample>

<ResponseExample>
  ```json Success (200) theme={null}
  {
    "success": true,
    "message": "API key updated successfully",
    "apiKey": {
      "id": "llm_1706123456_abc123def456",
      "name": "Updated Production Key",
      "description": "Updated description",
      "permissions": [],
      "updatedAt": "2026-01-27T10:00:00.000Z"
    }
  }
  ```

  ```json Not Found (404) theme={null}
  {
    "message": "API key not found"
  }
  ```
</ResponseExample>
