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



## OpenAPI

````yaml /openapi.en.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: Production
  - url: http://localhost:3000
    description: Local
security: []
tags: []
paths:
  /api/v2/orders:
    post:
      tags:
        - Orders
      summary: Create an order
      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: Bad request
          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'
components:
  schemas:
    CreateOrderDto:
      type: object
      properties:
        productId:
          type: string
          pattern: ^[0-9a-fA-F]{24}$
          description: Product ID (ObjectId)
          example: 664f1a2b3c4d5e6f7a8b9c0d
        nickname:
          type: string
          description: Player nickname (3–16 chars)
          example: Steve
        paymentMethodName:
          type: string
          minLength: 1
          maxLength: 100
          description: Payment method name; required only for paid orders
          example: imojeTransfer:blik
        email:
          type: string
          format: email
          minLength: 3
          maxLength: 254
          description: Buyer email (for confirmation)
          example: klient@example.com
        quantity:
          type: number
          minimum: 1
          maximum: 100000
          description: Quantity
          example: 1
        discountCode:
          type: string
          minLength: 1
          maxLength: 50
          pattern: ^[A-Za-z0-9_-]+$
          description: Discount code
          example: LATO10
        termsAccepted:
          type: boolean
          description: Seller terms accepted
        immediatePerformanceConsent:
          type: boolean
          description: Immediate digital performance requested
        withdrawalAcknowledged:
          type: boolean
          description: Withdrawal-right acknowledgement
        legalDocumentVersion:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: SHA-256 of the legal documents shown to the buyer
        metadata:
          description: Whitelisted checkout metadata
          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: Error message
        timestamp:
          type: string
          format: date-time
        path:
          type: string
          example: /api/v2/...
    CheckoutMetadataDto:
      type: object
      properties:
        variant:
          type: string
          minLength: 1
          maxLength: 80
          description: Exact product variant name

````