---
title: "Create an API key"
method: POST
path: "/org/api_keys"
tags: ["API Keys"]
---

# Create an API key

`POST /org/api_keys`

Create a new API key within the authenticated organization.

## Request body

- CreateApiKeyRequest
  - `name` string, required — Label for the API key (1-255 characters). API keys are not addressable by name.
  - `days_to_expire` integer, nullable — Number of days until expiry, up to 3650. Use null for never.
  - `project_id` string, nullable — Unique project identifier

## Response `201`

API key created successfully

- CreatedApiKey — API key returned immediately after creation. Includes the plaintext key once.
  - `id` string, required — Unique API key identifier
  - `name` string, required — Label for the API key. API keys are not addressable by name; use the ID or key identifier for stable references.
  - `created_at` string, date-time, required — When the API key was created
  - `created_by` ApiKeyCreator, required
    - `id` string, required — Kernel user ID of the creator.
    - `email` string, email, required — Email address of the creator.
    - `name` string, nullable, required — Display name of the creator, if available.
  - `expires_at` string, date-time, nullable, required — When the API key expires
  - `deleted_at` string, date-time, nullable, required — When the API key was deleted (soft-deleted). Null for keys that have not been deleted.
  - `project_id` string, nullable, required — Project identifier for project-scoped API keys. Null means org-wide.
  - `project_name` string, nullable, required — Project name for project-scoped API keys. Null means the key is org-wide or the project name is unavailable.
  - `masked_key` string, required — Masked version of the API key
  - `key` string, required — Plaintext API key. Only returned once when the key is created.

## Other responses

- `400` — Bad Request – invalid input
- `401` — Unauthorized – missing or invalid authorization token
- `404` — Resource not found
- `500` — Internal Server Error

---

[API](https://skmtc.net/kernel/apis/kernel-api.md) · [All operations](https://skmtc.net/kernel/apis/kernel-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kernel/kernel-api/versions/9e8ce9fcf5e1/schema)
