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

# Create API key

`POST /api/v1/auth/keys`

## Request body

- CreateApiKeyRequest
  - `name` string, required
  - `expires_at` string, date-time
  - `space_id` string, uuid

## Response `201`

Created

- ApiKeyCreatedResponse
  - `key_id` string, uuid, required
  - `name` string, required
  - `key_prefix` string, required
  - `raw_key` string, required
  - `expires_at` string, date-time, nullable, required
  - `space_id` string, uuid, nullable, required

## Other responses

- `401` — Unauthorized
- `404` — Not found

## Changes

- **2026-08-25** `55772030ddd3` — 6 warning
  - removed the optional property `code` from the response with the `401` status
  - removed the optional property `code` from the response with the `404` status
  - removed the optional property `fields` from the response with the `401` status
  - removed the optional property `fields` from the response with the `404` status
  - …2 more
- **2026-08-19** `b38f8e603649` — 6 info
  - added the optional property `code` to the response with the `401` status
  - added the optional property `code` to the response with the `404` status
  - added the optional property `fields` to the response with the `401` status
  - added the optional property `fields` to the response with the `404` status
  - …2 more

[Change history](https://skmtc.dev/crosmos/apis/crosmos-api/changes/api/v1/auth/keys/post.md)

---

[API](https://skmtc.dev/crosmos/apis/crosmos-api.md) · [All operations](https://skmtc.dev/crosmos/apis/crosmos-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/crosmos/crosmos-api/revisions/55772030ddd3/schema)
