---
title: "Create Api Key"
method: POST
path: "/v1/workspaces/{workspace}/api-keys/"
tags: ["v1", "protected", "api-keys"]
---

# Create Api Key

`POST /v1/workspaces/{workspace}/api-keys/`

Create a new API key. The raw ``token`` value is returned once — store it securely.

## Path parameters

- `workspace` string, required — Slug of the workspace the request acts in

## Request body

- APIKeyCreateRequest
  - `expires_in_days` integer, nullable — Optional expiry in days (omit for non-expiring)
  - `name` string, required — Human-friendly label for this API key

## Response `201`

Successful Response

- APIKeyCreateResponse — Extends APIKeyResponse with the raw token — shown ONCE at creation.
  - `access_count` integer, required
  - `created_at` string, required
  - `expires_at` string, nullable, required
  - `id` string, uuid, required
  - `is_active` boolean, required
  - `last_accessed_at` string, nullable, required
  - `name` string, required
  - `token` string, required — Raw token value — copy it now, it won't be shown again
  - `token_prefix` string, required

## Other responses

- `422` — Validation Error

## Changes

- **2026-09-26** `d3ad8e1a3681` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/agentarea/apis/agentarea-api/changes/v1/workspaces/:workspace/api-keys/post.md)

---

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