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

# Create API key

> Creates an API key and returns its secret once.



## OpenAPI

````yaml /hub/openapi/hub.json post /api/v1/hub/keys
openapi: 3.0.1
info:
  title: Fanify Hub API
  description: Generate media and text with Fanify credits. All prices use EUR.
  version: v1
servers:
  - url: https://fanifyai.com
security: []
paths:
  /api/v1/hub/keys:
    post:
      tags:
        - API keys
      summary: Create API key
      description: Creates an API key and returns its secret once.
      parameters:
        - name: X-Requested-With
          in: header
          description: Must be XMLHttpRequest.
          required: true
          schema:
            type: string
      requestBody:
        description: API key name
        content:
          application/json:
            schema:
              required:
                - name
              type: object
              properties:
                name:
                  maxLength: 100
                  minLength: 1
                  type: string
              additionalProperties: false
            example:
              name: My laptop
        required: true
      responses:
        '201':
          description: API key. The secret is returned once.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyDto'
              example:
                id: 12
                name: My laptop
                prefix: fanify_sk_a1B2c3D4
                created_at: '2026-09-07T10:00:00Z'
                last_used_at: null
                key: fanify_sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        '400':
          description: Invalid input
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - invalid_input
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#invalid_input
                title: Invalid input
                status: 400
                code: invalid_input
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - unauthorized
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#unauthorized
                title: Unauthorized
                status: 401
                code: unauthorized
        '429':
          description: Rate limit reached
          headers:
            Retry-After:
              description: Seconds before retrying.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - rate_limited
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#rate_limited
                title: Rate limit reached
                status: 429
                code: rate_limited
      security:
        - ConsoleSession: []
components:
  schemas:
    ApiKeyDto:
      required:
        - created_at
        - id
        - key
        - last_used_at
        - name
        - prefix
      type: object
      properties:
        id:
          type: integer
          format: int32
        name:
          type: string
        prefix:
          type: string
        created_at:
          type: string
          format: date-time
        last_used_at:
          type: string
          format: date-time
          nullable: true
        key:
          type: string
      additionalProperties: false
  securitySchemes:
    ConsoleSession:
      type: apiKey
      description: >-
        Fanify console session. X-Requested-With: XMLHttpRequest is also
        required.
      name: .AspNetCore.Cookies
      in: cookie

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.