---
title: "Create an API key (admin only)"
method: POST
path: "/users/api-keys"
tags: ["API Keys"]
---

# Create an API key (admin only)

`POST /users/api-keys`

Creates a new API key scoped to a specific user. The full token is returned only once.

## Request body

- object
  - `name` string, required — Human-readable name for the key.
  - `userId` string, required — ID of the user this key is scoped to.
  - `expiresAt` string, date-time — Optional expiration date. Null means the key never expires.

## Response `201`

API key created. Contains the full token (shown only once).

## Other responses

- `400` — Invalid input.
- `403` — Admin access required.
- `404` — Target user not found.
- `500` — Failed to create API key.

---

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