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

# Kritik stok tanımı oluştur

> Ürüne bir depo için kritik stok tanımı ekler.

Kritik stok tanımı, yalnızca `StockType` değeri `1` (stok tutulmuyor) olmayan bir ürüne eklenebilir (`2410`).

`WarehouseId` zorunludur; bir ürünün bir depo için en fazla bir kritik stok tanımı olabilir (`2403`).

* `MinStock` ve `MaxStock` negatif olamaz.
* `MaxStock` sıfırdan büyükse `MinStock`'tan küçük olamaz (`2406`); `MaxStock: 0` üst sınır olmadığı anlamına gelir.
* `MaxStockControl`, `MinStockControl` ve `NegativeStockControl` her biri ayrı ayrı aşağıdaki değerleri alır:

| Değer | Anlamı           |
| ----- | ---------------- |
| `0`   | İşleme devam et  |
| `1`   | Kullanıcıyı uyar |
| `2`   | İşlemi durdur    |

* `MaxStockControl`: stok `MaxStock`'u aştığında.
* `MinStockControl`: stok `MinStock`'un altına düştüğünde.
* `NegativeStockControl`: stok negatife düşecek bir işlem yapıldığında.


## OpenAPI

````yaml api-reference/openapi.tr.json POST /api/v1/products/{productId}/critical-stock
openapi: 3.1.1
info:
  title: Noyax API
  description: Server-to-server API for integrations to access Noyax data.
  version: '1.0'
servers:
  - url: https://api.noyax.com
security:
  - Bearer: []
tags:
  - name: Sections
  - name: Warehouses
  - name: Product Critical Stock
  - name: Product groups
  - name: Product Parameter Definitions
  - name: Product Parameters
  - name: Product Prices
  - name: Products
  - name: Cities
  - name: Countries
  - name: Currencies
  - name: Districts
  - name: Shipment Definitions
  - name: Units
  - name: VAT rates
  - name: Customer Addresses
  - name: Customer Bank Accounts
  - name: Customer Definitions
  - name: Customer Group Members
  - name: Customer Links
  - name: Customer Parameters
  - name: Customer Representatives
  - name: Customers
  - name: Customer Statement
  - name: Customer Telephones
paths:
  /api/v1/products/{productId}/critical-stock:
    post:
      tags:
        - Product Critical Stock
      summary: Kritik stok tanımı oluştur
      description: >-
        Ürüne bir depo için kritik stok tanımı ekler. Bir ürünün bir depo için
        en fazla bir tanımı olabilir.
      parameters:
        - name: productId
          in: path
          description: Ürün ID'si.
          required: true
          schema:
            type: string
            format: uuid
        - name: X-UserID
          in: header
          description: >-
            İsteğin adına yapıldığı Noyax kullanıcısının ID'si. Oluşturulan,
            güncellenen ve silinen kayıtların denetim alanlarına yazılır.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-CompanyID
          in: header
          description: >-
            Şirketin ID'si. Kullanıcı bu şirkete tanımlı olmalıdır. Bütün okuma
            ve yazma işlemleri bu şirketle sınırlıdır.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-PeriodID
          in: header
          description: >-
            Muhasebe döneminin ID'si. Cari endpoint'lerinde isteğe bağlıdır;
            gönderilirse oluşturulan kayıtlara yazılır.
          schema:
            minimum: 1
            type: integer
            format: int32
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCriticalStockRequestDto'
          text/json:
            schema:
              $ref: '#/components/schemas/ProductCriticalStockRequestDto'
          application/*+json:
            schema:
              $ref: '#/components/schemas/ProductCriticalStockRequestDto'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataResultOfProductCriticalStockDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '2410'
                Message: >-
                  A critical stock definition cannot be added for a product with
                  StockType 1 (no stock tracking).
                Errors:
                  - Code: '2410'
                    Message: >-
                      A critical stock definition cannot be added for a product
                      with StockType 1 (no stock tracking).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0102'
                Message: Token has expired. Obtain a new token using the refresh token.
                Errors:
                  - Code: '0102'
                    Message: >-
                      Token has expired. Obtain a new token using the refresh
                      token.
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0110'
                Message: You do not have permission for this operation.
                Errors:
                  - Code: '0110'
                    Message: You do not have permission for this operation.
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0120'
                Message: Daily request limit (10000) exceeded.
                Errors:
                  - Code: '0120'
                    Message: Daily request limit (10000) exceeded.
components:
  schemas:
    ProductCriticalStockRequestDto:
      type: object
      properties:
        WarehouseId:
          type:
            - 'null'
            - string
          description: Zorunlu. GET /api/v1/stock/warehouses ile dönen bir deponun ID'si.
          format: uuid
        MinStock:
          type: number
          description: Asgari stok seviyesi. Negatif olamaz.
          format: double
          example: 10
        MaxStock:
          type: number
          description: >-
            Azami stok seviyesi. Negatif olamaz; 0 üst sınır olmadığı anlamına
            gelir. Sıfırdan büyükse MinStock'tan küçük olamaz.
          format: double
          example: 500
        MaxStockControl:
          type: integer
          description: >-
            MaxStock aşıldığında ne olacağı. 0: Devam et, 1: Kullanıcıyı uyar,
            2: İşlemi durdur.
          format: int32
          example: 1
        MinStockControl:
          type: integer
          description: >-
            Stok MinStock'un altına düştüğünde ne olacağı. 0: Devam et, 1:
            Kullanıcıyı uyar, 2: İşlemi durdur.
          format: int32
          example: 1
        NegativeStockControl:
          type: integer
          description: >-
            Stok negatife düşecekse ne olacağı. 0: Devam et, 1: Kullanıcıyı
            uyar, 2: İşlemi durdur.
          format: int32
          example: 2
    DataResultOfProductCriticalStockDto:
      required:
        - Success
        - ResultCode
        - Data
      type: object
      properties:
        Success:
          type: boolean
          description: İşlemin başarılı olup olmadığı.
          example: true
        ResultCode:
          type: string
          description: >-
            Başarıda "0000". Hatada ilk hatanın kodu; hataların tamamı Errors
            içinde listelenir.
          example: '0000'
        Message:
          type:
            - 'null'
            - string
          description: >-
            Success false olduğunda hata mesajı. Bütün hataların mesajları tek
            metinde birleştirilir.
        Data:
          $ref: '#/components/schemas/ProductCriticalStockDto'
    ErrorResult:
      type: object
      properties:
        Success:
          type: boolean
          description: İşlemin başarılı olup olmadığı.
          example: false
        ResultCode:
          type:
            - 'null'
            - string
          description: >-
            Başarıda "0000". Hatada ilk hatanın kodu; hataların tamamı Errors
            içinde listelenir.
        Message:
          type:
            - 'null'
            - string
          description: >-
            Success false olduğunda hata mesajı. Bütün hataların mesajları tek
            metinde birleştirilir.
        Errors:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/ResultError'
          description: >-
            Kodlarıyla birlikte bütün hatalar. Yalnızca Success false olduğunda
            bulunur.
    ProductCriticalStockDto:
      type: object
      properties:
        Id:
          type: string
          description: Kritik stok tanımı ID'si.
          format: uuid
        ProductId:
          type: string
          description: Ürün ID'si.
          format: uuid
        WarehouseName:
          type:
            - 'null'
            - string
          description: Depo adı.
          example: A DEPO
        WarehouseId:
          type:
            - 'null'
            - string
          description: Zorunlu. GET /api/v1/stock/warehouses ile dönen bir deponun ID'si.
          format: uuid
        MinStock:
          type: number
          description: Asgari stok seviyesi. Negatif olamaz.
          format: double
          example: 10
        MaxStock:
          type: number
          description: >-
            Azami stok seviyesi. Negatif olamaz; 0 üst sınır olmadığı anlamına
            gelir. Sıfırdan büyükse MinStock'tan küçük olamaz.
          format: double
          example: 500
        MaxStockControl:
          type: integer
          description: >-
            MaxStock aşıldığında ne olacağı. 0: Devam et, 1: Kullanıcıyı uyar,
            2: İşlemi durdur.
          format: int32
          example: 1
        MinStockControl:
          type: integer
          description: >-
            Stok MinStock'un altına düştüğünde ne olacağı. 0: Devam et, 1:
            Kullanıcıyı uyar, 2: İşlemi durdur.
          format: int32
          example: 1
        NegativeStockControl:
          type: integer
          description: >-
            Stok negatife düşecekse ne olacağı. 0: Devam et, 1: Kullanıcıyı
            uyar, 2: İşlemi durdur.
          format: int32
          example: 2
    ResultError:
      required:
        - Code
        - Message
      type: object
      properties:
        Code:
          type: string
          description: Hata kodu. Tam liste için sonuç kodları sayfasına bakın.
        Message:
          type: string
          description: Hata açıklaması.
  securitySchemes:
    Bearer:
      type: http
      description: Access token obtained from the Noyax auth service with your API key.
      scheme: bearer
      bearerFormat: JWT

````