---
title: "Create API Key"
method: POST
path: "/keys"
tags: ["System"]
---

# Create API Key

`POST /keys`

Create a new API key. Requires an internal or enterprise API key. Returns the generated key string: save it, it cannot be retrieved later.

## Request body

- CreateKey
  - `name` string, required
  - `mode` 'live' | 'test'
  - `origin_restriction` object
    - `type` 'server-only' | 'public' | 'allowlist'
    - `allowed_origins` string[]

## Response `200`

Successful calculation

- object
  - `ok` boolean
  - `data` object
    - `id` number, nullable
    - `api_key` string, nullable
    - `api_key_masked` string, nullable
    - `name` string, nullable
    - `plan` string, nullable
    - `rate_limit` number, nullable
    - `credits_limit` number, nullable
    - `credits_used` number, nullable
    - `created_at` string, nullable
    - `last_used_at` unknown
    - `is_active` boolean, nullable
    - `origin_restriction` object, nullable
      - `type` string, nullable

## Other responses

- `400` — Validation error
- `401` — Missing or invalid API key

## Changes

- **2026-08-24** `8ab5a768b521` — 1 breaking
  - the `data/last_used_at` response's property type/format changed from `object`/`` to ``/`` for status `200`
- **2026-08-23** `529d7d36d7d6` — 2 warning, 10 info
  - removed the optional property `data/apiKey` from the response with the `200` status
  - removed the optional property `data/rateLimit` from the response with the `200` status
  - added the optional property `data/api_key` to the response with the `200` status
  - added the optional property `data/api_key_masked` to the response with the `200` status
  - …8 more

[Change history](https://skmtc.dev/astroway/apis/astroway-calculation-api/changes/keys/post.md)

---

[API](https://skmtc.dev/astroway/apis/astroway-calculation-api.md) · [All operations](https://skmtc.dev/astroway/apis/astroway-calculation-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/astroway/astroway-calculation-api/revisions/8ab5a768b521/schema)
