Skip to main content

POST /api-keys

This endpoint creates a new API key for the authenticated user. The full API key value is only shown once at creation time - make sure to save it securely.
The full API key is only returned once during creation. Store it securely as it cannot be retrieved later.

Request Body

name
string
required
A descriptive name for the API key (1-100 characters).
description
string
A description of what the key will be used for (max 500 characters).
permissions
array
A list of permissions to grant to the key. Defaults to all permissions.
expiresAt
string
Optional expiration date in ISO 8601 format.

Response

success
boolean
Whether the key was created successfully.
message
string
A status message.
apiKey
object
The created API key details.
warning
string
A reminder to save the key securely.
curl -X POST https://api.llmgenerator.com/api/v1/api-keys \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production API Key",
    "description": "For the main application"
  }'
{
  "success": true,
  "message": "API key created successfully",
  "apiKey": {
    "id": "llm_1706345678_newkey123abc",
    "name": "Production API Key",
    "description": "For the main application",
    "key": "llm_1706345678_newkey123abc",
    "permissions": [],
    "expiresAt": null,
    "createdAt": "2026-01-27T10:00:00.000Z",
    "isActive": true
  },
  "warning": "This is the only time the full API key will be shown. Please save it securely."
}