---
title: "Creates an API key for the authenticated user"
method: POST
path: "/api/auth/api-keys"
tags: ["API Keys"]
---

# Creates an API key for the authenticated user

`POST /api/auth/api-keys`

## Request

- Base URL: `https://passivelogic.com` (the document declares no server; this is the origin it was published from)
- URL: `https://passivelogic.com/api/auth/api-keys`
- Auth: one of:
  - API key in header `X-PL-AUTH`
  - API key in header `Authorization: PL-API-KEY`
  - API key in header `PL-API-KEY`
  - HTTP basic
- TypeScript: <https://skmtc.dev/passivelogic/apis/passivelogic-http-api/docs/api/auth/api-keys/post.ts> (a function with typed inputs; its response is checked against the schema)

## Request body

- CreateApiKeyRequest: Options for a new API key. The secret and owner are assigned by the server.
  - `role` string, required: Role assigned to the API key. Options are `read` or `readWrite`.
  - `name` string, required: Label for the API key.
  - `expiration` string, date-time, required: Expiration time.

## Response `201`

Created

- CreatedApiKeyResponse: A newly created API key and its one-time secret.
  - `apiKey` ApiKeyResponse, required: API key metadata. The secret is never included in this representation.
    - `expiration` string, date-time, required: Expiration time.
    - `name` string, nullable: Optional API key label.
    - `role` string, required: Role assigned to the API key. Options are `read` or `readWrite`.
    - `id` string, uuid, required: Unique API key ID.
  - `key` string, required: API key secret. This value is returned only at creation.

---

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