---
title: "Create API key"
method: POST
path: "/api-keys"
tags: ["API Keys"]
---

# Create API key

`POST /api-keys`

## Request

- Base URL: `https://api.aspect.inc`
- URL: `https://api.aspect.inc/api-keys`
- Auth: API key in header `Authorization`

Create a new API key for the authenticated user.

Returns the API key only once - it cannot be retrieved again for security reasons.

## Request body

- ApiKeyCreateRequest: API request schema for creating an API key
  - `name` string, required: Human-readable name for the API key

## Response `201`

Successful Response

- ApiKeyCreateResponse: API response schema returned after creating a new API key (includes the raw key once).
  - `api_key` string, required: The key value. It's returned only once, so store it now.
  - `key_info` ApiKeyGetResponse, required: API response schema for getting API key metadata (no sensitive key value).
    - `id` string, uuid, required
    - `name` string, required
    - `key_prefix` string, required
    - `created` string, date-time, required
    - `last_used` string, date-time, nullable, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/aspect/apis/aspect-api.md) - [All operations](https://skmtc.dev/aspect/apis/aspect-api/llms.txt) - [OpenAPI document](https://skmtc.dev/aspect/apis/aspect-api/revisions/28ea5f1adb54?raw)
