---
title: "Create an API key"
method: POST
path: "/v1/api-keys"
tags: ["API Keys"]
---

# Create an API key

`POST /v1/api-keys`

## Request

- Base URL: `https://api.astrocal.dev`
- URL: `https://api.astrocal.dev/v1/api-keys`
- Auth: HTTP bearer

Creates a new API key for the authenticated organization. The full key is returned in the response — this is the only time it will be shown. Requires dashboard authentication: requests authenticated with an API key are rejected, so a leaked key cannot be used to mint further keys.

## Request body

- object
  - `name` string, required
  - `mode` 'live' | 'test', required
  - `expires_at` string, date-time

## Response `201`

API key created

- object
  - `id` string, required
  - `org_id` string, required
  - `name` string, required
  - `key` string, required
  - `key_prefix` string, required
  - `mode` 'live' | 'test', required
  - `expires_at` string, nullable, required
  - `created_at` string, required
  - `warning` string, required

## Other responses

- `400`: Invalid input
- `401`: Unauthorized
- `403`: Forbidden — API keys cannot create other API keys

---

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