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

# Create Api Key

`POST /api/v1/keys`

## Request

- Base URL: `https://api.seoproai.co`
- URL: `https://api.seoproai.co/api/v1/keys`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://dajosjnaalanhqksxrpe.supabase.co/auth/v1/authorize`, token URL `https://dajosjnaalanhqksxrpe.supabase.co/auth/v1/token`)

Create a new API key for the authenticated user.

The full API key is ONLY returned in this response - store it securely!
You won't be able to retrieve the full key again.

Args:
    key_data: API key creation parameters
    user_id: Authenticated user ID (from JWT)
    db: Database client

Returns:
    APIKeyResponse with the full API key (only shown once!)

## Headers

- `X-User-Id` string, nullable
- `X-Organization-Id` string, nullable
- `Authorization` string, nullable

## Request body

- APIKeyCreate: Request model for creating a new API key
  - `name` string, required: Friendly name for the API key
  - `environment` string: Environment: 'live' or 'test'
  - `expires_in_days` integer, nullable: Optional expiration in days
  - `scopes` string[], nullable: Optional list of permission scopes
  - `website_id` integer, nullable: Optional website ID to mark as API-managed when generating the key

## Response `201`

Successful Response

- APIKeyResponse: Response model for API key (with full key - only shown once!)
  - `id` string, required
  - `name` string, required
  - `key_prefix` string, required
  - `full_key` string, required
  - `created_at` string, required
  - `expires_at` string, nullable, required
  - `scopes` string[], required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/seoproai/apis/seopro-ai.md) · [All operations](https://skmtc.dev/seoproai/apis/seopro-ai/llms.txt) · [OpenAPI document](https://skmtc.dev/seoproai/apis/seopro-ai/revisions/5b4b6391ddc9?raw)
