# Generate New API Key for Current User

`POST /api/identity/api-keys/me`

### Overview
Creates a new personal API token or BYOK credential. The raw plaintext key secret is **returned only once** in this response.

### Authentication & Headers
- **Auth**: Bearer Token
- **Required Header**: `API-Version: 1`

### Parameters & Request Body
- **`name`** *(string, required)*: Descriptive label for the key.
- **`is_byok`** *(boolean, optional, default: false)*: Set to true if configuring personal third-party LLM key.
- **`expires_days`** *(integer, optional, default: 90)*: Key expiration validity period in days.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes |  |
| `description` | string \| null | no |  |
| `expires_at` | string (date-time) \| null | no |  |

```json
{
  "name": "string",
  "description": "string",
  "expires_at": "2026-01-01T00:00:00Z"
}
```

## Responses

### 201 — API key generated successfully

### 400 — Bad Request - The request parameters or headers are invalid (e.g. unsupported API-Version).

### 401 — Unauthorized - Missing, invalid, or expired JWT Bearer token.

### 403 — Forbidden - Insufficient role permissions or resource access denied by RBAC policy.

### 404 — Not Found - The requested resource ID was not found.

### 422 — Validation Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | object[] | no |  |
| `detail[].loc` | string | integer[] | yes |  |
| `detail[].msg` | string | yes |  |
| `detail[].type` | string | yes |  |
| `detail[].input` | object | no |  |
| `detail[].ctx` | object | no |  |

```json
{
  "detail": [
    {
      "loc": [
        null
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

## Example

```bash
curl -X POST "$PINTER_URL/api/identity/api-keys/me" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","description":"string","expires_at":"2026-01-01T00:00:00Z"}'
```
