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

# Create a new hash-based API key

`POST /api/v1/api-keys`

Creates a new OpenAI-compatible API key (sk-oai-* format). Supports both permanent keys (no expiration) and expiring keys (with expiresIn parameter). The plaintext key is shown ONLY ONCE at creation time and cannot be retrieved again.

## Request body

- object
  - `data` object, required
    - `name` string, required — Human-readable name for the API key
    - `description` string — Optional description
    - `expiresIn` string — Optional expiration duration (e.g., "30d", "90d", "1h"). Omit for permanent key.
    - `subscription` string, required — Subscription ID header to scope this API key to a specific subscription.
    - `ephemeral` boolean — When true, requests an ephemeral key (short-lived); forwarded to maas-api.

## Response `201`

Created response.

- object
  - `data` object, required
    - `key` string — Plaintext API key (SHOWN ONCE, NEVER AGAIN)
    - `keyPrefix` string — Display prefix for UI (e.g., sk-oai-abc)
    - `id` string — Unique identifier for the key
    - `name` string — Name of the key
    - `createdAt` string, date-time — Creation timestamp (RFC3339)
    - `expiresAt` string, date-time — Expiration timestamp (RFC3339), omitted for permanent keys

## Other responses

- `400` — Bad Request response.
- `401` — Unauthorized response.
- `500` — Internal Server Error

---

[API](https://skmtc.net/opendatahub-io/apis/maas-bff-api.md) · [All operations](https://skmtc.net/opendatahub-io/apis/maas-bff-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/opendatahub-io/maas-bff-api/versions/9112415ceeca/schema)
