---
title: "Create a new API key. The full key value is only returned in this response."
method: POST
path: "/api-keys"
tags: ["API keys"]
---

# Create a new API key. The full key value is only returned in this response.

`POST /api-keys`

## Request

- Base URL: `https://api.stacktr.ee`
- URL: `https://api.stacktr.ee/api-keys`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.stacktr.ee/oauth/authorize`, token URL `https://api.stacktr.ee/oauth/token`, scopes: `sites:write`, `sites:read`)

## Request body

- object
  - `name` string

## Response `201`

Created.

- ApiKey
  - `id` string, required
  - `name` string, required
  - `prefix` string: First few chars of the key (for display).
  - `created_at` integer, required
  - `last_used` integer, nullable
  - `key` string: Full API key. Only present on creation responses.

---

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