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

# Create Api Key

> Create a new API key.

The full API key is returned only once in this response.
Store it securely - it cannot be retrieved again.



## OpenAPI

````yaml /api-reference/openapi.json post /api/api-keys
openapi: 3.1.0
info:
  title: Blindsight API
  version: 0.1.0
servers: []
security: []
paths:
  /api/api-keys:
    post:
      tags:
        - api-keys
      summary: Create Api Key
      description: |-
        Create a new API key.

        The full API key is returned only once in this response.
        Store it securely - it cannot be retrieved again.
      operationId: create_api_key_api_api_keys_post
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
        - name: blindsight_session
          in: cookie
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Blindsight Session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyCreateRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyCreateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ApiKeyCreateRequest:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        scopes:
          items:
            type: string
          type: array
          title: Scopes
        expires_in_days:
          anyOf:
            - type: integer
              maximum: 365
              minimum: 1
            - type: 'null'
          title: Expires In Days
      additionalProperties: false
      type: object
      required:
        - name
      title: ApiKeyCreateRequest
      description: Request to create a new API key.
    ApiKeyCreateResponse:
      properties:
        id:
          type: integer
          title: Id
        uuid:
          type: string
          title: Uuid
        name:
          type: string
          title: Name
        key:
          type: string
          title: Key
        key_preview:
          type: string
          title: Key Preview
        scopes:
          items:
            type: string
          type: array
          title: Scopes
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - uuid
        - name
        - key
        - key_preview
        - scopes
        - created_at
      title: ApiKeyCreateResponse
      description: >-
        Response when creating an API key - includes the full key (shown only
        once).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````