---
title: "Create Api Key"
method: POST
path: "/api/api-keys"
tags: ["API Keys"]
---

# Create Api Key

`POST /api/api-keys`

Create a new API key.

- **name**: Display name for the key
- **scope**: API key scope (user or enterprise; demo is admin-only)
- **daily_limit**: Optional daily request limit (NULL = unlimited)
- **expires_at**: Optional expiration date (NULL = 30 days from now)

**Enterprise keys (scope=enterprise):**
- Require admin approval before activation
- Use postpaid billing (monthly invoicing)
- Require company_name and request_message
- Get Business subscription access + unlimited rate limits

**Important**: The plain key is only shown once! Store it securely.

## Request body

- APIKeyCreateRequest
  - `name` string, required — Display name for the key
  - `scope` 'demo' | 'user' | 'enterprise'
  - `daily_limit` integer, nullable — Optional daily request limit (NULL = unlimited). Use for testing or rate-limited access.
  - `expires_at` string, date-time, nullable — Key expiration date (NULL = never expires, default = 30 days from now)
  - `request_message` string, nullable — Message explaining the reason for requesting API access. Required for enterprise keys.
  - `company_name` string, nullable — Company name (required for enterprise keys)
  - `expected_monthly_usage` number, nullable — Expected monthly usage in USD (helps set credit limit for enterprise keys)

## Response `201`

Successful Response

- APIKeyCreatedResponse
  - `success` boolean
  - `message` string, nullable
  - `data` APIKeyCreatedResult
    - `id` string, required
    - `name` string, required
    - `scope` 'demo' | 'user' | 'enterprise', required
    - `status` 'pending' | 'active' | 'expired' | 'declined' | 'revoked', required
    - `billing_mode` 'prepaid' | 'postpaid' — Billing mode for API keys. PREPAID: User must have positive balance. Session stops if balance runs out. Used by regular users (demo, user scopes). POSTPAID: Can go negative. Invoiced monthly. Used by enterprise keys only (requires admin approval).
    - `key` string, required — The API key - store securely, shown only once!
    - `key_preview` string, required — Masked preview of the key
    - `created_at` string, date-time, required
    - `expires_at` string, date-time, nullable
    - `company_name` string, nullable

## Other responses

- `400` — Bad Request
- `422` — Validation Error
- `500` — Internal Server Error

---

[API](https://skmtc.net/compresr/apis/compresr-platform-api.md) · [All operations](https://skmtc.net/compresr/apis/compresr-platform-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/compresr/compresr-platform-api/revisions/93ee959dfa51/schema)
