---
title: "Create Api Key"
method: POST
path: "/v1/apikeys/"
tags: ["API Keys"]
---

# Create Api Key

`POST /v1/apikeys/`

## Request

- Base URL: `https://api.lumethic.com`
- URL: `https://api.lumethic.com/v1/apikeys/`
- Auth: `OAuth2PasswordBearer` (a scheme the document does not define)

Create a new API key for programmatic access to the Lumethic API.

Generate a long-lived API key that can be used instead of JWT tokens for server-to-server
integrations, CI/CD pipelines, and automated workflows. The raw key is returned only once
in the response — store it securely.

**Authentication Required**: Valid JWT token

**Request Body**:
- **account_id**: The account to associate the key with (must be an account you have access to)
- **description**: Optional label to identify the key's purpose
- **expires_in_days**: Key lifetime in days (default 365, minimum 1)

**Response**: Returns the created key metadata and the raw key string.

**Status Codes**:
- 201: API key created successfully
- 403: You do not have access to the specified account

## Headers

- `X-API-Key` string, nullable

## Request body

- APIKeyCreateRequest
  - `description` string, nullable
  - `account_id` string, uuid, required
  - `expires_in_days` integer, nullable
  - `scope` string, nullable

## Response `201`

API key created successfully

- APIKeyCreateResponse: Response after creating a new API key. Contains the raw key which is only shown once.
  - `id` string, uuid, required: Unique identifier for the API key
  - `prefix` string, required: Key prefix for identification (e.g., 'ask_a1b2c3d4')
  - `account_id` string, uuid, required: Account this key is associated with
  - `user_id` string, uuid, required: User who created the key
  - `description` string, nullable, required: User-provided description of the key's purpose
  - `expires_at` string, date-time, required: ISO 8601 timestamp when the key expires
  - `created_at` string, date-time, required: ISO 8601 timestamp when the key was created
  - `raw_key` string, required: The full API key string. Store this securely — it cannot be retrieved again after creation.

## Other responses

- `403`: Access denied
- `422`: Validation Error

---

[API](https://skmtc.dev/lumethic/apis/lumethic-integration-api.md) · [All operations](https://skmtc.dev/lumethic/apis/lumethic-integration-api/llms.txt) · [OpenAPI document](https://skmtc.dev/lumethic/apis/lumethic-integration-api/revisions/fdafea3a491e?raw)
