---
title: "Create Api Key"
method: POST
path: "/api/v1/auth/api-key"
tags: ["auth"]
---

# Create Api Key

`POST /api/v1/auth/api-key`

## Request

- Base URL: `https://api.peil.app` (the document declares no server; this is the origin it was published from)
- URL: `https://api.peil.app/api/v1/auth/api-key`
- Auth: OAuth 2 (password, token URL `/api/v1/auth/jwt/login`)

Generate a new named, scoped API key. Up to 10 keys per user.

## Request body

- ApiKeyCreateRequest
  - `name` string, nullable
  - `scopes` string[]
  - `expires_in_days` integer, nullable

## Response `201`

Successful Response

- ApiKeyCreated
  - `id` integer, required
  - `key` string, required
  - `name` string, required
  - `prefix` string, required
  - `scopes` string[], required
  - `expires_at` string, date-time, nullable, required
  - `created_at` string, date-time, required

## Other responses

- `422`: Validation Error

---

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