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

# Create API Key

> Create a new API key for the authenticated user.

## Authentication

Requires an API key in the `Authorization` header.

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

## Request

<ParamField body="name" type="string" required>
  A display name for the key (e.g., "Production", "Development").
</ParamField>

### Example request

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

## Response

<ResponseField name="id" type="string">
  Unique key identifier.
</ResponseField>

<ResponseField name="name" type="string">
  Display name for the key.
</ResponseField>

<ResponseField name="key" type="string">
  The full API key. **This is only shown once** — store it securely.
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 creation timestamp.
</ResponseField>

### Example response

```json theme={"dark"}
{
  "id": "key_abc123",
  "name": "Production",
  "key": "enc_live_a1b2c3d4e5f6g7h8i9j0...",
  "created_at": "2024-01-15T10:00:00Z"
}
```

<Warning>
  The full key value is only returned at creation time. You won't be able to retrieve it again. Store it securely.
</Warning>

<ResponseExample>
  ```json 200 theme={"dark"}
  {
    "id": "key_abc123",
    "name": "Production",
    "key": "enc_live_a1b2c3d4e5f6g7h8i9j0...",
    "created_at": "2024-01-15T10:00:00Z"
  }
  ```

  ```json 400 theme={"dark"}
  {
    "error": "name is required"
  }
  ```

  ```json 401 theme={"dark"}
  {
    "error": "Unauthorized"
  }
  ```
</ResponseExample>
