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

# Create an API key



## OpenAPI

````yaml /openapi.en.json post /api/v2/api-keys
openapi: 3.0.0
info:
  title: ItemShop v2 API
  description: >-
    REST API platformy ItemShop v2 (NestJS + Fastify). Wszystkie ścieżki mają
    prefiks /api/v2.
  version: 2.0.0
  contact: {}
servers:
  - url: https://api.itemshop.dev
    description: Production
  - url: http://localhost:3000
    description: Local
security: []
tags: []
paths:
  /api/v2/api-keys:
    post:
      tags:
        - API Keys
      summary: Create an API key
      operationId: ApiKeyController_createApiKey
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyDto'
      responses:
        '201':
          description: Key created (secret returned once)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/ApiKey'
                  message:
                    type: string
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateApiKeyDto:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Key name
          example: Plugin survival
        permissions:
          description: >-
            Permissions as resource:action (e.g. 'products:write',
            'orders:read'). Wildcards: 'products:*' (whole resource), '*'
            (everything). Legacy aliases: read/write/delete; the admin alias is
            rejected. Full catalog at GET /api-keys/permissions.
          example:
            - products:read
            - orders:write
          type: array
          items:
            type: string
        type:
          enum:
            - shop
            - plugin
          type: string
          description: Key type
          example: plugin
        shopId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: Shop ID (for shop/plugin keys)
          example: 664f1a2b3c4d5e6f7a8b9c0d
        expiresAt:
          type: string
          description: Expiration date (ISO 8601)
          example: '2026-12-31T23:59:59.000Z'
      required:
        - name
        - type
    ApiKey:
      type: object
      properties:
        id:
          type: string
          example: 664f1a2b3c4d5e6f7a8b9c0d
        name:
          type: string
          example: Plugin survival
        permissions:
          type: array
          items:
            type: string
          example:
            - read
            - write
        type:
          type: string
          example: plugin
        keyPreview:
          type: string
          example: isk_a1b2...
        isActive:
          type: boolean
          example: true
        createdAt:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: integer
          example: 400
        error:
          type: string
          example: Error message
        timestamp:
          type: string
          format: date-time
        path:
          type: string
          example: /api/v2/...
  securitySchemes:
    bearerAuth:
      scheme: bearer
      bearerFormat: JWT
      type: http

````