> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentarea.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Api Key

> Create a new API key. The raw ``token`` value is returned once — store it securely.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/api-keys/
openapi: 3.1.0
info:
  description: >-
    Modular and extensible framework for building AI agents. This API requires
    JWT Bearer token authentication for most endpoints. Include your JWT token
    in the Authorization header. Public endpoints include /, /health, /docs,
    /redoc, and /openapi.json.
  title: AgentArea API
  version: 0.1.0
servers: []
security:
  - bearer: []
paths:
  /v1/api-keys/:
    post:
      tags:
        - v1
        - protected
        - api-keys
      summary: Create Api Key
      description: >-
        Create a new API key. The raw ``token`` value is returned once — store
        it securely.
      operationId: create_api_key_v1_api_keys__post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/APIKeyCreateRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIKeyCreateResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    APIKeyCreateRequest:
      properties:
        expires_in_days:
          anyOf:
            - type: integer
            - type: 'null'
          description: Optional expiry in days (omit for non-expiring)
          title: Expires In Days
        name:
          description: Human-friendly label for this API key
          title: Name
          type: string
      required:
        - name
      title: APIKeyCreateRequest
      type: object
    APIKeyCreateResponse:
      description: Extends APIKeyResponse with the raw token — shown ONCE at creation.
      properties:
        access_count:
          title: Access Count
          type: integer
        created_at:
          title: Created At
          type: string
        expires_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Expires At
        id:
          format: uuid
          title: Id
          type: string
        is_active:
          title: Is Active
          type: boolean
        last_accessed_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Accessed At
        name:
          title: Name
          type: string
        token:
          description: Raw token value — copy it now, it won't be shown again
          title: Token
          type: string
        token_prefix:
          title: Token Prefix
          type: string
      required:
        - id
        - name
        - token_prefix
        - is_active
        - expires_at
        - access_count
        - last_accessed_at
        - created_at
        - token
      title: APIKeyCreateResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    bearer:
      bearerFormat: JWT
      description: JWT Bearer token for authentication
      scheme: bearer
      type: http
    HTTPBearer:
      scheme: bearer
      type: http

````