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

# Create an API key

`POST /api/keys`

## Request

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

The full `sk_…` token is returned exactly once — store it now.

## Request body

- object
  - `name` string, required

## Response `200`

The new key, with its plaintext token.

- object
  - `id` string
  - `name` string
  - `prefix` string
  - `createdAt` string, date-time
  - `lastUsedAt` string, date-time, nullable
  - `revokedAt` string, date-time, nullable
  - `token` string

## Other responses

- `400`: Invalid name.
- `401`: Not authenticated.
- `403`: API keys can't create other API keys.

---

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