> ## 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.

# Atualizar chave de API

> Este endpoint atualiza os metadados de uma chave de API.

## PUT /api-keys/{keyId}

Este endpoint permite atualizar o nome e a descrição de uma chave de API existente.

### Parâmetros de caminho

<ParamField path="keyId" type="string" required>
  ID da chave a atualizar.
</ParamField>

### Corpo da requisição

<ParamField body="name" type="string">
  Novo nome da chave (1–100 caracteres).
</ParamField>

<ParamField body="description" type="string">
  Nova descrição (máximo 500 caracteres).
</ParamField>

<ParamField body="permissions" type="array">
  Nova lista de permissões da chave.
</ParamField>

### Resposta

<ResponseField name="success" type="boolean">
  Se a atualização foi bem-sucedida.
</ResponseField>

<ResponseField name="message" type="string">
  Mensagem de status.
</ResponseField>

<ResponseField name="apiKey" type="object">
  Detalhes atualizados da chave.

  <Expandable title="Propriedades de apiKey">
    <ResponseField name="id" type="string">
      Identificador único da chave.
    </ResponseField>

    <ResponseField name="name" type="string">
      Nome atualizado.
    </ResponseField>

    <ResponseField name="description" type="string">
      Descrição atualizada.
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      Data e hora da atualização em 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 Sucesso (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 Não encontrado (404) theme={null}
  {
    "message": "API key not found"
  }
  ```
</ResponseExample>
