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

# Create a new API key

`POST /api/keys`

## Request

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

Generate a new API key (POST). CSRF-protected.

409 at the per-user active-key cap (P1-21, external review 2026-09-26;
services/api_keys.py MAX_ACTIVE_API_KEYS_PER_USER).

## Query parameters

- `name` string

## Response `200`

Successful Response

- ApiKeysCreateResponse: `POST /api/keys` — generate a new API key. Run 19 F4 backfill 2026-05-12. Returns the freshly-generated key + metadata. The plaintext key is shown ONCE — clients must capture it on this response or revoke + reissue.
  - `status` string, nullable: 'ok' on success.
  - `key` string, nullable: Plaintext API key — shown exactly once.
  - `name` string, nullable: Human-readable label.
  - `id` integer, nullable: Key id (numeric).
  - `created_at` string, nullable: ISO timestamp.
  - `error` string, nullable: Failure message.

## Other responses

- `422`: Validation Error

---

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