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

# Create an API key

`POST /v1/api-keys`

## Request

- Base URL: `https://api.mentio.dev`
- URL: `https://api.mentio.dev/v1/api-keys`
- Auth: HTTP bearer

Mint a key for this workspace. The key itself is returned once; only its hash is stored. `expiresAt` makes it stop working at an instant (a key for a contractor or a one-off script); it stays listed until revoked.

## Request body

- object
  - `name` string: A label for the key; "default" when omitted.
  - `scope` 'read' | 'write': read: GET only. write: everything.
  - `expiresAt` string, date-time: When the key stops working (ISO 8601, or epoch ms), for a key handed to a script or a contractor. Must be in the future. Omit or null for a key that never expires.

## Response `201`

The new key, shown once

- object
  - `id` string, required: Key id (key_...).
  - `name` string, required
  - `prefix` string, required: The first characters of the key, to tell keys apart.
  - `scope` 'read' | 'write', required: read: GET only. write: everything.
  - `createdAt` string, required: ISO 8601 timestamp, UTC.
  - `lastUsedAt` string, nullable, required: ISO 8601 timestamp, UTC.
  - `expiresAt` string, nullable, required: When the key stops working; null for a key that never expires. An expired key stays listed until revoked.
  - `key` string, required: The full key. Shown once; store it now.

## Other responses

- `400`: expiresAt is not in the future
- `401`: Missing or invalid API key

---

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