---
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` object, nullable
    - `is_active` boolean, nullable
    - `origin_restriction` object, nullable
      - `type` string, nullable

## Other responses

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

---

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