openapi: 3.1.0
info:
  title: Product Inventory Service
  version: v2025.11.06-3
servers:
  - url: https://api-1.test.logitrail.com
    description: Test / Development Server
  - url: https://api-1.logitrail.com
    description: Production Server
paths:
  /v1/products/{productId}/inventory:
    get:
      summary: Get Product Inventory
      description: Requests current product inventory details from Logitrail WMS
      security:
        - idp:
            - products:read
      parameters:
        - in: path
          name: productId
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
          required: true
        - in: header
          name: x-logitrail-merchant-id
          schema:
            type: string
            title: Logitrail's Merchant ID the request is scoped for.
          required: true
      responses:
        '200':
          summary: 200 OK
          description: Product Inventory Data returned successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  product_inventory:
                    type: object
                    properties:
                      inventory:
                        type: object
                        properties:
                          available:
                            type: number
                            minimum: 0
                          reserved:
                            type: number
                            minimum: 0
                          demand:
                            type: number
                            minimum: 0
                          in_stock:
                            type: number
                            minimum: 0
                          on_hold:
                            type: number
                            minimum: 0
                          inbound:
                            type: number
                            minimum: 0
                        required:
                          - available
                          - reserved
                          - demand
                          - in_stock
                          - on_hold
                          - inbound
                      last_movement:
                        type: string
                        format: date-time
                    required:
                      - inventory
                      - last_movement
                required:
                  - product_inventory
        '400':
          summary: 400 Bad Request
          description: Most likely validation error in the request.
        '404':
          summary: 404 Not Found
          description: Product not found.
  /v1/products/{productId}/inventory/batches_on_shelf:
    get:
      summary: Get Product Arrival Batches on shelf
      description: >-
        Requests information about the Arrival Batches of a product that are
        currently stocked on shelf in the warehouse. Arrival Batches represent a
        specific batch of items that arrived together and are managed as a group
        within the warehouse. This endpoint provides details about these
        batches, including their quantities, locations, and other relevant
        information. Arrival Batches are most likely different from supplier
        batches / lot numbers and internal to Logitrail warehouse operations.
        For example, there may be more than one Arrival Batch for a product
        batch with "best before date" 2026-31-12 with supplier lot number 12345.
        Anyway, same Arrival Batch never contains multiple supplier lots or
        multiple products.
      security:
        - idp:
            - products:read
      parameters:
        - in: path
          name: productId
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
          required: true
        - in: header
          name: x-logitrail-merchant-id
          schema:
            type: string
            title: Logitrail's Merchant ID the request is scoped for.
          required: true
      responses:
        '200':
          summary: 200 OK
          description: Batch details returned successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  batches_on_shelf:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: number
                          minimum: 1
                        inbound_shipment:
                          type: object
                          properties:
                            id:
                              type: string
                              pattern: ^[0-9a-f]{24}$
                            sender_name:
                              type:
                                - string
                                - 'null'
                          required:
                            - id
                            - sender_name
                        on_shelf_at:
                          type:
                            - string
                            - 'null'
                          format: date-time
                        batch_details:
                          type: object
                          properties:
                            batch_number:
                              type:
                                - string
                                - 'null'
                            best_before_date:
                              type:
                                - string
                                - 'null'
                              format: date
                        purchase_value_per_article:
                          type:
                            - number
                            - 'null'
                          description: >-
                            The purchase value per article in the batch. Null if
                            not set or not all articles in the batch have a
                            purchase value set. Precision up to 4 decimals
                            (1.2345 EUR)
                        purchase_value_currency:
                          type:
                            - string
                            - 'null'
                          description: >-
                            The currency of the purchase value per article in
                            the batch.
                        warehouse_location:
                          type:
                            - string
                            - 'null'
                        total_on_shelf_count:
                          type: number
                          minimum: 1
                        reserved_count:
                          type: number
                          minimum: 0
                        available_count:
                          type: number
                          minimum: 0
                      required:
                        - id
                        - inbound_shipment
                        - on_shelf_at
                        - batch_details
                        - purchase_value_per_article
                        - purchase_value_currency
                        - warehouse_location
                        - total_on_shelf_count
                        - reserved_count
                        - available_count
                required:
                  - batches_on_shelf
        '400':
          summary: 400 Bad Request
          description: Most likely validation error in the request.
        '404':
          summary: 404 Not Found
          description: Requested Arrival Batch not found.
  /v1/products/{productId}/inventory/batch/{batchId}:
    post:
      summary: Update Product Arrival Batch
      description: >-
        Update the details of a specific product arrival batch. Note that a new
        Arrival Batch is generated whenever new items arrive and they are
        stocked in Logitrail warehouse.
      security:
        - idp:
            - products:manage
      parameters:
        - in: path
          name: productId
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
          required: true
        - in: path
          name: batchId
          schema:
            type: number
          required: true
        - in: header
          name: x-logitrail-merchant-id
          schema:
            type: string
            title: Logitrail's Merchant ID the request is scoped for.
          required: true
      responses:
        '200':
          summary: 200 OK
          description: Batch details updated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  batch:
                    type: object
                    properties:
                      id:
                        type: number
                        minimum: 1
                      inbound_shipment:
                        type: object
                        properties:
                          id:
                            type: string
                            pattern: ^[0-9a-f]{24}$
                          sender_name:
                            type:
                              - string
                              - 'null'
                        required:
                          - id
                          - sender_name
                      on_shelf_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                      batch_details:
                        type: object
                        properties:
                          batch_number:
                            type:
                              - string
                              - 'null'
                          best_before_date:
                            type:
                              - string
                              - 'null'
                            format: date
                      purchase_value_per_article:
                        type:
                          - number
                          - 'null'
                        description: >-
                          The purchase value per article in the batch. Null if
                          not set or not all articles in the batch have a
                          purchase value set. Precision up to 4 decimals (1.2345
                          EUR)
                      purchase_value_currency:
                        type:
                          - string
                          - 'null'
                        description: >-
                          The currency of the purchase value per article in the
                          batch.
                      article_count:
                        type: number
                        minimum: 0
                      warehouse_location:
                        type:
                          - string
                          - 'null'
                    required:
                      - id
                      - inbound_shipment
                      - on_shelf_at
                      - batch_details
                      - purchase_value_per_article
                      - purchase_value_currency
                      - article_count
                      - warehouse_location
                required:
                  - batch
        '400':
          summary: 400 Bad Request
          description: Most likely a validation error in the request.
        '404':
          summary: 404 Not Found
          description: Requested Arrival Batch not found.
components:
  securitySchemes:
    idp:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: >-
            https://idp.logitrail.com/realms/logitrail/protocol/openid-connect/token
          scopes:
            products:read: Read product information
            products:manage: Manage product information
