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

# Create API key

` POST /api/v1/api-keys `

Create API key

## Servers

- ` https://littledemo.com ` — Production

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` bearerAuth `: ` http `

  - HTTP scheme: ` bearer `

  - Live API key, for example `Authorization: Bearer ld_live_...`.

### Alternative 2

- ` cookieAuth `: ` apiKey `

  - Credential: ` better-auth.session_token ` in ` cookie `

  - Dashboard session cookie.

## Request body (optional)

Content type: ` application/json `

- ` value `: type ` object `

  - ` name `: type ` string `

    - minLength: ` 1 `

    - maxLength: ` 100 `

  - ` type `: type ` string `

    - enum: ` ["live","publishable"] `

    - default: ` "live" `

  - ` project_id `: type ` string `

  - ` allowed_domains `: type ` array `

    - ` array item `: type ` string `

      - maxLength: ` 253 `

## Responses

### ` 201 ` — API key created (plaintext returned only once)

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` id `, ` key `, ` prefix `, ` name `, ` type `, ` project_id `, ` allowed_domains `

  - ` id `: type ` string `

  - ` key `: type ` string `

  - ` prefix `: type ` string `

  - ` name `: type ` string `

  - ` type `: type ` string `

    - enum: ` ["live","publishable"] `

  - ` project_id `: type ` string `; nullable

  - ` allowed_domains `: type ` array `; nullable

    - ` array item `: type ` string `

## Request examples

### cURL

```curl
curl -X POST 'https://littledemo.com/api/v1/api-keys' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "type": "live",
  "project_id": "string",
  "allowed_domains": [
    "string"
  ]
}'
```

### JavaScript

```javascript
const response = await fetch('https://littledemo.com/api/v1/api-keys', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "name": "string",
    "type": "live",
    "project_id": "string",
    "allowed_domains": [
      "string"
    ]
  })
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://littledemo.com/api/v1/api-keys', headers=headers, json={
  "name": "string",
  "type": "live",
  "project_id": "string",
  "allowed_domains": [
    "string"
  ]
})
print(response.json())
```