> ## 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 zamówienie



## OpenAPI

````yaml /openapi.pl.json post /api/v2/orders
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/orders:
    post:
      tags:
        - Orders
      summary: Utwórz zamówienie
      operationId: OrderController_createOrder
      parameters:
        - name: cf-turnstile-response
          in: header
          description: >-
            Cloudflare Turnstile token from the checkout widget (required in
            production)
          required: true
          schema:
            type: string
        - name: Idempotency-Key
          in: header
          description: >-
            Random UUID/base64url attempt key (32-128 characters); reuse only
            for an identical retry
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrderDto'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                  message:
                    type: string
        '400':
          description: Błędne dane wejściowe
          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'
components:
  schemas:
    CreateOrderDto:
      type: object
      properties:
        productId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: ID produktu (ObjectId)
          example: 664f1a2b3c4d5e6f7a8b9c0d
        nickname:
          type: string
          description: Nick gracza (3–16 znaków)
          example: Steve
        paymentMethodName:
          type: string
          minLength: 1
          maxLength: 100
          description: Nazwa metody płatności; wymagana tylko dla płatnych zamówień
          example: imojeTransfer:blik
        email:
          type: string
          format: email
          minLength: 3
          maxLength: 254
          description: E-mail kupującego (do potwierdzenia)
          example: klient@example.com
        quantity:
          type: number
          minimum: 1
          maximum: 100000
          description: Ilość
          example: 1
        discountCode:
          type: string
          minLength: 1
          maxLength: 50
          pattern: ^[A-Za-z0-9_-]+$
          description: Kod rabatowy
          example: LATO10
        termsAccepted:
          type: boolean
          description: Akceptacja regulaminu sprzedawcy
        immediatePerformanceConsent:
          type: boolean
          description: Żądanie natychmiastowego wykonania usługi cyfrowej
        withdrawalAcknowledged:
          type: boolean
          description: Potwierdzenie utraty prawa odstąpienia po wykonaniu
        legalDocumentVersion:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: SHA-256 wersji dokumentów pokazanych kupującemu
        metadata:
          description: Dozwolone metadane checkoutu
          allOf:
            - $ref: '#/components/schemas/CheckoutMetadataDto'
      required:
        - productId
        - nickname
        - termsAccepted
        - immediatePerformanceConsent
        - withdrawalAcknowledged
        - legalDocumentVersion
    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/...
    CheckoutMetadataDto:
      type: object
      properties:
        variant:
          type: string
          minLength: 1
          maxLength: 80
          description: Dokładna nazwa wariantu produktu

````