> ## 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.

# Utwórz klucz API



## OpenAPI

````yaml /openapi.pl.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: Produkcja
  - url: http://localhost:3000
    description: Lokalnie
security: []
tags: []
paths:
  /api/v2/api-keys:
    post:
      tags:
        - API Keys
      summary: Utwórz klucz API
      operationId: ApiKeyController_createApiKey
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyDto'
      responses:
        '201':
          description: Klucz utworzony (sekret zwracany raz)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/ApiKey'
                  message:
                    type: string
        '400':
          description: Błędne dane wejściowe
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Brak/niepoprawne uwierzytelnienie
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Nie znaleziono
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Przekroczony limit żądań
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateApiKeyDto:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Nazwa klucza
          example: Plugin survival
        permissions:
          description: >-
            Uprawnienia w formacie resource:action (np. 'products:write',
            'orders:read'). Wildcardy: 'products:*' (cały zasób), '*'
            (wszystko). Aliasy zgodności: read/write/delete; alias admin jest
            niedozwolony. Pełny katalog pod GET /api-keys/permissions.
          example:
            - products:read
            - orders:write
          type: array
          items:
            type: string
        type:
          enum:
            - shop
            - plugin
          type: string
          description: Typ klucza
          example: plugin
        shopId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: ID sklepu (dla klucza typu shop/plugin)
          example: 664f1a2b3c4d5e6f7a8b9c0d
        expiresAt:
          type: string
          description: Data wygaśnięcia (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: Komunikat błędu
        timestamp:
          type: string
          format: date-time
        path:
          type: string
          example: /api/v2/...
  securitySchemes:
    bearerAuth:
      scheme: bearer
      bearerFormat: JWT
      type: http

````