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

# Create Api Key

`POST /api/v1/config/api-keys`

## Request

- Base URL: `https://memory.kagura-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://memory.kagura-ai.com/api/v1/config/api-keys`
- Auth: none declared

Create a new API key for the current user.

Issue #246: Creates API key with context_id=None (no auto-assignment).
Issue #1752: the owner is emailed a security notice once the key is
committed (the key's name only, never its value).

## Headers

- `authorization` string, nullable

## Request body

- APIKeyCreate: Request model for creating an API key.
  - `name` string, required: Friendly name for the API key
  - `expires_days` integer, nullable: Expiration in days (1-3650). Omit for the server default (365 days); 0 opts in to a key that never expires.
  - `default_context_id` string, uuid, nullable: MCP default context of the key: a context-scoped tool called without context_id runs in it (?context= on the URL wins). Omit for none.

## Response `201`

Successful Response

- APIKeyCreateResponse: Response model for API key creation (includes plaintext key).
  - `id` unknown, required
  - `key_prefix` unknown, required
  - `name` unknown, required
  - `user_id` unknown, required
  - `created_at` unknown, required
  - `last_used_at` unknown
  - `revoked_at` unknown
  - `expires_at` unknown
  - `status` unknown, required
  - `default_context_id` unknown
  - `default_context_name` unknown
  - `api_key` unknown, required

## Other responses

- `422`: Validation Error

## Changes

- **2026-10-20** `09f17f5ada29`: 3 info
  - added the new optional request property `default_context_id`
  - added the optional property `default_context_id` to the response with the `201` status
  - added the optional property `default_context_name` to the response with the `201` status

[Operation history](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/changes/api/v1/config/api-keys/post.md)

---

[API](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud.md) · [All operations](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/revisions/09f17f5ada29?raw)
