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

# Rename API Key

> Change the display name of an existing API key.

## Authentication

Requires an API key in the `Authorization` header.

```bash theme={"dark"}
Authorization: Bearer YOUR_API_KEY
```

## Request

<ParamField body="id" type="string" required>
  The ID of the API key to rename.
</ParamField>

<ParamField body="name" type="string" required>
  The new display name for the key.
</ParamField>

### Example request

```bash theme={"dark"}
curl -X PUT https://encrata.com/api/agent/keys \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"id": "key_abc123", "name": "Production key"}'
```

## Response

```json theme={"dark"}
{
  "message": "API key renamed"
}
```

<Note>
  Renaming requires a non-`readonly` role in the active workspace.
</Note>

<ResponseExample>
  ```json 200 theme={"dark"}
  {
    "message": "API key renamed"
  }
  ```

  ```json 400 theme={"dark"}
  {
    "error": "id and name are required"
  }
  ```

  ```json 401 theme={"dark"}
  {
    "error": "Unauthorized"
  }
  ```

  ```json 403 theme={"dark"}
  {
    "error": "Insufficient permissions"
  }
  ```

  ```json 404 theme={"dark"}
  {
    "error": "API key not found"
  }
  ```
</ResponseExample>
