openapi: 3.1.0

info:
  title: Katana Public API
  version: 1.0.0
  description: |-
    Public API for Katana Manufacturing Resource Planning (MRP) platform.

    This OpenAPI specification provides comprehensive access to Katana's manufacturing,
    inventory, sales, and purchasing capabilities.

    **Key Features:**
    - Complete CRUD operations for all business objects
    - Real-time inventory management and tracking
    - Manufacturing order and BOM (Bill of Materials) management
    - Sales and purchase order processing
    - Webhook event notifications for real-time integrations
    - Rate limiting with retry headers for reliable API usage
    - Comprehensive pagination support for list endpoints

    **API Limits: **
    - Rate limit: 60 requests per 60 seconds
    - Max page size: 250 records per request
    - Default page size: 50 records per request

    **Webhook Events:**
    Subscribe to real-time notifications for 50+ event types including sales orders,
    manufacturing orders, inventory changes, and more.
  license:
    name: MIT
    url: https://opensource.org/license/mit/
servers:
  - url: https://api.katanamrp.com/v1
security:
  - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  parameters:
    custom_fields_format:
      description: "Selects the representation of `custom_fields` on items, for both the request body and
        the response.\n\n- `default` — object keyed by custom field definition id (UUID).\n- `legacy` — the
        `{field_name, field_value}` array tied to custom fields collections.\n\nMost accounts do not need
        this header: an account that has not moved to item custom fields always gets `legacy`, and an account
        that has moved and no longer uses collections always gets the object representation. The header matters
        only while both are available for the account, where `legacy` is the default and `default` opts into
        the object representation.\n\nRequesting a representation the account does not have returns 422, as
        does sending a `custom_fields` body whose shape does not match the representation in force, mixing
        both shapes in one request, or combining `custom_field_collection_id` with the object representation
        — that field belongs to the legacy representation and is left out of responses entirely under the
        object one. Responses vary on this header."
      in: header
      name: X-Custom-Fields-Format
      required: false
      schema:
        enum:
          - default
          - legacy
        type: string
    ids:
      name: ids
      in: query
      description: Filters results by an array of IDs.
      required: false
      schema:
        type: array
        items:
          type: integer
    variant_ids:
      name: variant_ids
      in: query
      description: Filters results by an array of variant IDs.
      required: false
      schema:
        type: array
        items:
          type: integer
    extend_inventory:
      name: extend
      in: query
      required: false
      description: Array of objects to extend the response for inventory endpoints.
      schema:
        type: array
        items:
          type: string
          enum:
            - variant
            - location
    extend_material:
      name: extend
      in: query
      required: false
      description: Array of objects to extend the response for material endpoints.
      schema:
        type: array
        items:
          type: string
          enum:
            - supplier
    extend_product:
      name: extend
      in: query
      required: false
      description: Array of objects to extend the response for product endpoints.
      schema:
        type: array
        items:
          type: string
          enum:
            - supplier
    extend_purchase_order:
      name: extend
      in: query
      required: false
      description: Array of objects to extend the response for purchase order endpoints.
      schema:
        type: array
        items:
          type: string
          enum:
            - supplier
    extend_sales_order_row:
      name: extend
      in: query
      required: false
      description: Array of objects to extend the response for sales order row endpoints.
      schema:
        type: array
        items:
          type: string
          enum:
            - variant
    extend_variant:
      name: extend
      in: query
      required: false
      description: Array of objects to extend the response for variant endpoints.
      schema:
        type: array
        items:
          type: string
          enum:
            - product_or_material
    location_id:
      name: location_id
      in: query
      description: Filters results by a location ID.
      required: false
      schema:
        type: integer
    inventory_movement_resource_type:
      name: resource_type
      in: query
      description: Filters inventory movements by the resource type that caused them.
      required: false
      schema:
        $ref: "#/components/schemas/InventoryMovementResourceTypeFilter"
    serial_number_resource_type:
      name: resource_type
      in: query
      description: Filters serial numbers by the resource type they are attached to.
      required: false
      schema:
        $ref: "#/components/schemas/SerialNumberResourceType"
    resource_id:
      name: resource_id
      in: query
      description: Filters results by a resource ID.
      required: false
      schema:
        type: integer
    caused_by_order_no:
      name: caused_by_order_no
      in: query
      description: Filters results by the causing order number.
      required: false
      schema:
        type: string
    caused_by_resource_id:
      name: caused_by_resource_id
      in: query
      description: Filters results by the causing resource ID.
      required: false
      schema:
        type: integer
    limit:
      name: limit
      in: query
      description: Number of records to return per page.
      required: false
      schema:
        type: integer
        default: 50
    page:
      name: page
      in: query
      description: Page number to return.
      required: false
      schema:
        type: integer
        default: 1
    created_at_min:
      name: created_at_min
      in: query
      description: Minimum creation date (ISO 8601 format).
      required: false
      schema:
        type: string
        format: date-time
    created_at_max:
      name: created_at_max
      in: query
      description: Maximum creation date (ISO 8601 format).
      required: false
      schema:
        type: string
        format: date-time
    updated_at_min:
      name: updated_at_min
      in: query
      description: Minimum update date (ISO 8601 format).
      required: false
      schema:
        type: string
        format: date-time
    updated_at_max:
      name: updated_at_max
      in: query
      description: Maximum update date (ISO 8601 format).
      required: false
      schema:
        type: string
        format: date-time
    batch_id:
      name: batch_id
      in: query
      description: Filters results by a valid batch id.
      schema:
        type: integer
    batch_number:
      name: batch_number
      in: query
      description: Filters results by a valid batch number.
      schema:
        type: string
    variant_id:
      name: variant_id
      in: query
      description: Filters results by a valid variant id.
      schema:
        type: integer
    include_archived:
      name: include_archived
      in: query
      required: false
      description: Includes archived results.
      schema:
        type: boolean
    batch_barcode:
      name: batch_barcode
      in: query
      description: Filter results by batch barcode.
      schema:
        type: string
    batch_created_at_min:
      name: batch_created_at_min
      in: query
      description: Minimum value for batch_created_at range (ISO 8601).
      schema:
        type: string
    batch_created_at_max:
      name: batch_created_at_max
      in: query
      description: Maximum value for batch_created_at range (ISO 8601).
      schema:
        type: string
    include_empty:
      name: include_empty
      in: query
      description: Include empty records in result.
      schema:
        type: boolean
    name:
      name: name
      in: query
      required: false
      description: Filters records by name.
      schema:
        type: string
    include_deleted:
      name: include_deleted
      in: query
      required: false
      description: Soft-deleted data is excluded from result set by default. Set to true to include it.
      schema:
        type: boolean
    legal_name:
      name: legal_name
      in: query
      description: Filters results by a legal name.
      required: false
      schema:
        type: string
    address_id:
      name: address_id
      in: query
      description: Filters results by an address ID.
      required: false
      schema:
        type: integer
    sales_allowed:
      name: sales_allowed
      in: query
      description: Filters results by whether sales are allowed.
      required: false
      schema:
        type: boolean
    manufacturing_allowed:
      name: manufacturing_allowed
      in: query
      description: Filters results by whether manufacturing is allowed.
      required: false
      schema:
        type: boolean
    purchases_allowed:
      name: purchases_allowed
      in: query
      description: Filters results by whether purchases are allowed.
      required: false
      schema:
        type: boolean
    rank:
      name: rank
      in: query
      description: Filters results by a rank value.
      required: false
      schema:
        type: integer
    bin_name:
      name: bin_name
      in: query
      required: false
      description: Filters storage bins by name.
      schema:
        type: string
    uom:
      name: uom
      required: false
      description: Filters records by unit of measure.
      schema:
        type: string
      in: query
    default_supplier_id:
      name: default_supplier_id
      required: false
      description: Filters records by default supplier ID.
      schema:
        type: integer
      in: query
    is_sellable:
      name: is_sellable
      required: false
      description: Filters records by whether they are sellable.
      schema:
        type: boolean
      in: query
    batch_tracked:
      name: batch_tracked
      required: false
      description: |-
        Filters records by batch-tracking status. Send the literal string
        ``"true"`` or ``"false"`` — Katana matches the wire value, not the JSON
        boolean.
      schema:
        type: string
        enum:
          - "true"
          - "false"
      in: query
    purchase_uom:
      name: purchase_uom
      required: false
      description: Filters records by purchase unit of measure.
      schema:
        type: string
      in: query
    purchase_uom_conversion_rate:
      name: purchase_uom_conversion_rate
      required: false
      description: Filters records by purchase unit of measure conversion rate.
      schema:
        type: number
      in: query
    sku:
      name: sku
      required: false
      description: Filters results by a sku
      schema:
        type: string
      in: query
    sku_list:
      name: sku
      required: false
      description: Filters results by list of skus
      schema:
        type: array
        items:
          type: string
      in: query
    category:
      name: category
      required: false
      description: Filters negative stock by a category
      schema:
        type: string
      in: query
    is_producible:
      name: is_producible
      required: false
      description: Filters products by an is_producible
      schema:
        type: boolean
      in: query
    is_purchasable:
      name: is_purchasable
      required: false
      description: Filters products by an is_purchasable
      schema:
        type: boolean
      in: query
    is_auto_assembly:
      name: is_auto_assembly
      required: false
      description: Filters products by an is_auto_assembly
      schema:
        type: boolean
      in: query
    serial_tracked:
      name: serial_tracked
      required: false
      description: |-
        Filters records by serial-tracking status. Send the literal string
        ``"true"`` or ``"false"`` — Katana matches the wire value, not the JSON
        boolean.
      schema:
        type: string
        enum:
          - "true"
          - "false"
      in: query
    operations_in_sequence:
      name: operations_in_sequence
      required: false
      description: Filters products by a operations_in_sequence
      schema:
        type: boolean
      in: query
    order_no:
      name: order_no
      required: false
      description: Filters purchase orders by an order number
      schema:
        type: string
      in: query
    entity_type:
      name: entity_type
      required: false
      description: Filters purchase orders by an entity type
      schema:
        $ref: "#/components/schemas/PurchaseOrderEntityType"
      in: query
    address_entity_type:
      name: entity_type
      required: false
      description: Filters addresses by entity type (billing or shipping).
      schema:
        $ref: "#/components/schemas/AddressEntityType"
      in: query
    po_status:
      name: status
      required: false
      description: Filters purchase orders by a status
      schema:
        enum:
          - DRAFT
          - NOT_RECEIVED
          - PARTIALLY_RECEIVED
          - RECEIVED
      in: query
    billing_status:
      name: billing_status
      required: false
      description: Filters purchase orders by a billing status
      schema:
        enum:
          - BILLED
          - NOT_BILLED
          - PARTIALLY_BILLED
      in: query
    currency:
      name: currency
      required: false
      description: Filters purchase orders by a currency
      schema:
        type: string
      in: query
    tracking_location_id:
      name: tracking_location_id
      required: false
      description: Filters purchase orders by a tracking location
      schema:
        type: number
      in: query
    supplier_id:
      name: supplier_id
      required: false
      description: Filters purchase orders by a supplier
      schema:
        type: number
      in: query
    group_id:
      name: group_id
      required: false
      description: Filters purchase order additional cost rows by group id
      schema:
        type: number
      in: query
    additional_cost_id:
      name: additional_cost_id
      required: false
      description: Filters purchase order additional cost rows by additional cost id
      schema:
        type: number
      in: query
    tax_rate_id:
      name: tax_rate_id
      required: false
      description: Filters purchase order additional cost rows by tax rate id
      schema:
        type: number
      in: query
    distribution_method:
      name: distribution_method
      required: false
      description: Filters purchase order additional cost rows by an distribution method
      schema:
        $ref: "#/components/schemas/CostDistributionMethod"
      in: query
    purchase_order_id:
      name: purchase_order_id
      required: false
      description: Filters purchase order rows by purchase order id
      schema:
        type: number
      in: query
    manufacturing_order_status:
      name: status
      required: false
      description: Filters manufacturing orders by a status.
      schema:
        $ref: "#/components/schemas/ManufacturingOrderStatus"
      in: query
    mo_operation_row_status:
      name: status
      required: false
      description: Filters manufacturing order operation rows by a status.
      schema:
        $ref: "#/components/schemas/ManufacturingOperationStatus"
      in: query
    manufacturing_order_id:
      name: manufacturing_order_id
      required: false
      description: Filters manufacturing orders by location.
      schema:
        type: number
      in: query
    received_items_group_id:
      name: received_items_group_id
      required: false
      description: Filters purchase order accounting metadata by received items group id
      schema:
        type: number
      in: query
    email:
      name: email
      required: false
      description: Filters suppliers by an email
      schema:
        type: string
      in: query
    first_name:
      name: first_name
      required: false
      description: Filters by first name
      schema:
        type: string
      in: query
    last_name:
      name: last_name
      required: false
      description: Filters by last name
      schema:
        type: string
      in: query
    company:
      name: company
      required: false
      description: Filters by company name
      schema:
        type: string
      in: query
    phone:
      name: phone
      required: false
      description: Filters suppliers by a phone number
      schema:
        type: string
      in: query
    supplier_ids:
      name: supplier_ids
      required: false
      description: Filters supplier addresses by an array of supplier IDs
      schema:
        type: array
        items:
          type: integer
      in: query
    line_1:
      name: line_1
      required: false
      description: Filters supplier addresses by a line_1
      schema:
        type: string
      in: query
    line_2:
      name: line_2
      required: false
      description: Filters supplier addresses by a line_2
      schema:
        type: string
      in: query
    city:
      name: city
      required: false
      description: Filters supplier addresses by a city
      schema:
        type: string
      in: query
    state:
      name: state
      required: false
      description: Filters supplier addresses by a state
      schema:
        type: string
      in: query
    zip:
      name: zip
      required: false
      description: Filters supplier addresses by a zip
      schema:
        type: string
      in: query
    country:
      name: country
      required: false
      description: Filters supplier addresses by a country
      schema:
        type: string
      in: query
    ingredient_availability:
      name: ingredient_availability
      required: false
      description: Filters manufacturing orders by an ingredient availability.
      schema:
        $ref: "#/components/schemas/IngredientAvailability"
      in: query
    rate:
      name: rate
      required: false
      description: Filters tax rates by rate
      schema:
        type: number
      in: query
    is_default_sales:
      name: is_default_sales
      required: false
      description: Filters tax rates by an is_default_sales
      schema:
        type: boolean
      in: query
    is_default_purchases:
      name: is_default_purchases
      required: false
      description: Filters tax rates by an is_default_purchases
      schema:
        type: boolean
      in: query
    product_id:
      name: product_id
      required: false
      description: Filters variants by a product id
      schema:
        type: integer
      in: query
    material_id:
      name: material_id
      required: false
      description: Filters variants by a material id
      schema:
        type: integer
      in: query
    sales_price:
      name: sales_price
      required: false
      description: Filters variants by a sales price
      schema:
        type: number
      in: query
    purchase_price:
      name: purchase_price
      required: false
      description: Filters variants by a purchase price
      schema:
        type: number
      in: query
    internal_barcode:
      name: internal_barcode
      required: false
      description: Filters variants by an internal barcode
      schema:
        type: string
        minLength: 3
        maxLength: 40
      in: query
    registered_barcode:
      name: registered_barcode
      required: false
      description: Filters variants by a registered barcode
      schema:
        type: string
        maxLength: 120
      in: query
    supplier_item_codes:
      name: supplier_item_codes
      required: false
      description: |
        Filters variants by supplier item codes. Returns the variants that match with any of the codes in the array.
      schema:
        type: array
        items:
          type: string
          minLength: 1
      in: query
    abc_classification:
      name: abc_classification
      required: false
      description: Filters variants by ABC inventory classification.
      schema:
        $ref: "#/components/schemas/AbcClassification"
      in: query
    url:
      name: url
      required: false
      description: Filters webhooks by an url
      schema:
        type: string
      in: query
    enabled:
      name: enabled
      required: false
      description: Filters webhooks by enabled flag
      schema:
        type: boolean
      in: query
    is_linked_to_sales_order:
      name: is_linked_to_sales_order
      required: false
      description: Filters based on whether a manufacturing order is linked to a sales order or not.
      schema:
        type: boolean
      in: query
    manufacturing_order_ids:
      name: manufacturing_order_ids
      required: false
      description: Filters manufacturing order productions by manufacturing order ids.
      schema:
        type: array
        items:
          type: integer
      in: query
    production_ids:
      name: production_ids
      required: false
      description: Filters manufacturing order production ingredients by production ids.
      schema:
        type: array
        items:
          type: integer
      in: query
    sales_return_order_no:
      name: order_no
      in: query
      description: Filters sales returns by their return order number.
      required: false
      schema:
        type: string
    sales_return_location_id:
      name: return_location_id
      in: query
      description: Filters sales returns by their return location ID.
      required: false
      schema:
        type: integer
    refund_status:
      name: refund_status
      in: query
      description: Filters sales returns by a refund status
      required: false
      schema:
        $ref: "#/components/schemas/SalesReturnRefundStatus"
    order_return_date_min:
      name: order_return_date_min
      in: query
      description: Minimum value for order return date range. Must be compatible with ISO 8601 format.
      required: false
      schema:
        type: string
        format: date-time
    order_return_date_max:
      name: order_return_date_max
      in: query
      description: Maximum value for order return date range. Must be compatible with ISO 8601 format.
      required: false
      schema:
        type: string
        format: date-time
    order_created_date_min:
      name: order_created_date_min
      in: query
      description: Minimum value for order_created_date range. Must be compatible with ISO 8601 format
      required: false
      schema:
        type: string
        format: date-time
    order_created_date_max:
      name: order_created_date_max
      in: query
      description: Maximum value for order_created_date range. Must be compatible with ISO 8601 format
      required: false
      schema:
        type: string
        format: date-time
    restock_location_id:
      name: restock_location_id
      in: query
      description: Filters sales return rows by a restock location id
      required: false
      schema:
        type: integer
    reason_id:
      name: reason_id
      in: query
      description: Filters sales return rows by a reason id
      required: false
      schema:
        type: integer
    sales_order_row_id:
      name: sales_order_row_id
      in: query
      description: Filters sales return rows by a sales order row id
      required: false
      schema:
        type: integer
    customer_ids:
      name: customer_ids
      in: query
      description: Filters customer addresses by an array of customer IDs
      required: false
      schema:
        type: array
        items:
          type: integer
    category_name:
      name: category_name
      in: query
      description: Filters results by category name
      required: false
      schema:
        type: string
    is_primary:
      name: is_primary
      in: query
      description: Filters locations by whether they are the primary location.
      required: false
      schema:
        type: boolean
    last_document_status:
      name: last_document_status
      in: query
      description: Filters purchase orders by the status of their last document.
      required: false
      schema:
        $ref: "#/components/schemas/PurchaseOrderDocumentStatus"
    fulfillment_invoice_status:
      name: invoice_status
      in: query
      description: Filters fulfillments by invoice status.
      required: false
      schema:
        $ref: "#/components/schemas/SalesOrderFulfillmentInvoiceStatusFilter"
    variant_type:
      name: type
      in: query
      description: Filters variants by item type (product or material).
      required: false
      schema:
        $ref: "#/components/schemas/InventoryItemType"
    id:
      name: id
      in: path
      required: true
      description: Resource identifier
      schema:
        type: integer
    bom_row_id:
      name: id
      in: path
      required: true
      description: BOM row identifier (UUID)
      schema:
        type: string
        format: uuid
    custom_field_definition_id:
      name: id
      in: path
      required: true
      description: Custom field definition identifier (UUID)
      schema:
        type: string
        format: uuid
    sales_order_id:
      name: sales_order_id
      in: query
      description: Filter by sales order ID
      schema:
        type: integer
    customer_id:
      name: customer_id
      in: query
      description: Filter by customer ID
      schema:
        type: integer
    status:
      name: status
      in: query
      description: Filter by status
      schema:
        type: string
    sales_return_status:
      name: status
      in: query
      description: Filter by status
      schema:
        $ref: "#/components/schemas/SalesReturnStatus"
    sales_order_fulfillment_status:
      name: status
      in: query
      description: Filter by status
      schema:
        $ref: "#/components/schemas/SalesOrderFulfillmentStatus"
    stocktake_status:
      name: status
      in: query
      description: Filter by status
      schema:
        $ref: "#/components/schemas/StocktakeStatus"
    ingredient_variant_id:
      name: ingredient_variant_id
      in: query
      description: Filter by ingredient variant ID
      schema:
        type: integer
    product_variant_id:
      name: product_variant_id
      in: query
      description: Filter by product variant ID
      schema:
        type: integer
    operation_id:
      name: operation_id
      in: query
      description: Filter by operation ID
      schema:
        type: integer
    operation_name:
      name: operation_name
      in: query
      description: Filter by operation name
      schema:
        type: string
    resource_name:
      name: resource_name
      in: query
      description: Filter by resource name
      schema:
        type: string
    product_operation_row_id:
      name: product_operation_row_id
      in: query
      description: Filter by product operation row ID
      schema:
        type: integer
  headers:
    X-Pagination:
      description: Pagination metadata containing page information for paginated responses
      schema:
        type: object
        properties:
          total_records:
            type: string
            description: Total number of records in the result set matching the filters (as string)
            example: "150"
          total_pages:
            type: string
            description: Number of pages in the result set (as string)
            example: "6"
          offset:
            type: string
            description: The offset from 0 for the start of this page (as string)
            example: "50"
          page:
            type: string
            description: The current page number being requested (as string)
            example: "3"
          first_page:
            type: string
            description: Whether the requested page is the first one in the collection (as string)
            example: "false"
          last_page:
            type: string
            description: Whether the requested page is the last one in the collection (as string)
            example: "false"
        required:
          - total_records
          - total_pages
          - offset
          - page
          - first_page
          - last_page
        example:
          total_records: "142"
          total_pages: "8"
          offset: "50"
          page: "2"
          first_page: "false"
          last_page: "false"
    X-Ratelimit-Limit:
      description: Number of requests available for this application (default 60 per minute)
      schema:
        type: integer
        example: 60
    X-Ratelimit-Remaining:
      description: Number of requests remaining in current rate limit window
      schema:
        type: integer
        example: 45
    X-Ratelimit-Reset:
      description: The timestamp (milliseconds since epoch) when the rate limit quota will reset
      schema:
        type: integer
        format: int64
        example: 1640995199000
    Retry-After:
      description: Number of seconds to wait before making another request when rate limited
      schema:
        type: integer
        example: 15
    X-Katana-Retry-Num:
      description: Webhook retry attempt number (1, 2, or 3)
      schema:
        type: integer
        minimum: 1
        maximum: 3
        example: 1
    X-Sha2-Signature:
      description: HMAC SHA-256 signature for webhook verification
      schema:
        type: string
        example: sha256=a8f5f167f44f4964e6c998dee827110c
  responses:
    NoContent:
      description: Object deleted successfully
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
    UnauthorizedError:
      description: Make sure you've entered your API token correctly.
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            statusCode: 401
            name: UnauthorizedError
            message: Unauthorized
    NotFoundError:
      description: Not found.
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            statusCode: 404
            name: NotFoundError
            message: Not found
    UnprocessableEntityError:
      description: Validation failed.
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/DetailedErrorResponse"
          example:
            statusCode: 422
            name: UnprocessableEntityError
            message: The request body is invalid. See error object `details` property for more info.
            code: VALIDATION_FAILED
            details:
              - path: .city
                code: maxLength
                message: should NOT be longer than 10 characters
                info:
                  limit: 10
    TooManyRequests:
      description: |-
        Rate limit exceeded - too many requests sent within the rate limit window (60 requests per 60 seconds)
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
        Retry-After:
          $ref: "#/components/headers/Retry-After"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            statusCode: 429
            name: TooManyRequests
            message: Too Many Requests
    InternalServerError:
      description: Internal Server Error.
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            statusCode: 500
            name: InternalServerError
            message: Internal Server Error
    BadRequestError:
      description: Bad Request Error.
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            statusCode: 400
            name: BadRequest
            message: Bad Request
    PreconditionFailedError:
      description: |-
        Precondition failed - the resource cannot be modified or deleted in its
        current state. Typically returned when a delete is blocked by linked
        child records (e.g. a sales order with attached return orders, or a
        purchase order with received stock).

        Note: 412 responses observed on these endpoints arrive wrapped in
        Katana's nested ``{"error": {...}}`` envelope (see example). The
        ``ErrorResponse`` schema describes the inner object; the wire payload
        nests it under an ``error`` key. The client's ``unwrap()`` helper
        handles both shapes transparently. Callers inspecting the raw
        payload directly (via ``sync_detailed()`` / ``asyncio_detailed()``
        and ``Response.content``) should expect the wrapped form.
      headers:
        X-Ratelimit-Limit:
          $ref: "#/components/headers/X-Ratelimit-Limit"
        X-Ratelimit-Remaining:
          $ref: "#/components/headers/X-Ratelimit-Remaining"
        X-Ratelimit-Reset:
          $ref: "#/components/headers/X-Ratelimit-Reset"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            error:
              statusCode: 412
              name: PreconditionFailedError
              message: Cannot delete sales orders as sales orders have return orders.
  schemas:
    RerankOrdersResponse:
      type: object
      description: Orders in their resulting order, including linked manufacturing orders moved together.
      required:
        - order_ids
      properties:
        order_ids:
          type: array
          description: IDs of the orders moved, in their resulting order
          minItems: 1
          uniqueItems: true
          items:
            type: integer
            minimum: 1
            maximum: 2147483647
      example:
        order_ids: [101, 102]
    ErrorResponse:
      type: object
      description: Base error message schema
      properties:
        statusCode:
          type: integer
          description: HTTP status code
        name:
          type: string
          description: Error name/type
        message:
          type: string
          description: Human-readable error message
    CodedErrorResponse:
      description: Error response with an additional application-specific error code for detailed error handling
      allOf:
        - $ref: "#/components/schemas/ErrorResponse"
        - type: object
          properties:
            code:
              type:
                - string
                - "null"
              description: Application-specific error code
    DetailedErrorResponse:
      description: Enhanced error response containing detailed validation error information for complex request failures
      allOf:
        - $ref: "#/components/schemas/CodedErrorResponse"
        - type: object
          properties:
            details:
              type: array
              description: Detailed validation error information
              items:
                $ref: "#/components/schemas/ValidationErrorDetail"
    ValidationErrorDetail:
      description: |
        Ajv-style validation error detail. Katana's API uses Ajv (the de facto
        Node.js JSON Schema validator) under the hood; every detail item maps
        to an Ajv ``ErrorObject``: ``path`` ↔ ``instancePath``, ``code`` ↔
        ``keyword``, ``info`` ↔ ``params``. The shape of ``info`` is keyword-
        specific — see each typed subtype.

        **No discriminator on purpose.** Each typed variant locks its ``code``
        to a specific Ajv keyword via ``Literal[<keyword>]``; deserializers
        try each variant and the first match wins. ``GenericValidationError``
        accepts any unknown ``code`` value, so future Ajv keywords (or
        custom user-defined ones) fall through gracefully instead of raising.
        A discriminator-based union here would lock the schema to today's
        keyword set and break on any new code Katana ships.
      oneOf:
        - $ref: "#/components/schemas/AdditionalPropertiesValidationError"
        - $ref: "#/components/schemas/ConstValidationError"
        - $ref: "#/components/schemas/DependenciesValidationError"
        - $ref: "#/components/schemas/EnumValidationError"
        - $ref: "#/components/schemas/ExclusiveMaximumValidationError"
        - $ref: "#/components/schemas/ExclusiveMinimumValidationError"
        - $ref: "#/components/schemas/FormatValidationError"
        - $ref: "#/components/schemas/MaxItemsValidationError"
        - $ref: "#/components/schemas/MaxLengthValidationError"
        - $ref: "#/components/schemas/MaximumValidationError"
        - $ref: "#/components/schemas/MinItemsValidationError"
        - $ref: "#/components/schemas/MinLengthValidationError"
        - $ref: "#/components/schemas/MinimumValidationError"
        - $ref: "#/components/schemas/MultipleOfValidationError"
        - $ref: "#/components/schemas/OneOfValidationError"
        - $ref: "#/components/schemas/PatternValidationError"
        - $ref: "#/components/schemas/RequiredValidationError"
        - $ref: "#/components/schemas/TypeValidationError"
        - $ref: "#/components/schemas/UniqueItemsValidationError"
        - $ref: "#/components/schemas/GenericValidationError"

    BaseValidationError:
      type: object
      description: |
        Common fields shared by every validation error detail. Maps to the
        non-keyword-specific portion of an Ajv ``ErrorObject``.
      properties:
        path:
          type: string
          description: |
            JSON path to the field with the error (Ajv's ``instancePath``).
            Format depends on Ajv config: leading ``/`` for JSON Pointer style
            or leading ``.`` / dotted style for legacy ``dataPath``.
        code:
          type: string
          description: Ajv keyword that failed (e.g. ``maxLength``, ``required``, ``type``)
        message:
          type: string
          description: Human-readable validation error message
      required:
        - path
        - code
        - message

    AdditionalPropertiesValidationError:
      description: |
        Ajv ``additionalProperties`` keyword: an object includes a property
        not permitted by the schema. ``info.additionalProperty`` names the
        offending key.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["additionalProperties"]
            info:
              type: object
              description: Keyword-specific metadata for ``additionalProperties``
              properties:
                additionalProperty:
                  type: string
                  description: The disallowed property name
              required:
                - additionalProperty
          required:
            - info

    ConstValidationError:
      description: |
        Ajv ``const`` keyword: the value must equal the schema's constant.
        ``info.allowedValue`` is the required value (any JSON type).
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["const"]
            info:
              type: object
              description: Keyword-specific metadata for ``const``
              properties:
                allowedValue:
                  description: The required constant value (any JSON type)
              required:
                - allowedValue
          required:
            - info

    DependenciesValidationError:
      description: |
        Ajv ``dependencies`` / ``dependentRequired`` keyword: presence of one
        property requires others. ``info`` carries the offending property,
        the missing dependent, and the full dependency list.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["dependencies"]
            info:
              type: object
              description: Keyword-specific metadata for ``dependencies``
              properties:
                property:
                  type: string
                  description: The property whose presence triggered the dependency check
                missingProperty:
                  type: string
                  description: The dependent property that is missing
                deps:
                  type: string
                  description: Comma-separated list of all required dependents
                depsCount:
                  type: integer
                  description: Total count of required dependents
              required:
                - property
                - missingProperty
          required:
            - info

    EnumValidationError:
      description: |
        Ajv ``enum`` keyword: the value is not in the allowed set.
        ``info.allowedValues`` is the schema's enum list.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["enum"]
            info:
              type: object
              description: Keyword-specific metadata for ``enum``
              properties:
                allowedValues:
                  type: array
                  items: {}
                  description: The schema's enum list (items can be any JSON type)
              required:
                - allowedValues
          required:
            - info

    ExclusiveMaximumValidationError:
      description: |
        Ajv ``exclusiveMaximum`` keyword: the value must be strictly less than
        ``info.limit``.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["exclusiveMaximum"]
            info:
              type: object
              description: Keyword-specific metadata for ``exclusiveMaximum``
              properties:
                limit:
                  type: number
                  description: Exclusive upper bound
                comparison:
                  type: string
                  enum: ["<"]
                  description: Ajv's comparison operator marker (always ``<``)
              required:
                - limit
          required:
            - info

    ExclusiveMinimumValidationError:
      description: |
        Ajv ``exclusiveMinimum`` keyword: the value must be strictly greater
        than ``info.limit``.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["exclusiveMinimum"]
            info:
              type: object
              description: Keyword-specific metadata for ``exclusiveMinimum``
              properties:
                limit:
                  type: number
                  description: Exclusive lower bound
                comparison:
                  type: string
                  enum: [">"]
                  description: Ajv's comparison operator marker (always ``>``)
              required:
                - limit
          required:
            - info

    FormatValidationError:
      description: |
        Ajv ``format`` keyword (e.g. ``email``, ``date-time``, ``uri``). The
        expected format name lives in ``info.format``.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["format"]
            info:
              type: object
              description: Keyword-specific metadata for ``format``
              properties:
                format:
                  type: string
                  description: Expected format name (``email``, ``date-time``, ``uri``, etc.)
              required:
                - format
          required:
            - info

    MaxItemsValidationError:
      description: |
        Ajv ``maxItems`` keyword: the array exceeds its maximum length.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["maxItems"]
            info:
              type: object
              description: Keyword-specific metadata for ``maxItems``
              properties:
                limit:
                  type: integer
                  description: Maximum allowed array length
              required:
                - limit
          required:
            - info

    MaxLengthValidationError:
      description: |
        Ajv ``maxLength`` keyword: the string exceeds its maximum length.
        The limit lives in ``info.limit`` (not as a sibling of ``code``).
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["maxLength"]
            info:
              type: object
              description: Keyword-specific metadata for ``maxLength``
              properties:
                limit:
                  type: integer
                  description: Maximum allowed string length
              required:
                - limit
          required:
            - info

    MaximumValidationError:
      description: |
        Ajv ``maximum`` keyword: the value exceeds its inclusive upper bound.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["maximum"]
            info:
              type: object
              description: Keyword-specific metadata for ``maximum``
              properties:
                limit:
                  type: number
                  description: Inclusive upper bound
                comparison:
                  type: string
                  enum: ["<="]
                  description: Ajv's comparison operator marker (always ``<=``)
              required:
                - limit
          required:
            - info

    MinItemsValidationError:
      description: |
        Ajv ``minItems`` keyword: the array is shorter than the schema's
        minimum length.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["minItems"]
            info:
              type: object
              description: Keyword-specific metadata for ``minItems``
              properties:
                limit:
                  type: integer
                  description: Minimum required array length
              required:
                - limit
          required:
            - info

    MinLengthValidationError:
      description: |
        Ajv ``minLength`` keyword: the string is shorter than the schema's
        minimum length. Parallel to ``MaxLengthValidationError`` — the limit
        lives in ``info.limit``.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["minLength"]
            info:
              type: object
              description: Keyword-specific metadata for ``minLength``
              properties:
                limit:
                  type: integer
                  description: Minimum required string length
              required:
                - limit
          required:
            - info

    MinimumValidationError:
      description: |
        Ajv ``minimum`` keyword: the value is below its inclusive lower bound.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["minimum"]
            info:
              type: object
              description: Keyword-specific metadata for ``minimum``
              properties:
                limit:
                  type: number
                  description: Inclusive lower bound
                comparison:
                  type: string
                  enum: [">="]
                  description: Ajv's comparison operator marker (always ``>=``)
              required:
                - limit
          required:
            - info

    MultipleOfValidationError:
      description: |
        Ajv ``multipleOf`` keyword: the value is not a multiple of
        ``info.multipleOf``.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["multipleOf"]
            info:
              type: object
              description: Keyword-specific metadata for ``multipleOf``
              properties:
                multipleOf:
                  type: number
                  description: Required divisor
              required:
                - multipleOf
          required:
            - info

    OneOfValidationError:
      description: |
        Ajv ``oneOf`` keyword: the value matched zero or multiple branches of
        the schema's ``oneOf``. ``info.passingSchemas`` is the array of
        matched branch indices when more than one matched, or ``null`` when
        none matched.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["oneOf"]
            info:
              type: object
              description: Keyword-specific metadata for ``oneOf``
              properties:
                passingSchemas:
                  type: ["array", "null"]
                  items:
                    type: integer
                  description: Indices of branches that matched (``null`` when none matched)
              required:
                - passingSchemas
          required:
            - info

    PatternValidationError:
      description: |
        Ajv ``pattern`` keyword: the string does not match the schema's
        regex. The pattern lives in ``info.pattern``.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["pattern"]
            info:
              type: object
              description: Keyword-specific metadata for ``pattern``
              properties:
                pattern:
                  type: string
                  description: Regular expression that must be matched
              required:
                - pattern
          required:
            - info

    RequiredValidationError:
      description: |
        Ajv ``required`` keyword: an object is missing a required property.
        ``info.missingProperty`` names the missing field.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["required"]
            info:
              type: object
              description: Keyword-specific metadata for ``required``
              properties:
                missingProperty:
                  type: string
                  description: Name of the required property that is missing
              required:
                - missingProperty
          required:
            - info

    TypeValidationError:
      description: |
        Ajv ``type`` keyword: the value's type does not match the schema's
        ``type``. ``info.type`` names the expected type.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["type"]
            info:
              type: object
              description: Keyword-specific metadata for ``type``
              properties:
                type:
                  type: string
                  description: Expected type (``string``, ``number``, ``integer``, ``boolean``, ``array``, ``object``, ``null``)
              required:
                - type
          required:
            - info

    UniqueItemsValidationError:
      description: |
        Ajv ``uniqueItems`` keyword: the array contains duplicate items.
        ``info.i`` and ``info.j`` are the indices of the duplicate pair.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              enum: ["uniqueItems"]
            info:
              type: object
              description: Keyword-specific metadata for ``uniqueItems``
              properties:
                i:
                  type: integer
                  description: Index of the first duplicate
                j:
                  type: integer
                  description: Index of the second duplicate
              required:
                - i
                - j
          required:
            - info

    GenericValidationError:
      description: |
        Permissive fallback for any Ajv keyword we haven't yet typed. The
        ``code`` field is unconstrained (just ``string``), so any wire value
        validates here when none of the typed variants match.
        ``BaseValidationError`` fields (``path``, ``code``, ``message``) are
        guaranteed; any keyword-specific ``info`` lives in
        ``additional_properties``.

        Listed last in ``ValidationErrorDetail.oneOf`` so deserializers try
        the typed variants first and only land here for unknown keywords.
      allOf:
        - $ref: "#/components/schemas/BaseValidationError"
        - type: object
          properties:
            code:
              type: string
              description: Ajv keyword that failed (any value not covered by typed subtypes)

    OutsourcedPurchaseOrderIngredientAvailability:
      type: string
      enum:
        - "PROCESSED"
        - "IN_STOCK"
        - "NOT_AVAILABLE"
        - "EXPECTED"
        - "NO_RECIPE"
        - "NOT_APPLICABLE"
      description: Status of ingredients required for outsourced purchase order production

    VariantType:
      type: string
      enum:
        - product
        - material
        - service
      description: Type classification of a variant

    PurchaseOrderDocumentStatus:
      type: string
      enum:
        - notSent
        - sending
        - sent
        - failed
      description: >-
        Status of a purchase order's last document, accepted by the
        `GET /purchase_orders` `last_document_status` filter (verified against
        the live API 2026-06-10).

    SalesOrderFulfillmentInvoiceStatusFilter:
      type: string
      enum:
        - INVOICED
        - NOT_INVOICED
      description: >-
        Invoice statuses accepted by the `GET /sales_order_fulfillments`
        `invoice_status` filter. A subset of SalesOrderFulfillmentInvoiceStatus
        (the response enum): the gateway does not allow filtering by
        `PARTIALLY_INVOICED` (verified against the live API 2026-06-10).

    AbcClassification:
      type: string
      enum:
        - A
        - B
        - C
      description: |-
        ABC inventory classification of the variant. Categorizes items by relative
        value and consumption importance.

    AddressEntityType:
      type: string
      enum:
        - billing
        - shipping
      description: Address type - billing for invoicing, shipping for delivery

    ManufacturingOrderStatus:
      type: string
      enum:
        - NOT_STARTED
        - BLOCKED
        - IN_PROGRESS
        - PARTIALLY_COMPLETED
        - DONE
      description: Production status of a manufacturing order

    CostDistributionMethod:
      type: string
      enum:
        - BY_VALUE
        - NON_DISTRIBUTED
      description: Method for distributing additional costs across purchase order items

    PurchaseOrderEntityType:
      type: string
      enum:
        - regular
        - outsourced
      description: Type of purchase order - regular for materials or outsourced for subcontracted work

    StocktakeStatus:
      type: string
      enum:
        - NOT_STARTED
        - IN_PROGRESS
        - COUNTED
        - COMPLETED
      description: Current status of a stocktake process

    SalesReturnStatus:
      type: string
      enum:
        - NOT_RETURNED
        - RETURNED_ALL
        - RESTOCKED_ALL
      description: Processing status of a sales return

    SalesReturnRefundStatus:
      type: string
      enum:
        - NOT_REFUNDED
        - REFUNDED
        - PARTIALLY_REFUNDED
      description: Refund status of a sales return

    OperatorWorkingArea:
      type: string
      enum:
        - shopFloor
        - warehouse
      description: Operator's primary working area in the shop

    ProductAvailability:
      type: string
      enum:
        - IN_STOCK
        - EXPECTED
        - PICKED
        - NOT_AVAILABLE
        - NOT_APPLICABLE
      description: Availability status of a product for order fulfillment

    IngredientAvailability:
      type: string
      enum:
        - PROCESSED
        - IN_STOCK
        - NOT_AVAILABLE
        - EXPECTED
        - NO_RECIPE
        - NOT_APPLICABLE
      description: Availability status of ingredients for production

    InventoryItemType:
      type: string
      enum:
        - product
        - material
      description: Item type discriminator for products and materials

    MaterialType:
      type: string
      enum:
        - material
      description: Item type discriminator for materials

    ProductType:
      type: string
      enum:
        - product
      description: Item type discriminator for products

    ServiceType:
      type: string
      enum:
        - service
      description: Item type discriminator for services

    ProductOperationType:
      type: string
      enum:
        - process
        - setup
        - perUnit
        - fixed
      description: Cost calculation method for product operations

    ManufacturingOperationStatus:
      type: string
      enum:
        - NOT_STARTED
        - BLOCKED
        - IN_PROGRESS
        - PAUSED
        - COMPLETED
      description: Status of a manufacturing order operation row
    ManufacturingOperationType:
      type: string
      enum:
        - process
        - setup
        - perUnit
        - fixed
      description: Type of operation defining how time and cost are calculated
    PurchaseOrderStatus:
      type: string
      enum:
        - DRAFT
        - NOT_RECEIVED
        - PARTIALLY_RECEIVED
        - RECEIVED
      description: Fulfillment status of a purchase order

    CreatePurchaseOrderInitialStatus:
      type: string
      enum:
        - DRAFT
        - NOT_RECEIVED
      description: Initial status when creating a purchase order

    PurchaseOrderBillingStatus:
      type: string
      enum:
        - BILLED
        - NOT_BILLED
        - PARTIALLY_BILLED
      description: Billing status through accounting integration

    DocumentSendStatus:
      type: string
      enum:
        - NOT_SENT
        - SENDING
        - FAILED
        - SENT
      description: Status of the last document e-mail sent

    SalesOrderStatus:
      type: string
      enum:
        - NOT_SHIPPED
        - PENDING
        - READY_FOR_FULFILLMENT
        - PARTIALLY_PACKED
        - PARTIALLY_DELIVERED
        - PACKED
        - DELIVERED
      description: |
        Fulfillment status of a sales order. ``PENDING`` is the initial
        status assigned to newly-created sales orders before they
        progress to ``NOT_SHIPPED``. The ``PARTIALLY_*`` states are
        server-computed; clients should not attempt to set them.

    SalesOrderProductionStatus:
      type: string
      enum:
        - NOT_STARTED
        - NONE
        - NOT_APPLICABLE
        - IN_PROGRESS
        - BLOCKED
        - DONE
      description: Production status of a sales order

    CreateSalesOrderStatus:
      type: string
      enum:
        - NOT_SHIPPED
        - PENDING
      description: Initial status when creating a sales order

    SalesOrderFulfillmentStatus:
      type: string
      enum:
        - PACKED
        - DELIVERED
      description: Status of a sales order fulfillment

    SalesOrderFulfillmentInvoiceStatus:
      type: string
      enum:
        - NOT_INVOICED
        - INVOICED
        - PARTIALLY_INVOICED
      description: Invoice status of a sales order fulfillment

    SalesOrderInvoicingStatus:
      type: string
      enum:
        - notInvoiced
        - partiallyInvoiced
        - invoiced
      description: |
        Sales-order-level invoicing status, rolled up across the order's
        fulfillments. The wire format differs from
        ``SalesOrderFulfillmentInvoiceStatus``: the order-level field uses
        camelCase (``invoiced``) while the fulfillment-level field uses
        SCREAMING_SNAKE_CASE (``INVOICED``).

    UpdateSalesOrderStatus:
      type: string
      enum:
        - NOT_SHIPPED
        - PENDING
        - READY_FOR_FULFILLMENT
        - PACKED
        - DELIVERED
      description: Allowed status values when updating a sales order

    StockTransferStatus:
      type: string
      enum:
        - draft
        - received
        - inTransit
      description: |
        Status of a stock transfer. Note the camelCase ``inTransit``.

    InventoryMovementResourceType:
      type: string
      enum:
        - Production
        - PurchaseOrderRow
        - PurchaseOrderRecipeRow
        - SalesOrderRow
        - ManufacturingOrderRecipeRow
        - StockAdjustmentRow
        - StockTransferRow
        - ManufacturingOrder
        - SystemGenerated
        - ProductionIngredient
      description: Type of resource that caused an inventory movement

    InventoryMovementResourceTypeFilter:
      type: string
      enum:
        - Production
        - ProductionIngredient
        - PurchaseOrderRecipeRow
        - PurchaseOrderRow
        - SalesOrderRow
        - StockAdjustmentRow
        - StockTransferRow
        - SystemGenerated
      description: >-
        Resource types accepted by the `GET /inventory_movements` `resource_type`
        filter. A subset of InventoryMovementResourceType (the response enum):
        the gateway does not allow filtering by ManufacturingOrder or
        ManufacturingOrderRecipeRow even though movements can reference them.

    SerialNumberResourceType:
      type: string
      enum:
        - ManufacturingOrder
        - Production
        - StockAdjustmentRow
        - StockTransferRow
        - PurchaseOrderRow
        - SalesOrderRow
        - SalesOrderFulfillmentRow
      description: Type of resource associated with a serial number

    CreateSerialNumberResourceType:
      type: string
      enum:
        - ManufacturingOrder
        - Production
        - StockAdjustmentRow
        - StockTransferRow
        - PurchaseOrderRow
        - SalesOrderRow
      description: |
        Allowed resource types when attaching serial numbers via
        ``POST /serial_numbers``. Every tested path requires a serial-number
        string that already exists. New strings were rejected for all tested
        resource types and manufacturing-order states; production and goods
        receipt create serial identities elsewhere in the API.

        Unknown strings hard-fail the request with ``422``. A valid resource
        can also reject attachment because of its state or remaining quantity.
        Manual attachment to otherwise readable manufacturing orders returned
        ``404`` in the September 2026 test-tenant probes, so this endpoint must
        not be treated as a prerequisite for production or fulfillment.

    CreateSerialNumberFailureReason:
      type: string
      enum:
        - DUPLICATE
        - MISSING
        - NOT_IN_STOCK
      description: |
        Per-string failure reasons documented in the published 200 response schema.
        NOT_IN_STOCK is documented for unavailable stock; it was not reproduced
        by the October 2026 test-tenant probes.
        Current invalid-input probes never produced these values: unknown,
        duplicate, and mixed valid/invalid inputs hard-failed the entire
        request with ``422``. The enum remains modeled until a successful
        attachment establishes the current 200 response shape.

    CustomFieldCollectionResourceType:
      type: string
      enum:
        - product
        - material
        - variant
        - customer
        - sales_order
        - purchase_order
        - stocktake
      description: Type of business object a custom fields collection applies to

    PriceListAdjustmentMethod:
      type: string
      enum:
        - fixed
        - percentage
        - markup
      description: Method used for price list adjustments

    AccountingIntegrationType:
      type: string
      enum:
        - xero
        - quickBooks
        - sage
        - custom
      description: Type of accounting system integration

    OutsourcedRecipeIngredientAvailability:
      type: string
      enum:
        - PROCESSED
        - IN_STOCK
        - NOT_AVAILABLE
        - EXPECTED
        - NO_RECIPE
        - NOT_APPLICABLE
      description: Ingredient availability for outsourced purchase order recipe rows

    BaseEntity:
      type: object
      description: Base entity with unique identifier
      properties:
        id:
          type: integer
          description: Unique identifier
      required:
        - id
      example:
        id: 12345
    UpdatableEntity:
      description: Common fields for entities that can be updated
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            created_at:
              type: string
              format: date-time
              description: Timestamp when the entity was first created
            updated_at:
              type: string
              format: date-time
              description: Timestamp when the entity was last updated
      example:
        id: 12345
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
    ArchivableEntity:
      description: Common fields for entities that can be archived
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            created_at:
              type: string
              format: date-time
              description: Timestamp when the entity was first created
            updated_at:
              type: string
              format: date-time
              description: Timestamp when the entity was last updated
            archived_at:
              type:
                - string
                - "null"
              format: date-time
              description: Nullable archive timestamp
      example:
        id: 12345
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        archived_at: null
    DeletableEntity:
      description: Common fields for entities that can be deleted
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            created_at:
              type: string
              format: date-time
              description: Timestamp when the entity was first created
            updated_at:
              type: string
              format: date-time
              description: Timestamp when the entity was last updated
            deleted_at:
              type:
                - string
                - "null"
              format: date-time
              description: Nullable deletion timestamp
      example:
        id: 12345
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        deleted_at: null
    ArchivableDeletableEntity:
      description: Common fields for entities that can be both archived and deleted
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            created_at:
              type: string
              format: date-time
              description: Timestamp when the entity was first created
            updated_at:
              type: string
              format: date-time
              description: Timestamp when the entity was last updated
            archived_at:
              type:
                - string
                - "null"
              format: date-time
              description: Nullable archive timestamp
            deleted_at:
              type:
                - string
                - "null"
              format: date-time
              description: Nullable deletion timestamp
      example:
        id: 12345
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        archived_at: null
        deleted_at: null
    MaterialConfig:
      description: Configuration option supplied while creating a material variant
      type: object
      additionalProperties: false
      required:
        - name
        - values
      properties:
        name:
          type: string
          description: Configuration attribute name (e.g., Grade, Thickness, Color)
        values:
          type: array
          description: Array of possible values for this configuration attribute
          items:
            type: string
      example:
        name: Grade
        values:
          - "Premium"
          - "Standard"
          - "Economy"
    ItemConfig:
      description: Configuration option for products and materials that defines variant attributes
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            name:
              type: string
              description: Configuration attribute name (e.g., Size, Color, Style, Grade)
            values:
              type: array
              description: Array of possible values for this configuration attribute
              items:
                type: string
            product_id:
              type:
                - integer
                - "null"
              description: ID of the product this configuration belongs to (null for materials)
            material_id:
              type:
                - integer
                - "null"
              description: ID of the material this configuration belongs to (null for products)
          required:
            - name
            - values
      example:
        id: 201
        name: Type
        values:
          - "Standard"
          - "Double-bladed"
        product_id: 1
        material_id: null
    AdditionalCost:
      description: |
        Additional cost types that can be applied to purchase orders and manufacturing orders (e.g., shipping, taxes,
        duties)
      allOf:
        - type: object
          properties:
            name:
              type: string
          required:
            - name
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 1
        name: Shipping Cost
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        deleted_at: null
    AdditionalCostListResponse:
      description: Response containing a list of additional cost types for purchase orders and manufacturing orders
      type: object
      properties:
        data:
          type: array
          description: Array of additional cost types that can be applied to orders
          items:
            $ref: "#/components/schemas/AdditionalCost"
      example:
        data:
          - id: 1
            name: Shipping Cost
            created_at: "2020-10-23T10:37:05.085Z"
            updated_at: "2020-10-23T10:37:05.085Z"
            deleted_at: null
          - id: 2
            name: Import Duty
            created_at: "2020-10-23T10:37:05.085Z"
            updated_at: "2020-10-23T10:37:05.085Z"
            deleted_at: null
    Batch:
      type: object
      description: Core batch business properties
      required:
        - batch_number
        - variant_id
      properties:
        batch_number:
          type: string
          description: Unique batch number identifier
        expiration_date:
          type: string
          format: date-time
          description: Batch expiration date (ISO 8601)
        batch_created_date:
          type: string
          format: date-time
          description: Batch creation date (ISO 8601)
        variant_id:
          type: integer
          maximum: 2147483647
          description: ID of the variant this batch belongs to
        batch_barcode:
          type:
            - string
            - "null"
          minLength: 3
          maxLength: 40
          description: Optional barcode for the batch
      example:
        batch_number: BAT-2024-001
        expiration_date: "2025-10-23T10:37:05.085Z"
        batch_created_date: "2024-01-15T08:00:00.000Z"
        variant_id: 1001
        batch_barcode: "0317"
    BatchStock:
      description: Batch inventory record showing current stock levels for a specific batch at a specific location
      allOf:
        - $ref: "#/components/schemas/Batch"
        - type: object
          properties:
            batch_id:
              type: integer
            location_id:
              type: integer
              description: ID of the location where the batch is stored
            quantity_in_stock:
              type: string
              description: Current quantity in stock for this batch
      example:
        batch_id: 1109
        batch_number: BAT-2024-001
        batch_created_date: "2024-01-15T08:00:00.000Z"
        expiration_date: "2025-10-23T10:37:05.085Z"
        location_id: 1
        variant_id: 1001
        quantity_in_stock: "25.00000"
        batch_barcode: "0317"
    BatchStockListResponse:
      type: object
      description: List of batch stock records showing current inventory levels for tracked batches across all locations
      properties:
        data:
          type: array
          description: Array of batch stock records with current quantities
          items:
            $ref: "#/components/schemas/BatchStock"
      example:
        data:
          - batch_id: 1109
            batch_number: BAT-2024-001
            batch_created_date: "2024-01-15T08:00:00.000Z"
            expiration_date: "2025-10-23T10:37:05.085Z"
            location_id: 1
            variant_id: 1001
            quantity_in_stock: "25.00000"
            batch_barcode: "0317"
          - batch_id: 1110
            batch_number: BAT-2024-002
            batch_created_date: "2024-01-16T09:30:00.000Z"
            expiration_date: "2025-11-15T10:37:05.085Z"
            location_id: 1
            variant_id: 1002
            quantity_in_stock: "50.00000"
            batch_barcode: "0318"
    BatchStockUpdate:
      type: object
      description: Request payload for updating batch properties and tracking information
      additionalProperties: false
      properties:
        batch_number:
          type: string
          description: Updated batch number
        expiration_date:
          type: string
          format: date-time
          description: Updated expiration date (ISO 8601)
        batch_created_date:
          type: string
          format: date-time
          description: Updated batch creation date (ISO 8601)
        batch_barcode:
          type:
            - string
            - "null"
          minLength: 3
          maxLength: 40
          description: Updated barcode for the batch
      example:
        batch_number: BAT-2024-001-UPDATED
        expiration_date: "2025-12-31T23:59:59.000Z"
        batch_barcode: 0317-V2
    BatchResponse:
      description: Complete batch record with system metadata for inventory tracking and traceability
      allOf:
        - $ref: "#/components/schemas/Batch"
        - $ref: "#/components/schemas/UpdatableEntity"
      example:
        id: 1109
        batch_number: BAT-2024-001
        expiration_date: "2025-10-23T10:37:05.085Z"
        batch_created_date: "2024-01-15T08:00:00.000Z"
        created_at: "2024-01-15T08:00:00.000Z"
        updated_at: "2024-01-15T08:00:00.000Z"
        variant_id: 1001
        batch_barcode: "0317"
    ManufacturingOrderProductionBatchTransaction:
      type: object
      additionalProperties: false
      description: |-
        Batch allocation for a manufacturing order production run.

        Deliberately **not** the shared ``BatchTransaction``: this endpoint
        takes the batch alone. The produced amount is already given by
        ``completed_quantity`` on the request body, so a per-batch
        ``quantity`` would be redundant — and upstream's
        ``CompletePartiallyBatchDto`` sets ``additionalProperties: false``,
        so sending one is rejected with 422 (verified against the live API
        2026-09-18, #1042).
      required:
        - batch_id
      properties:
        batch_id:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: ID of the batch the produced quantity is allocated to.

    SalesOrderRowBatchTransactionUpdate:
      type: object
      additionalProperties: false
      description: >-
        Batch allocation on a sales order row update. Omitting quantity sets
        the allocation to zero; it does not preserve its previous quantity
        (verified against the live API, #1053).
      required:
        - batch_id
      properties:
        batch_id:
          type: integer
          maximum: 2147483647
          description: ID of the batch for the allocation
        quantity:
          type: number
          description: Allocated quantity; omission resets it to zero
      example:
        batch_id: 1109
    BatchTransaction:
      type: object
      description: |
        Represents a quantity transaction for a specific batch in manufacturing, sales, or inventory operations
      additionalProperties: false
      required:
        - batch_id
        - quantity
      properties:
        batch_id:
          type: integer
          description: ID of the batch for the transaction
        quantity:
          type: number
          description: The quantity in this batch transaction
      example:
        batch_id: 1109
        quantity: 25.0
    StorageBin:
      type: object
      description: Core storage bin business properties
      required:
        - bin_name
        - location_id
      properties:
        name:
          type: string
          description: Name of the storage bin (returned by list endpoint)
        bin_name:
          type: string
          description: Name of the storage bin (used in create/update requests and individual responses)
        location_id:
          type: integer
          description: Unique identifier of the location where storage bin is located
      example:
        bin_name: Bin-2
        location_id: 12346
    StorageBinResponse:
      description: Complete storage bin record with location details and system metadata for warehouse organization
      allOf:
        - $ref: "#/components/schemas/StorageBin"
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 12345
        name: Bin-2
        bin_name: Bin-2
        location_id: 12346
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        deleted_at: null
    StorageBinUpdate:
      type: object
      description: Storage bin fields for update operations
      additionalProperties: false
      required:
        - bin_name
      properties:
        bin_name:
          type: string
          description: Name of the storage bin
      example:
        bin_name: A-01-SHELF-2
    StorageBinCreate:
      type: object
      description: Storage bin fields for create operations
      additionalProperties: false
      required:
        - bin_name
        - location_id
      properties:
        bin_name:
          type: string
          minLength: 1
          description: Name of the storage bin
        location_id:
          type: integer
          minimum: 1
          description: ID of the location the storage bin belongs to
      example:
        bin_name: A-01-SHELF-2
        location_id: 12346
    BinTransferStatus:
      type: string
      enum:
        - CREATED
        - IN_TRANSIT
        - DONE
      description: |-
        Lifecycle status of a bin transfer. New transfers start in `CREATED`; status
        changes are applied through the dedicated status endpoint.
    BinInventoryGranularity:
      type: string
      enum:
        - VARIANT
        - BATCH
        - SERIAL_NUMBER
      default: VARIANT
      description: |-
        Row granularity for a bin inventory query. `VARIANT` returns one row per
        (location, variant, bin); `BATCH` and `SERIAL_NUMBER` break rows down further
        by the matching traceability axis.
    BinTransferTraceability:
      type: object
      description: |-
        Traceability allocation on a bin transfer row, pinning the moved quantity to a
        specific batch and/or serial number. A null axis means that axis is unset.
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the batch this quantity is drawn from, or null when unbatched.
        serial_number_id:
          type:
            - integer
            - "null"
          description: ID of the serial number this quantity is drawn from, or null when untraced.
        quantity:
          type: string
          description: Quantity allocated to this traceability axis, as a decimal string.
    BinTransferRow:
      description: |-
        Line item in a bin transfer — the variant, quantity, and source/target bins the
        stock moves between, with optional batch/serial traceability.
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the bin transfer row.
            bin_transfer_id:
              type: integer
              description: ID of the parent bin transfer.
            location_id:
              type: integer
              description: ID of the location the transfer occurs within.
            variant_id:
              type: integer
              description: ID of the product or material variant being moved.
            quantity:
              type: string
              description: Quantity being moved, as a decimal string.
            source_bin_location_id:
              type:
                - integer
                - "null"
              description: ID of the bin the stock moves from, or null when unassigned.
            target_bin_location_id:
              type:
                - integer
                - "null"
              description: ID of the bin the stock moves to, or null when unassigned.
            traceability:
              type: array
              description: Batch/serial allocations for the moved quantity.
              items:
                $ref: "#/components/schemas/BinTransferTraceability"
            created_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date the parent transfer was created (mirrored onto the row).
            departed_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp the stock departed the source bin.
            arrived_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp the stock arrived at the target bin.
          required:
            - id
            - bin_transfer_id
            - variant_id
            - quantity
        - $ref: "#/components/schemas/DeletableEntity"
    BinTransfer:
      description: |-
        A movement of stock between bins within a single location, optionally carrying
        per-row batch/serial traceability.
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the bin transfer.
            bin_transfer_number:
              type: string
              description: Human-readable reference number for the transfer.
            location_id:
              type: integer
              description: ID of the location the transfer occurs within.
            status:
              description: Current lifecycle status of the transfer.
              $ref: "#/components/schemas/BinTransferStatus"
            created_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date the transfer was created.
            departed_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp the transfer left the source bins.
            arrived_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp the transfer reached the target bins.
            additional_info:
              type:
                - string
                - "null"
              description: Optional free-text note about the transfer.
            bin_transfer_rows:
              type: array
              description: Line items detailing the variants and quantities being moved.
              items:
                $ref: "#/components/schemas/BinTransferRow"
          required:
            - id
            - bin_transfer_number
            - location_id
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 1
        bin_transfer_number: BT-1
        location_id: 1
        status: IN_TRANSIT
        created_date: "2026-05-22T10:00:00.000Z"
        departed_at: "2026-05-22T11:00:00.000Z"
        arrived_at: null
        additional_info: urgent transfer
        bin_transfer_rows:
          - id: 11
            bin_transfer_id: 1
            location_id: 1
            variant_id: 42
            quantity: "3"
            source_bin_location_id: 7
            target_bin_location_id: 9
            traceability:
              - batch_id: 100
                serial_number_id: null
                quantity: "3"
            created_at: "2026-05-22T10:00:00.000Z"
            updated_at: "2026-05-22T10:00:00.000Z"
            deleted_at: null
        created_at: "2026-05-22T10:00:00.000Z"
        updated_at: "2026-05-22T10:00:00.000Z"
        deleted_at: null
    BinTransferListResponse:
      type: object
      description: Paginated list of bin transfer records.
      properties:
        data:
          type: array
          description: Array of bin transfer records.
          items:
            $ref: "#/components/schemas/BinTransfer"
      example:
        data:
          - id: 1
            bin_transfer_number: BT-1
            location_id: 1
            status: CREATED
            created_date: "2026-05-22T10:00:00.000Z"
            departed_at: null
            arrived_at: null
            additional_info: urgent transfer
            bin_transfer_rows: []
            created_at: "2026-05-22T10:00:00.000Z"
            updated_at: "2026-05-22T10:00:00.000Z"
            deleted_at: null
    BinTransferRowListResponse:
      type: object
      description: Paginated list of bin transfer rows.
      properties:
        data:
          type: array
          description: Array of bin transfer row records.
          items:
            $ref: "#/components/schemas/BinTransferRow"
      example:
        data:
          - id: 11
            bin_transfer_id: 1
            location_id: 1
            variant_id: 42
            quantity: "3"
            source_bin_location_id: 7
            target_bin_location_id: 9
            traceability:
              - batch_id: 100
                serial_number_id: null
                quantity: "3"
            created_at: "2026-05-22T10:00:00.000Z"
            updated_at: "2026-05-22T10:00:00.000Z"
            deleted_at: null
    BinInventory:
      type: object
      description: |-
        Per-bin inventory position at the requested granularity. Quantities are decimal
        strings. A null `bin_location_id`, `batch_id`, or `serial_number_id` denotes
        stock whose traceability on that axis is unset. Rows reaching zero across all
        three quantities are removed, so absence implies zero.
      properties:
        location_id:
          type: integer
          description: ID of the location.
        variant_id:
          type: integer
          description: ID of the variant.
        bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin, or null for stock with no bin assignment.
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the batch (present at `BATCH` granularity), or null.
        serial_number_id:
          type:
            - integer
            - "null"
          description: ID of the serial number (present at `SERIAL_NUMBER` granularity), or null.
        quantity_in_stock:
          type: string
          description: On-hand quantity in this position, as a decimal string.
        quantity_committed:
          type: string
          description: Quantity committed to orders, as a decimal string.
        quantity_expected:
          type: string
          description: Quantity expected from inbound receipts, as a decimal string.
    BinInventoryListResponse:
      type: object
      description: Paginated list of per-bin inventory positions.
      properties:
        data:
          type: array
          description: Array of per-bin inventory positions.
          items:
            $ref: "#/components/schemas/BinInventory"
      example:
        data:
          - location_id: 1
            variant_id: 42
            bin_location_id: 7
            batch_id: null
            serial_number_id: null
            quantity_in_stock: "12.0000000000"
            quantity_committed: "2.0000000000"
            quantity_expected: "5.0000000000"
    BinTransferTraceabilityRequest:
      type: object
      additionalProperties: false
      description: Batch/serial allocation supplied on a bin transfer row.
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the batch to draw from, or null.
        serial_number_id:
          type:
            - integer
            - "null"
          description: ID of the serial number to draw from, or null.
        quantity:
          type: string
          description: Quantity to allocate to this axis, as a decimal string.
    ManufacturingOrderTraceabilityRequest:
      type: object
      additionalProperties: false
      description: |-
        Batch / serial allocation supplied on a manufacturing order or a
        production — the **output** side of manufacturing. Narrows
        ``TraceabilityRequest`` by dropping ``bin_location_id``: you are
        allocating finished goods to a batch and/or serial number, not
        drawing them from a bin. Upstream models this as
        ``Omit<TraceabilityInputItemDto, 'bin_location_id'>`` and rejects
        the extra property, hence a distinct component rather than a reuse
        of the four-field base.
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the batch to allocate the produced quantity to, or null.
        serial_number_id:
          type:
            - integer
            - "null"
          description: ID of the serial number to attach to the produced quantity, or null.
        quantity:
          type: number
          description: Quantity allocated to this axis. Must be non-zero when supplied.

    ManufacturingOrderIngredientTraceabilityRequest:
      type: object
      additionalProperties: false
      description: |-
        Batch / bin allocation supplied on a manufacturing order recipe row
        or a production ingredient — the **input** side of manufacturing.
        Narrows ``TraceabilityRequest`` by dropping ``serial_number_id``:
        you are consuming ingredients from a batch in a bin, and serial
        attachment belongs to the produced output rather than the
        ingredient. Upstream models this as
        ``Omit<TraceabilityInputItemDto, 'serial_number_id'>`` and rejects
        the extra property.
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the batch to draw the ingredient from, or null.
        bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin location to draw the ingredient from, or null.
        quantity:
          type: number
          description: Quantity allocated to this axis. Must be non-zero when supplied.

    TraceabilityRequest:
      type: object
      additionalProperties: false
      description: |-
        Batch / serial / bin allocation supplied on a create-or-update row to
        trace the moved quantity to a specific batch, serial number, and/or
        bin location. Mirrors Katana's ``TraceabilityInputItemDto`` — the
        unified traceability input that supersedes the older per-entity
        ``serial_numbers`` arrays for attaching serial-tracked units to a row.

        Any axis may be null; a non-null ``serial_number_id`` attaches (or
        draws from) that serial number for the allocated ``quantity``. Katana
        marks ``quantity`` required on stock-adjustment traceability rows and
        treats it as the per-allocation amount everywhere else, so it is
        modelled as optional here to accept every valid payload shape.
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the batch to draw from, or null.
        bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin location to draw from, or null.
        serial_number_id:
          type:
            - integer
            - "null"
          description: ID of the serial number to attach / draw from, or null.
        quantity:
          type: number
          description: >-
            Quantity allocated to this axis. Must be non-zero when supplied.
    BinTransferRowCreateNested:
      type: object
      additionalProperties: false
      description: A bin transfer row supplied inline when creating a bin transfer.
      required:
        - variant_id
        - quantity
      properties:
        variant_id:
          type: integer
          description: ID of the variant to move.
        quantity:
          type: string
          description: Quantity to move, as a decimal string.
        source_bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin to move stock from, or null.
        target_bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin to move stock to, or null.
        traceability:
          type: array
          description: Optional batch/serial allocations for the moved quantity.
          items:
            $ref: "#/components/schemas/BinTransferTraceabilityRequest"
    CreateBinTransferRequest:
      type: object
      additionalProperties: false
      description: |-
        Request payload for creating a bin transfer, optionally with rows and per-row
        traceability in a single call.
      required:
        - location_id
      properties:
        location_id:
          type: integer
          description: ID of the location the transfer occurs within.
        bin_transfer_number:
          type: string
          minLength: 1
          maxLength: 255
          description: Human-readable reference number for the transfer.
        additional_info:
          type:
            - string
            - "null"
          description: Optional free-text note about the transfer.
        created_date:
          type: string
          format: date-time
          description: Date the transfer was created. Defaults to now when omitted.
        bin_transfer_rows:
          type: array
          maxItems: 250
          description: Line items to create together with the transfer.
          items:
            $ref: "#/components/schemas/BinTransferRowCreateNested"
      example:
        location_id: 1
        bin_transfer_number: BT-1
        additional_info: urgent transfer
        bin_transfer_rows:
          - variant_id: 42
            quantity: "3"
            source_bin_location_id: 7
            target_bin_location_id: 9
            traceability:
              - batch_id: 100
                quantity: "3"
    UpdateBinTransferRequest:
      type: object
      additionalProperties: false
      description: Request payload for updating a bin transfer's header fields.
      properties:
        bin_transfer_number:
          type: string
          minLength: 1
          maxLength: 255
          description: Updated reference number.
        location_id:
          type: integer
          description: Updated location ID.
        additional_info:
          type:
            - string
            - "null"
          description: Updated free-text note.
        created_date:
          type:
            - string
            - "null"
          format: date-time
          description: Updated creation date.
        departed_at:
          type:
            - string
            - "null"
          format: date-time
          description: Updated departure timestamp.
        arrived_at:
          type:
            - string
            - "null"
          format: date-time
          description: Updated arrival timestamp.
      example:
        bin_transfer_number: BT-1
        additional_info: updated note
    CreateBinTransferRowRequest:
      type: object
      additionalProperties: false
      description: Request payload for adding a row to an existing bin transfer.
      required:
        - bin_transfer_id
        - variant_id
        - quantity
      properties:
        bin_transfer_id:
          type: integer
          description: ID of the bin transfer to add this row to.
        variant_id:
          type: integer
          description: ID of the variant to move.
        quantity:
          type: string
          description: Quantity to move, as a decimal string.
        source_bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin to move stock from, or null.
        target_bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin to move stock to, or null.
        traceability:
          type: array
          description: Optional batch/serial allocations for the moved quantity.
          items:
            $ref: "#/components/schemas/BinTransferTraceabilityRequest"
      example:
        bin_transfer_id: 1
        variant_id: 42
        quantity: "3"
        source_bin_location_id: 7
        target_bin_location_id: 9
    UpdateBinTransferRowRequest:
      type: object
      additionalProperties: false
      description: Request payload for updating a bin transfer row.
      properties:
        variant_id:
          type: integer
          description: Updated variant ID.
        quantity:
          type: string
          description: Updated quantity, as a decimal string.
        source_bin_location_id:
          type:
            - integer
            - "null"
          description: Updated source bin ID, or null.
        target_bin_location_id:
          type:
            - integer
            - "null"
          description: Updated target bin ID, or null.
        traceability:
          type: array
          description: Updated batch/serial allocations for the moved quantity.
          items:
            $ref: "#/components/schemas/BinTransferTraceabilityRequest"
      example:
        quantity: "5"
    UpdateBinTransferStatusRequest:
      type: object
      additionalProperties: false
      description: Request payload for changing a bin transfer's status.
      required:
        - status
      properties:
        status:
          description: New status for the bin transfer.
          $ref: "#/components/schemas/BinTransferStatus"
      example:
        status: IN_TRANSIT
    InventoryMovement:
      description: |
        Record of inventory quantity changes caused by transactions like sales, purchases, manufacturing, or adjustments
      allOf:
        - type: object
          properties:
            variant_id:
              type: integer
              description: Identifier of the product variant associated with the movement.
            location_id:
              type: integer
              description: Identifier of the location where the movement occurred.
            resource_type:
              description: The type of resource that caused the movement.
              $ref: "#/components/schemas/InventoryMovementResourceType"
            resource_id:
              type: integer
              description: Identifier of the resource that initiated the movement.
            caused_by_order_no:
              type: string
              description: Order number that triggered the movement.
            caused_by_resource_id:
              type: integer
              description: Identifier for the resource that caused the movement.
            movement_date:
              type: string
              format: date-time
              description: Date and time when the inventory movement occurred.
            quantity_change:
              type: number
              description: The change in quantity as a result of the movement.
            balance_after:
              type: number
              description: The quantity balance after the movement.
            value_per_unit:
              type: number
              description: The value per unit for the movement.
            value_in_stock_after:
              type: number
              description: The total value in stock after the movement.
            average_cost_after:
              type: number
              description: The average cost per unit after the movement.
            rank:
              type: integer
              description: A rank or order index for the movement.
        - $ref: "#/components/schemas/UpdatableEntity"
      required:
        - variant_id
        - location_id
        - resource_type
        - movement_date
        - quantity_change
        - balance_after
        - value_per_unit
        - value_in_stock_after
        - average_cost_after
        - created_at
        - updated_at
      example:
        id: 12345
        variant_id: 3001
        location_id: 1
        resource_type: PurchaseOrderRow
        resource_id: 5001
        caused_by_order_no: PO-2024-001
        caused_by_resource_id: 5001
        movement_date: "2024-01-15T10:30:00.000Z"
        quantity_change: 100.0
        balance_after: 500.0
        value_per_unit: 25.5
        value_in_stock_after: 12750.0
        average_cost_after: 25.5
        rank: 1
        created_at: "2024-01-15T10:30:00.000Z"
        updated_at: "2024-01-15T10:30:00.000Z"
    InventoryMovementListResponse:
      type: object
      description: |
        A list of inventory movement records tracking stock changes, transfers, and adjustments across locations.
      properties:
        data:
          type: array
          description: Array of inventory movement records with transaction details
          items:
            $ref: "#/components/schemas/InventoryMovement"
      required:
        - data
      example:
        data:
          - id: 5001
            variant_id: 2002
            location_id: 1
            resource_type: PurchaseOrderRow
            resource_id: 1001
            caused_by_order_no: PO-2024-001
            caused_by_resource_id: 1001
            movement_type: TRANSFER_IN
            movement_date: "2023-10-15T14:30:00Z"
            quantity: 10.0
            quantity_change: 10.0
            balance_after: 100.0
            cost_per_unit: 12.5
            value_per_unit: 12.5
            total_cost: 125.0
            value_in_stock_after: 1250.0
            average_cost_after: 12.5
            reference_id: 1001
            notes: Received from supplier shipment
            created_at: "2023-10-15T14:30:00Z"
            updated_at: "2023-10-15T14:30:00Z"
    Variant:
      description: Specific SKU of a product or material with unique pricing, configuration, and inventory tracking
      allOf:
        - $ref: "#/components/schemas/UpdatableEntity"
        - type: object
          properties:
            sku:
              type:
                - string
                - "null"
              description: |-
                Stock keeping unit - unique identifier for this variant. Katana allows
                variants to be created without a SKU; the field is always present in the
                response but may be null for such rows.
            sales_price:
              type:
                - number
                - "null"
              description: Price at which this variant is sold to customers
            product_id:
              type:
                - integer
                - "null"
              description: ID of the parent product if this variant belongs to a finished good
            material_id:
              type:
                - integer
                - "null"
              description: ID of the parent material if this variant belongs to a raw material
            purchase_price:
              type: number
              description: Cost to purchase this variant from suppliers
            type:
              $ref: "#/components/schemas/VariantType"
            internal_barcode:
              type:
                - string
                - "null"
              description: Internal barcode for warehouse scanning and tracking
            registered_barcode:
              type:
                - string
                - "null"
              description: Official registered barcode (UPC, EAN, etc.) for retail use
            supplier_item_codes:
              type: array
              description: Supplier-specific part numbers or SKUs for purchasing
              items:
                type: string
            lead_time:
              type:
                - integer
                - "null"
              description: Days required to manufacture or procure this variant
            minimum_order_quantity:
              type:
                - number
                - "null"
              description: Minimum quantity that must be ordered from suppliers
            custom_fields:
              description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
              anyOf:
                - type: array
                  items:
                    type: object
                    properties:
                      field_name:
                        type: string
                        description: Name of the custom field
                      field_value:
                        type: string
                        description: Value stored in the custom field
                - type: object
                  propertyNames:
                    pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
                  additionalProperties:
                    type:
                      - string
                      - number
                      - boolean
                      - 'null'
                - type: 'null'
            config_attributes:
              type:
                - array
                - "null"
              description: Configuration attribute values that define this variant (color, size, etc.)
              items:
                type: object
                properties:
                  config_name:
                    type: string
                    description: Name of the configuration attribute (e.g., Color, Size)
                  config_value:
                    type: string
                    description: Value for this configuration attribute (e.g., Blue, Large)
            abc_classification:
              description: |-
                ABC inventory classification of this variant. ``null`` when the
                variant has not been classified.
              anyOf:
                - $ref: "#/components/schemas/AbcClassification"
                - type: "null"
          required:
            - sku
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3001
        sku: KNF-PRO-8PC-STL
        sales_price: 299.99
        product_id: 101
        material_id:
        purchase_price: 150.0
        type: product
        internal_barcode: INT-KNF-001
        registered_barcode: "789123456789"
        supplier_item_codes:
          - SUP-KNF-8PC-001
        lead_time: 7
        minimum_order_quantity: 1
        custom_fields:
          - field_name: Warranty Period
            field_value: 5 years
        config_attributes:
          - config_name: Piece Count
            config_value: 8-piece
          - config_name: Handle Material
            config_value: Steel
        abc_classification: A
        created_at: "2024-01-15T08:00:00.000Z"
        updated_at: "2024-08-20T14:45:00.000Z"
        deleted_at:
    ServiceVariant:
      description: Service variant with unique pricing and configuration for external services
      allOf:
        - $ref: "#/components/schemas/UpdatableEntity"
        - type: object
          properties:
            sku:
              type:
                - string
                - "null"
              description: |-
                A unique service code. Katana allows services to be created without
                a SKU; the field is always present in the response but may be null
                for such rows (mirrors Variant.sku).
            sales_price:
              type:
                - number
                - "null"
              description: |
                Default sales price (excluding tax), which is automatically assigned to the service when creating sales
                orders
            default_cost:
              type:
                - number
                - "null"
              description: Default cost which is used to calculate profit
            service_id:
              type: integer
              description: ID of the service this variant belongs to
            type:
              $ref: "#/components/schemas/VariantType"
            custom_fields:
              description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
              anyOf:
                - type: array
                  items:
                    type: object
                    properties:
                      field_name:
                        type: string
                        description: Name of the custom field
                      field_value:
                        type: string
                        description: Value for the custom field
                - type: object
                  propertyNames:
                    pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
                  additionalProperties:
                    type:
                      - string
                      - number
                      - boolean
                      - 'null'
                - type: 'null'
          required:
            - sku
            - service_id
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 4001
        sku: ASSM-001
        sales_price: 75.0
        default_cost: 50.0
        service_id: 401
        type: service
        custom_fields:
          - field_name: Skill Level
            field_value: Expert
          - field_name: Duration
            field_value: 2 hours
        created_at: "2024-01-15T08:00:00.000Z"
        updated_at: "2024-08-20T14:45:00.000Z"
        deleted_at:
    LocationAddress:
      description: Physical address information for manufacturing locations and warehouse facilities
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the location address
        city:
          type: string
          description: City or locality name where the location is situated
        country:
          type: string
          description: Country name or country code for the location
        line_1:
          type: string
          description: Primary address line (street address, building number)
        line_2:
          type: string
          description: Secondary address line (apartment, suite, floor, building)
        state:
          type: string
          description: State, province, or region designation
        zip:
          type: string
          description: Postal code or ZIP code for the location
      required:
        - id
        - city
        - country
        - line_1
        - state
        - zip
      example:
        id: 5001
        city: Austin
        country: US
        line_1: 1500 Industrial Blvd
        line_2: Building A
        state: TX
        zip: "78745"
    Location:
      description: Manufacturing location or warehouse facility where inventory is managed and operations are performed
      allOf:
        - $ref: "#/components/schemas/DeletableEntity"
        - type: object
          properties:
            name:
              type: string
              description: Display name of the location
            legal_name:
              type:
                - string
                - "null"
              description: Legal name of the entity that owns the location
            address_id:
              type:
                - integer
                - "null"
              description: Identifier of the associated address record, or null if no address is on file
            address:
              description: Structured address information for the location, or null if no address is on file
              oneOf:
                - $ref: "#/components/schemas/LocationAddress"
                - type: "null"
            is_primary:
              type: boolean
              description: Whether this location is the primary location for the tenant
            sales_allowed:
              type: boolean
              description: Whether sales orders may be fulfilled from this location
            purchase_allowed:
              type: boolean
              description: Whether purchase orders may be received at this location
            manufacturing_allowed:
              type: boolean
              description: Whether manufacturing orders may be produced at this location
          required:
            - name
      example:
        id: 1
        name: Main location
        legal_name: Amazon
        address_id: 1
        address:
          id: 1
          city: New York
          country: US
          line_1: 10 East 20th Example St
          line_2: ""
          state: New York
          zip: "10000"
        is_primary: true
        sales_allowed: true
        purchase_allowed: true
        manufacturing_allowed: true
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        deleted_at: null
    Inventory:
      type: object
      description: |-
        Represents the current inventory state for a specific product variant at a location.
        Includes stock levels, commitments, expectations, and financial information.
      properties:
        variant_id:
          type: integer
          description: Unique identifier of the product variant
        location_id:
          type: integer
          description: Unique identifier of the location where inventory is stored
        safety_stock_level:
          type: string
          description: |
            The quantity of a product or material which indicates an acceptable stock level for unexpected demand
            without overstocking
        reorder_point:
          type: string
          description: (Deprecated - use safety_stock_level instead) Queries the safety stock level
        average_cost:
          type: string
          description: Average cost per unit of this variant at this location
        value_in_stock:
          type: string
          description: Total monetary value of current stock
        quantity_in_stock:
          type: string
          description: Current physical quantity available at this location
        quantity_committed:
          type: string
          description: Quantity already allocated to orders but not yet shipped
        quantity_expected:
          type: string
          description: Quantity expected to arrive from pending purchase orders
        quantity_missing_or_excess:
          type: string
          description: Difference between expected and actual stock (negative means missing, positive means excess)
        quantity_potential:
          type:
            - string
            - "null"
          description: Total quantity that could be available (in stock + expected)
        variant:
          $ref: "#/components/schemas/Variant"
          description: Product variant details associated with this inventory record
        location:
          $ref: "#/components/schemas/Location"
          description: Location details where this inventory is stored
        archived_at:
          type:
            - string
            - "null"
          format: date-time
          description: Timestamp when this inventory record was archived
        default_storage_bin:
          description: Default storage bin for this variant at this location, when one has been linked via the variant default storage bin endpoints
          anyOf:
            - $ref: "#/components/schemas/VariantDefaultStorageBinLinkResponse"
            - type: "null"
      required:
        - variant_id
        - location_id
        - safety_stock_level
        - reorder_point
        - average_cost
        - value_in_stock
        - quantity_in_stock
        - quantity_committed
        - quantity_expected
        - quantity_missing_or_excess
        - quantity_potential
      example:
        variant_id: 3001
        location_id: 1
        safety_stock_level: "25.0"
        reorder_point: "25.0"
        average_cost: "15.50"
        value_in_stock: "2325.00"
        quantity_in_stock: "150.0"
        quantity_committed: "25.0"
        quantity_expected: "50.0"
        quantity_missing_or_excess: "0.0"
        quantity_potential: "175.0"
    InventoryListResponse:
      type: object
      description: List of current inventory levels showing stock quantities for all variants across all locations
      properties:
        data:
          type: array
          description: Array of inventory records with current stock levels and location details
          items:
            $ref: "#/components/schemas/Inventory"
      required:
        - data
      example:
        data:
          - id: 1001
            variant_id: 3001
            location_id: 1
            quantity_on_hand: 150.0
            quantity_allocated: 25.0
            quantity_available: 125.0
            safety_stock_level: "25.0"
            reorder_point: "25.0"
            average_cost: "25.5"
            value_in_stock: "3825.0"
            quantity_in_stock: "150.0"
            quantity_committed: "25.0"
            quantity_expected: "50.0"
            quantity_missing_or_excess: "0.0"
            quantity_potential: "175.0"
            total_value: 3825.0
            created_at: "2024-01-15T08:00:00.000Z"
            updated_at: "2024-01-15T12:30:00.000Z"
          - id: 1002
            variant_id: 3002
            location_id: 1
            quantity_on_hand: 75.0
            quantity_allocated: 10.0
            quantity_available: 65.0
            safety_stock_level: "30.0"
            reorder_point: "30.0"
            average_cost: "45.0"
            value_in_stock: "3375.0"
            quantity_in_stock: "75.0"
            quantity_committed: "10.0"
            quantity_expected: "25.0"
            quantity_missing_or_excess: "0.0"
            quantity_potential: "90.0"
            total_value: 3375.0
            created_at: "2024-01-15T08:00:00.000Z"
            updated_at: "2024-01-15T14:15:00.000Z"
    InventoryReorderPoint:
      description: |
        Configuration that defines the minimum inventory level that triggers automatic reordering for a specific variant
        at a location
      type: object
      required:
        - location_id
        - variant_id
        - value
      properties:
        location_id:
          type: integer
          maximum: 2147483647
          description: The location where this reorder point applies
        variant_id:
          type: integer
          maximum: 2147483647
          description: The product variant this reorder point is configured for
        value:
          type: string
          description: The minimum quantity that triggers reordering, returned as a fixed-precision decimal string
    InventoryReorderPointResponse:
      description: Complete inventory reorder point configuration including metadata and creation/update timestamps
      allOf:
        - $ref: "#/components/schemas/InventoryReorderPoint"
        - $ref: "#/components/schemas/DeletableEntity"
    InventorySafetyStockLevel:
      type: object
      description: Safety stock level configuration to maintain minimum inventory buffers and prevent stockouts
      required:
        - location_id
        - variant_id
        - value
      properties:
        location_id:
          type: integer
          maximum: 2147483647
          description: ID of the location where the safety stock level applies
        variant_id:
          type: integer
          maximum: 2147483647
          description: ID of the variant for which the safety stock level is set
        value:
          type: string
          description: Minimum quantity to maintain as safety stock buffer, returned as a fixed-precision decimal string
      example:
        location_id: 1
        variant_id: 3001
        value: "25.0"
    InventorySignalLeadTimeSource:
      type: string
      description: Which source supplied the lead time used in a replenishment calculation
      enum:
        - sku
        - system_po
        - system_mo
        - fallback

    InventorySignalStockRisk:
      type: integer
      enum: [0, 1, 2, 3]
      description: Replenishment urgency from low (0) to stockout (3).
    InventorySignal:
      description: Replenishment signal for one variant, summed across all locations, using the selected
        demand window.
      type: object
      properties:
        avg_daily_demand:
          description: "Quantity consumed over the last demand_window days divided by demand_window. Demand
            counts\n        sales, manufacturing ingredient consumption, and outsourced purchase order recipe
            rows. If the variant's\n        first stock movement is less than demand_window days old, the
            divisor is the days since that movement\n        instead. Recalculated nightly at 07:00 UTC, so
            it can be up to 24 hours old. The average is flat: no\n        seasonality and no trend."
          type: string
        committed:
          description: "Quantity already claimed by open sales and manufacturing orders, so it cannot cover
            the demand\n        ahead. stock_risk and safety_stock_breach_at are worked out from in_stock
            less committed.\n        days_of_stock_left is not."
          type: string
        days_of_stock_left:
          description: "Whole days until stock runs out at the current demand rate (= floor(in_stock /\n \
            \       avg_daily_demand)). Uses in_stock alone: it ignores committed stock and incoming supply,
            so it can disagree\n        with stock_risk. Null while the variant's demand has not yet been
            calculated."
          type:
            - integer
            - 'null'
        demand_calculated_at:
          description: "When avg_daily_demand was last calculated. It dates the average, not the row. Every
            other field\n        updates within seconds of a change to in_stock, safety_stock or incoming
            supply. A lead time change is not\n        applied within seconds."
          format: date-time
          type: string
        demand_window:
          description: "The number of days avg_daily_demand is calculated over: 7, 30, 60 or 90. Matches the\n\
            \        demand_window query parameter, which defaults to 30."
          enum:
            - 7
            - 30
            - 60
            - 90
          type: integer
        expected_before_safety_stock_breach:
          description: "The incoming quantity that stock_risk counted. Open orders are taken in expected-date
            order. An\n        order counts only if it lands on or before the projected breach day, and each
            counted order pushes that day\n        further out. An overdue order counts as landing today.
            0 means nothing incoming lands in time. Null where\n        incoming supply could not change the
            risk. Neither value means nothing is incoming."
          type:
            - string
            - 'null'
        in_stock:
          description: Quantity on hand, summed across all locations.
          type: string
        lead_time_source:
          $ref: '#/components/schemas/InventorySignalLeadTimeSource'
          description: "Which source supplied lead_time_used: sku (variant lead time), system_po (factory
            default\n        purchase lead time), system_mo (factory default manufacturing lead time) or fallback
            (14 days)."
        lead_time_used:
          description: "Lead time in days used in the calculations. The variant lead time. Where that is not
            set, the\n        factory default purchase lead time, then the factory default manufacturing lead
            time, then 14 days."
          type: integer
        reorder_point:
          description: "The calculated stock level under which the shortfall lands inside the lead time\n\
            \        (= avg_daily_demand * lead_time_used + safety_stock). Null while the variant's demand
            has not yet been\n        calculated. This is not the reorder_point on the inventory object, which
            is the user-set safety stock."
          type:
            - string
            - 'null'
        safety_stock:
          description: The safety stock level set for the variant.
          type: string
        safety_stock_breach_at:
          description: "The projected date on which in_stock less committed, counting incoming supply, falls
            below\n        safety stock. Set on high (1) and critical (2) rows only. Null everywhere else."
          format: date-time
          type:
            - string
            - 'null'
        stock_risk:
          description: "How urgent replenishment is, as an integer from 0 to 3. Worked out from in_stock less\n\
            \        committed, plus incoming supply that lands in time, over a horizon of lead_time_used
            + 7 days.\n        0 = low: stock stays at or above safety stock through the horizon.\n      \
            \  1 = high: stock falls below safety stock inside the horizon, but after the lead time.\n   \
            \     2 = critical: stock falls below safety stock inside the lead time, so an order placed now
            arrives late.\n        3 = stockout: in_stock is 0 or less.\n        Stockout is checked first
            and the first match wins. Values are in ascending severity, so a value of 1 or\n        more means
            the variant needs attention. Null while the variant's demand has not yet been calculated."
          anyOf:
            - $ref: '#/components/schemas/InventorySignalStockRisk'
            - type: 'null'
        variant_id:
          description: "ID of the product or material variant the signal describes. Signals are account-wide:
            one row\n        per variant, summed across all locations."
          type: integer
      example:
        variant_id: 1
        reorder_point: "49.00000000000000000000"
        days_of_stock_left: 12
        stock_risk: 1
        in_stock: "42.00000000000000000000"
        committed: "0.00000000000000000000"
        safety_stock_breach_at: "2026-08-24T00:00:00.000Z"
        expected_before_safety_stock_breach: "30.00000000000000000000"
        safety_stock: "0.00000000000000000000"
        lead_time_used: 14
        lead_time_source: sku
        demand_calculated_at: "2026-08-12T07:00:00.000Z"

        avg_daily_demand: '3.50000000000000000000'
        demand_window: 30
    InventorySignalListResponse:
      description: |
        Response containing a list of inventory replenishment signals with pagination support.
      type: object
      properties:
        data:
          type: array
          description: Array of per-variant replenishment signals
          items:
            $ref: "#/components/schemas/InventorySignal"
      example:
        data:
          - variant_id: 1
            reorder_point: "49.00000000000000000000"
            days_of_stock_left: 12
            stock_risk: 1
            in_stock: "42.00000000000000000000"
            committed: "0.00000000000000000000"
            safety_stock_breach_at: "2026-08-24T00:00:00.000Z"
            expected_before_safety_stock_breach: "30.00000000000000000000"
            safety_stock: "0.00000000000000000000"
            lead_time_used: 14
            lead_time_source: sku
            demand_calculated_at: "2026-08-12T07:00:00.000Z"

            avg_daily_demand: "3.50000000000000000000"
            demand_window: 30
    InventorySafetyStockLevelResponse:
      description: Complete safety stock level configuration with metadata including timestamps and deletion status
      allOf:
        - $ref: "#/components/schemas/InventorySafetyStockLevel"
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 1001
        variant_id: 1
        location_id: 1
        value: "10"
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        deleted_at: null
    CreateManufacturingOrderRequest:
      description: |
        Request payload for creating a new manufacturing order to initiate production of products or components.
      type: object
      required:
        - variant_id
        - planned_quantity
        - location_id
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        status:
          type: string
          enum:
            - NOT_STARTED
          description: |
            Initial production status. ``NOT_STARTED`` is the only value
            accepted on create; transition to other statuses via
            ``PATCH /manufacturing_orders/{id}``.
        order_no:
          type: string
          description: |
            Custom manufacturing order number for tracking and reference.
            Optional — Katana server-generates a default (``MO-<n>``) when
            omitted.
        variant_id:
          type: integer
          description: ID of the product variant to manufacture
        location_id:
          type: integer
          description: ID of the factory location where production will take place
        planned_quantity:
          type: number
          description: Quantity of the variant to produce
        actual_quantity:
          type: number
          description: Actual quantity produced
        order_created_date:
          type: string
          format: date-time
          description: Date and time when the manufacturing order should be created (defaults to current time)
        production_deadline_date:
          type: string
          format: date-time
          description: Target deadline for completing production
        additional_info:
          type: string
          description: Optional notes or additional information about the order
        batch_transactions:
          type: array
          description: Batch transactions for produced items
          items:
            $ref: "#/components/schemas/BatchTransaction"
        traceability:
          type: array
          description: >-
            Batch / serial allocations for the quantity this manufacturing order will produce.
          items:
            $ref: "#/components/schemas/ManufacturingOrderTraceabilityRequest"

      example:
        variant_id: 2101
        planned_quantity: 50
        location_id: 1
        order_no: MO-2024-001
        order_created_date: "2024-01-15T08:00:00Z"
        production_deadline_date: "2024-01-25T17:00:00Z"
        additional_info: Priority order for new product launch
    ManufacturingOrder:
      description:
        Represents a manufacturing order for producing products, tracking production status, costs, and timeline
        from creation to completion.
      allOf:
        - type: object
          properties:
            id:
              type: integer
            status:
              description: Current production status of the manufacturing order
              $ref: "#/components/schemas/ManufacturingOrderStatus"
            order_no:
              type: string
              description: Unique manufacturing order number for tracking and reference
            variant_id:
              type: integer
              description: ID of the product variant being manufactured
            planned_quantity:
              type: number
              description: Originally planned quantity to produce
            actual_quantity:
              type:
                - number
                - "null"
              description: Actual quantity produced, null if production not completed
            completed_quantity:
              type:
                - number
                - "null"
              description: Total quantity completed so far (including partial completions)
            remaining_quantity:
              type:
                - number
                - "null"
              description: Remaining quantity to produce (planned - completed)
            includes_partial_completions:
              type: boolean
              description: Whether this order has been partially completed
            batch_transactions:
              type: array
              description: Batch transactions for produced items, typically one transaction per manufacturing order
              items:
                $ref: "#/components/schemas/BatchTransaction"
            location_id:
              type: integer
              description: ID of the factory location where production takes place
            order_created_date:
              type: string
              format: date-time
              description: Date and time when the manufacturing order was created
            production_deadline_date:
              type:
                - string
                - "null"
              format: date-time
              description: Target deadline for completing production (null when none is set)
            done_date:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp when the manufacturing order was completed
            additional_info:
              type: string
              description: Optional notes or additional information about the order
            is_linked_to_sales_order:
              type: boolean
              description: Whether this manufacturing order is linked to a sales order
            ingredient_availability:
              description: Status of material ingredient availability for production
              anyOf:
                - $ref: "#/components/schemas/IngredientAvailability"
                - type: "null"
            total_cost:
              type: number
              description: Total cost of the manufacturing order including all materials and operations
            total_actual_time:
              type: number
              description: Total actual time spent on production operations
            total_planned_time:
              type: number
              description: Total planned time for all production operations
            sales_order_id:
              type:
                - integer
                - "null"
              description: ID of the linked sales order, if applicable
            sales_order_row_id:
              type:
                - integer
                - "null"
              description: ID of the specific sales order row, if applicable
            sales_order_delivery_deadline:
              type:
                - string
                - "null"
              format: date-time
              description: Delivery deadline from the linked sales order
            material_cost:
              type:
                - number
                - "null"
              description: Total cost of materials used in production
            subassemblies_cost:
              type:
                - number
                - "null"
              description: Total cost of subassemblies used in production
            operations_cost:
              type:
                - number
                - "null"
              description: Total cost of production operations and labor
            serial_numbers:
              type: array
              description: Serial numbers assigned to produced items
              items:
                $ref: "#/components/schemas/SerialNumber"
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3001
        status: IN_PROGRESS
        order_no: MO-2024-001
        variant_id: 2101
        planned_quantity: 50
        actual_quantity: 35
        location_id: 1
        order_created_date: "2024-01-15T08:00:00Z"
        production_deadline_date: "2024-01-25T17:00:00Z"
        additional_info: Priority order for new product launch
        is_linked_to_sales_order: true
        ingredient_availability: IN_STOCK
        total_cost: 12500.0
        total_actual_time: 140.5
        total_planned_time: 200.0
        sales_order_id: 2001
        sales_order_row_id: 2501
        sales_order_delivery_deadline: "2024-01-30T12:00:00Z"
        material_cost: 8750.0
        subassemblies_cost: 2250.0
        operations_cost: 1500.0
        serial_numbers:
          - id: 1
            transaction_id: "MO-2024-001-001"
            serial_number: PKS-001-240115
            resource_type: ManufacturingOrder
            resource_id: 3001
            transaction_date: "2024-01-15T08:00:00Z"
            quantity_change: 1
          - id: 2
            transaction_id: "MO-2024-001-002"
            serial_number: PKS-002-240115
            resource_type: ManufacturingOrder
            resource_id: 3001
            transaction_date: "2024-01-15T08:00:00Z"
            quantity_change: 1
          - id: 3
            transaction_id: "MO-2024-001-003"
            serial_number: PKS-003-240115
            resource_type: ManufacturingOrder
            resource_id: 3001
            transaction_date: "2024-01-15T08:00:00Z"
            quantity_change: 1
        created_at: "2024-01-15T08:00:00Z"
        updated_at: "2024-01-20T14:30:00Z"
        deleted_at: null
    UpdateManufacturingOrderRequest:
      description: Request payload for updating an existing manufacturing order's properties and production parameters.
      type: object
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        status:
          description: Updated production status of the manufacturing order
          $ref: "#/components/schemas/ManufacturingOrderStatus"
        order_no:
          type: string
          description: Updated manufacturing order number for tracking and reference
        variant_id:
          type: integer
          description: Updated ID of the product variant being manufactured
        location_id:
          type: integer
          description: Updated ID of the factory location where production takes place
        planned_quantity:
          type: number
          description: Updated quantity of the variant to produce
        actual_quantity:
          type: number
          description: Updated actual quantity produced
        order_created_date:
          type: string
          format: date-time
          description: Updated date and time when the manufacturing order was created
        production_deadline_date:
          type: string
          format: date-time
          description: Updated target deadline for completing production
        done_date:
          type: string
          format: date-time
          description: Timestamp when the manufacturing order was completed
        additional_info:
          type: string
          description: Updated notes or additional information about the order
        batch_transactions:
          type: array
          description: Batch transactions for produced items
          items:
            $ref: "#/components/schemas/BatchTransaction"
        traceability:
          type: array
          description: >-
            Updated batch / serial allocations for the produced quantity.
          items:
            $ref: "#/components/schemas/ManufacturingOrderTraceabilityRequest"

      example:
        planned_quantity: 75
        additional_info: Increased quantity due to additional customer demand
        production_deadline_date: "2024-01-30T17:00:00Z"
    CreateManufacturingOrderProductionRequest:
      description:
        Request payload for creating a production run within a manufacturing order, recording actual production
        activities and material consumption.
      type: object
      required:
        - manufacturing_order_id
        - completed_quantity
      properties:
        manufacturing_order_id:
          type: integer
          description: ID of the manufacturing order this production run belongs to
        completed_quantity:
          type: number
          description: Quantity produced in this production run
        completed_date:
          type: string
          format: date-time
          description: Date and time when the production was completed
        is_final:
          type: boolean
          description: Whether this is the final production run that completes the manufacturing order
        batch_transaction:
          description: Batch allocation for this production run
          $ref: "#/components/schemas/ManufacturingOrderProductionBatchTransaction"
        ingredients:
          type: array
          description: Ingredients consumed during this production run
          items:
            $ref: "#/components/schemas/ManufacturingOrderProductionIngredient"
        operations:
          type: array
          description: Operations performed during this production run
          items:
            $ref: "#/components/schemas/ManufacturingOrderOperationRow"
        serial_numbers:
          type: array
          description: |
            Pre-existing SerialNumber IDs (integers) to assign to the units
            produced in this production run. Katana silently drops IDs that
            do not exist. On the verified test configuration, omitting serial
            inputs for a serial-tracked product generated identities during
            production; `POST /serial_numbers` did not mint new strings.
          items:
            type: integer
        traceability:
          type: array
          description: >-
            Batch / serial allocations for the quantity completed in this production run.
          items:
            $ref: "#/components/schemas/ManufacturingOrderTraceabilityRequest"
      example:
        manufacturing_order_id: 3001
        completed_quantity: 25
        completed_date: "2024-01-20T14:30:00Z"
        is_final: false
        ingredients:
          - id: 4001
            location_id: 1
            variant_id: 3101
            manufacturing_order_id: 3001
            manufacturing_order_recipe_row_id: 3201
            production_id: 3501
            quantity: 50.0
            production_date: "2024-01-20T14:30:00Z"
            cost: 125.0
        operations:
          - id: 3801
            manufacturing_order_id: 3001
            operation_id: 401
            time: 15.0
    UpdateManufacturingOrderProductionRequest:
      description:
        Request payload for updating an existing production run within a manufacturing order.
      type: object
      properties:
        production_date:
          type: string
          format: date-time
          description: Updated date and time when the production was completed
        traceability:
          type: array
          description: >-
            Updated batch / serial allocations for the completed quantity.
          items:
            $ref: "#/components/schemas/ManufacturingOrderTraceabilityRequest"
      example:
        production_date: "2024-01-21T16:00:00Z"
    ManufacturingOrderProduction:
      description:
        Represents a completed production run within a manufacturing order, tracking actual quantities produced
        and resources consumed during manufacturing.
      allOf:
        - type: object
          properties:
            id:
              type: integer
            manufacturing_order_id:
              type: integer
              description: ID of the manufacturing order this production run belongs to
            factory_id:
              type: integer
              description: ID of the factory where this production run was performed
            quantity:
              type: number
              description: Actual quantity produced in this production run
            production_date:
              type: string
              format: date-time
              description: Date and time when the production was completed
            ingredients:
              type: array
              description: Ingredients consumed during this production run
              items:
                $ref: "#/components/schemas/ManufacturingOrderProductionIngredient"
            operations:
              type: array
              description: Operations performed during this production run
              items:
                $ref: "#/components/schemas/ManufacturingOrderOperationProduction"
            serial_numbers:
              type: array
              description: Serial numbers assigned during this production run
              items:
                $ref: "#/components/schemas/SerialNumber"
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3501
        manufacturing_order_id: 3001
        quantity: 25
        production_date: "2024-01-20T14:30:00Z"
        ingredients:
          - id: 4001
            location_id: 1
            variant_id: 3101
            manufacturing_order_id: 3001
            manufacturing_order_recipe_row_id: 3201
            production_id: 3501
            quantity: 50.0
            production_date: "2024-01-20T14:30:00Z"
            cost: 125.0
            created_at: "2024-01-20T14:30:00Z"
            updated_at: "2024-01-20T14:30:00Z"
            deleted_at: null
        operations:
          - id: 3801
            manufacturing_order_id: 3001
            operation_id: 401
            operation_name: Cut Steel Sheets
            time: 15.0
            cost: 45.0
            created_at: "2024-01-20T14:30:00Z"
            updated_at: "2024-01-20T14:30:00Z"
            deleted_at: null
        serial_numbers:
          - id: 1
            transaction_id: "PROD-3501-001"
            serial_number: PKS-001-240120
            resource_type: Production
            resource_id: 3501
            transaction_date: "2024-01-20T14:30:00Z"
            quantity_change: 1
          - id: 2
            transaction_id: "PROD-3501-002"
            serial_number: PKS-002-240120
            resource_type: Production
            resource_id: 3501
            transaction_date: "2024-01-20T14:30:00Z"
            quantity_change: 1
        created_at: "2024-01-20T14:30:00Z"
        updated_at: "2024-01-20T14:30:00Z"
        deleted_at: null
    ManufacturingOrderProductionListResponse:
      description:
        Response containing a list of production runs for manufacturing orders with pagination support for tracking
        production history.
      type: object
      properties:
        data:
          type: array
          description: Array of production runs from manufacturing orders
          items:
            $ref: "#/components/schemas/ManufacturingOrderProduction"
      example:
        data:
          - id: 3501
            manufacturing_order_id: 3001
            quantity: 25
            production_date: "2024-01-20T14:30:00Z"
            ingredients:
              - id: 4001
                location_id: 1
                variant_id: 3101
                manufacturing_order_id: 3001
                manufacturing_order_recipe_row_id: 3201
                production_id: 3501
                quantity: 50.0
                production_date: "2024-01-20T14:30:00Z"
                cost: 125.0
                created_at: "2024-01-20T14:30:00Z"
                updated_at: "2024-01-20T14:30:00Z"
                deleted_at: null
            operations:
              - id: 3801
                manufacturing_order_id: 3001
                operation_id: 401
                operation_name: Cut Steel Sheets
                time: 15.0
                cost: 45.0
                created_at: "2024-01-20T14:30:00Z"
                updated_at: "2024-01-20T14:30:00Z"
                deleted_at: null
            serial_numbers:
              - id: 1
                transaction_id: "PROD-3501-001"
                serial_number: PKS-001-240120
                resource_type: Production
                resource_id: 3501
                transaction_date: "2024-01-20T14:30:00Z"
                quantity_change: 1
              - id: 2
                transaction_id: "PROD-3501-002"
                serial_number: PKS-002-240120
                resource_type: Production
                resource_id: 3501
                transaction_date: "2024-01-20T14:30:00Z"
                quantity_change: 1
            created_at: "2024-01-20T14:30:00Z"
            updated_at: "2024-01-20T14:30:00Z"
            deleted_at: null
    ManufacturingOrderProductionIngredient:
      description: |
        Record of actual ingredient consumption during manufacturing order production, tracking quantities and costs
      allOf:
        - type: object
          properties:
            id:
              type: integer
            location_id:
              type: integer
            variant_id:
              type: integer
            manufacturing_order_id:
              type: integer
            manufacturing_order_recipe_row_id:
              type: integer
            production_id:
              type: integer
            quantity:
              type: number
            production_date:
              type: string
              format: date-time
            cost:
              type: number
        - $ref: "#/components/schemas/DeletableEntity"
    UpdateManufacturingOrderProductionIngredientRequest:
      description: Request payload for updating ingredient consumption data in a manufacturing order production batch
      type: object
      properties:
        batch_transactions:
          type: array
          description: >-
            Batch transactions for ingredient consumption. Each allocation needs
            a positive quantity: the live API rejects its omission with
            "Traceability entries without a serial number must provide a positive
            quantity", despite the upstream DTO marking quantity optional (#1053).
          items:
            $ref: "#/components/schemas/BatchTransaction"
        traceability:
          type: array
          description: >-
            Updated batch / bin allocations for the ingredient quantity consumed.
          items:
            $ref: "#/components/schemas/ManufacturingOrderIngredientTraceabilityRequest"
      example:
        batch_transactions:
          - batch_id: 123
            quantity: 3.2
    ManufacturingOrderOperationRow:
      description:
        Represents an individual operation step within a manufacturing order, tracking production operations, operator
        assignments, time, and costs.
      allOf:
        - type: object
          required:
            - id
          properties:
            id:
              type: integer
            status:
              description: Current status of the operation
              $ref: "#/components/schemas/ManufacturingOperationStatus"
            type:
              description: |
                Type of operation defining how time and cost are calculated.
                Same enum used on the request side
                (``Create/UpdateManufacturingOrderOperationRowRequest``).
              $ref: "#/components/schemas/ManufacturingOperationType"
            rank:
              type: number
              description: Order/sequence of this operation within the manufacturing process
            manufacturing_order_id:
              type: integer
              description: ID of the manufacturing order this operation belongs to
            operation_id:
              type: integer
              description: ID of the operation template or definition
            operation_name:
              type: string
              description: Name of the operation being performed
            resource_id:
              type:
                - integer
                - "null"
              description: ID of the resource (machine/workstation) used for this operation
            resource_name:
              type:
                - string
                - "null"
              description: Name of the resource (machine/workstation) used
            assigned_operators:
              type: array
              description: Operators assigned to perform this operation
              items:
                $ref: "#/components/schemas/AssignedOperator"
            completed_by_operators:
              type: array
              description: Operators who have completed work on this operation
              items:
                $ref: "#/components/schemas/AssignedOperator"
            active_operator_id:
              type:
                - number
                - "null"
              description: ID of the currently active operator working on this operation
            planned_time_per_unit:
              type: string
              deprecated: true
              description: Planned time per unit for this operation (deprecated — use ``planned_time_parameter`` instead)
            planned_time_parameter:
              type: string
              description: Parameter for calculating planned time
            total_actual_time:
              type:
                - string
                - "null"
              description: Actual time as a decimal string, or null before completion
            planned_cost_per_unit:
              type: string
              description: Planned cost per unit for this operation
            total_actual_cost:
              type:
                - string
                - "null"
              description: Actual cost as a decimal string, or null before completion
            total_consumed_time:
              type: number
              description: Total time consumed so far for this operation
            total_remaining_time:
              type: number
              description: Remaining time estimated for this operation
            cost_per_hour:
              type: string
              deprecated: true
              description: Hourly cost rate for this operation, returned as a fixed-precision decimal string (deprecated — use ``cost_parameter`` instead)
            cost_parameter:
              type: string
              description: Parameter for calculating operation costs, returned as a fixed-precision decimal string
            group_boundary:
              type:
                - number
                - "null"
              description: Group boundary setting for operation grouping
            is_status_actionable:
              type: boolean
              description: Whether the current status allows for operator actions
            completed_at:
              type:
                - string
                - "null"
              format: date-time
              description: Date and time when the operation was completed, null if not completed
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3801
        status: IN_PROGRESS
        # ``type`` is illustrative — any valid ``ManufacturingOperationType``
        # value works for an example. The original fixture used
        # ``Production``, which doesn't match the local enum
        # (``process | setup | perUnit | fixed``). #583 tracks the open
        # question of whether the enum or the fixture is wrong against
        # the live API.
        type: process
        rank: 1
        manufacturing_order_id: 3001
        operation_id: 401
        operation_name: Cut Steel Sheets
        resource_id: 501
        resource_name: Laser Cutting Machine
        assigned_operators:
          - id: 101
            operator_id: 101
            name: John Smith
            working_area: Production Floor A
            resource_id: 501
        completed_by_operators: []
        active_operator_id: 101
        planned_time_per_unit: "15.0"
        planned_time_parameter: "1.0"
        total_actual_time: "12.5"
        planned_cost_per_unit: "45.0"
        total_actual_cost: "37.5"
        cost_per_hour: "180.0"
        cost_parameter: "1.0"
        group_boundary: 0
        is_status_actionable: true
        completed_at: null
        created_at: "2024-01-15T08:00:00Z"
        updated_at: "2024-01-20T14:30:00Z"
        deleted_at: null
    CreateManufacturingOrderOperationRowRequest:
      description:
        Request payload for creating a new manufacturing order operation row to track production operation time
        and operator assignments
      type: object
      required:
        - manufacturing_order_id
        - status
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        manufacturing_order_id:
          type: integer
          description: ID of the manufacturing order this operation belongs to
        operation_id:
          type: integer
          description: ID of the operation being performed
        type:
          description: Type of operation defining how time and cost are calculated
          $ref: "#/components/schemas/ManufacturingOperationType"
        operation_name:
          type: string
          description: Name of the operation
        resource_id:
          type: integer
          description: ID of the resource (machine/workstation) performing the operation
        resource_name:
          type: string
          description: Name of the resource performing the operation
        planned_time_parameter:
          type: number
          description: Parameter for calculating planned time
        planned_time_per_unit:
          type: number
          deprecated: true
          description: Planned time per unit of output (deprecated — use ``planned_time_parameter`` instead)
        cost_parameter:
          type: number
          description: Parameter for calculating operation cost
        cost_per_hour:
          type: number
          deprecated: true
          description: Hourly cost rate for this operation (deprecated — use ``cost_parameter`` instead)
        status:
          type: string
          enum:
            - NOT_STARTED
          description: |
            Initial status of the operation row. Live API only accepts
            NOT_STARTED on create; transitions go through PATCH.
        assigned_operators:
          type: array
          description: Operators assigned to perform this operation
          items:
            $ref: "#/components/schemas/Operator"

      example:
        manufacturing_order_id: 1001
        operation_id: 201
        type: process
        operation_name: Assembly
        resource_id: 501
        resource_name: Workstation A
        planned_time_parameter: 1.0
        planned_time_per_unit: 15.0
        cost_parameter: 1.0
        cost_per_hour: 50.0
        status: NOT_STARTED
    UpdateManufacturingOrderOperationRowRequest:
      description: Request payload for updating a manufacturing order operation row with actual completion data
      type: object
      additionalProperties: false
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        operation_id:
          type: integer
          description: ID of the operation being performed
        type:
          description: Type of operation defining how time and cost are calculated
          $ref: "#/components/schemas/ManufacturingOperationType"
        operation_name:
          type: string
          description: Name of the operation
        resource_id:
          type: integer
          description: ID of the resource (machine/workstation) performing the operation
        resource_name:
          type: string
          description: Name of the resource performing the operation
        planned_time_parameter:
          type: number
          description: Parameter for calculating planned time
        planned_time_per_unit:
          type: number
          deprecated: true
          description: Planned time per unit of output (deprecated — use ``planned_time_parameter`` instead)
        total_actual_time:
          type: number
          description: Actual time taken in minutes for this operation
        cost_parameter:
          type: number
          description: Parameter for calculating operation cost
        cost_per_hour:
          type: number
          deprecated: true
          description: Hourly cost rate for this operation (deprecated — use ``cost_parameter`` instead)
        status:
          description: Current status of the operation
          $ref: "#/components/schemas/ManufacturingOperationStatus"
        assigned_operators:
          type: array
          description: Operators assigned to perform this operation
          items:
            $ref: "#/components/schemas/Operator"
        completed_by_operators:
          type: array
          description: List of operators who completed this operation
          items:
            $ref: "#/components/schemas/Operator"

      example:
        operation_name: Assembly
        total_actual_time: 52.3
        status: COMPLETED
        completed_by_operators:
          - id: 101
            operator_name: John Smith
            created_at: "2024-01-15T08:00:00.000Z"
            updated_at: "2024-01-15T08:00:00.000Z"
            deleted_at: null
    ManufacturingOrderOperationRowResponse:
      description: Complete manufacturing order operation details including all metadata and operational parameters
      type: object
      allOf:
        - $ref: "#/components/schemas/ManufacturingOrderOperationRow"
    ManufacturingOrderOperationProduction:
      description: Record of actual work performed on a specific operation during manufacturing order production
      allOf:
        - type: object
          properties:
            id:
              type: integer
            location_id:
              type: integer
            manufacturing_order_id:
              type: integer
            manufacturing_order_operation_id:
              type: integer
            production_id:
              type: integer
            time:
              type: number
            production_date:
              type: string
              format: date-time
            cost:
              type: number
        - $ref: "#/components/schemas/DeletableEntity"
    CreateManufacturingOrderRecipeRowRequest:
      description:
        Request payload for creating a new manufacturing order recipe row to track ingredient requirements and
        consumption
      type: object
      required:
        - manufacturing_order_id
        - variant_id
        - planned_quantity_per_unit
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        manufacturing_order_id:
          type: integer
          description: ID of the manufacturing order this ingredient belongs to
        variant_id:
          type: integer
          description: ID of the ingredient variant being consumed
        notes:
          type: string
          description: Additional notes about this ingredient usage
        planned_quantity_per_unit:
          type: number
          description: Planned quantity of ingredient per unit of finished product
        total_actual_quantity:
          type: number
          description: Total actual quantity of ingredient consumed
        batch_transactions:
          type: array
          description: Batch tracking transactions for this ingredient
          items:
            type: object
            required:
              - batch_id
              - quantity
            properties:
              batch_id:
                type: integer
                description: ID of the ingredient batch being consumed
              quantity:
                type: number
                description: Quantity consumed from this batch
        traceability:
          type: array
          description: >-
            Batch / bin allocations for the ingredient quantity consumed by this recipe row.
          items:
            $ref: "#/components/schemas/ManufacturingOrderIngredientTraceabilityRequest"

      example:
        manufacturing_order_id: 1001
        variant_id: 2002
        notes: Use fresh ingredients from cold storage
        planned_quantity_per_unit: 0.25
        total_actual_quantity: 5.0
        batch_transactions:
          - batch_id: 301
            quantity: 3.0
          - batch_id: 302
            quantity: 2.0
    UpdateManufacturingOrderRecipeRowRequest:
      description:
        Request payload for updating a manufacturing order recipe row with actual consumption data and revised
        requirements
      type: object
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        variant_id:
          type: integer
          description: Updated ID of the ingredient variant being consumed
        notes:
          type: string
          description: Additional notes about this ingredient usage
        planned_quantity_per_unit:
          type: number
          description: Revised planned quantity of ingredient per unit of finished product
        total_actual_quantity:
          type: number
          description: Updated total actual quantity of ingredient consumed
        batch_transactions:
          type: array
          description: Updated batch tracking transactions for this ingredient
          items:
            type: object
            properties:
              batch_id:
                type: integer
                description: ID of the ingredient batch being consumed
              quantity:
                type: number
                description: Quantity consumed from this batch
        traceability:
          type: array
          description: >-
            Updated batch / bin allocations for the consumed ingredient quantity.
          items:
            $ref: "#/components/schemas/ManufacturingOrderIngredientTraceabilityRequest"

      example:
        variant_id: 2002
        notes: Used organic ingredients as requested by customer
        planned_quantity_per_unit: 0.3
        total_actual_quantity: 6.2
        batch_transactions:
          - batch_id: 301
            quantity: 3.5
          - batch_id: 302
            quantity: 2.7
    ManufacturingOrderRecipeRow:
      description:
        Represents an ingredient or component required for a manufacturing order, tracking planned and actual quantities
        used in production.
      allOf:
        - type: object
          properties:
            id:
              type: integer
            manufacturing_order_id:
              type: integer
              description: ID of the manufacturing order this recipe row belongs to
            variant_id:
              type: integer
              description: ID of the ingredient variant required for production
            notes:
              type:
                - string
                - "null"
              description: Additional notes about this ingredient or special handling instructions
            planned_quantity_per_unit:
              type: string
              description: Planned quantity of this ingredient needed per unit produced
            total_actual_quantity:
              type:
                - string
                - "null"
              description: |
                Total actual quantity of this ingredient consumed. Returned as a fixed-precision
                decimal string (e.g. ``"125.0000000000"``).
            ingredient_availability:
              description: Current availability status of this ingredient
              $ref: "#/components/schemas/IngredientAvailability"
            ingredient_expected_date:
              type:
                - string
                - "null"
              format: date-time
              description: Expected date when ingredient will be available if currently unavailable
            batch_transactions:
              type: array
              description: Batch tracking transactions for this ingredient consumption
              items:
                type: object
                properties:
                  batch_id:
                    type: integer
                    description: ID of the batch being consumed
                  quantity:
                    type: number
                    description: Quantity consumed from this batch
            cost:
              type:
                - string
                - "null"
              description: |
                Total cost of this ingredient for the manufacturing order. Returned as a fixed-precision
                decimal string (e.g. ``"437.5000000000"``).
            total_consumed_quantity:
              type: number
              description: Total quantity consumed so far from this ingredient
            total_remaining_quantity:
              type: number
              description: Remaining quantity needed from this ingredient
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 4001
        manufacturing_order_id: 3001
        variant_id: 3201
        notes: Use only grade 304 material
        planned_quantity_per_unit: "2.5000000000"
        total_actual_quantity: "125.0000000000"
        ingredient_availability: IN_STOCK
        batch_transactions:
          - batch_id: 1201
            quantity: 125.0
        cost: "437.5000000000"
        created_at: "2024-01-15T08:00:00Z"
        updated_at: "2024-01-20T14:30:00Z"
        deleted_at: null
    ManufacturingOrderRecipeRowListResponse:
      description: |
        Response containing a list of recipe rows (ingredients) for manufacturing orders with pagination support.
      type: object
      properties:
        data:
          type: array
          description: Array of recipe rows showing ingredients required for manufacturing orders
          items:
            $ref: "#/components/schemas/ManufacturingOrderRecipeRow"
      example:
        data:
          - id: 4001
            manufacturing_order_id: 3001
            variant_id: 3201
            notes: Use only grade 304 material
            planned_quantity_per_unit: "2.5000000000"
            total_actual_quantity: "125.0000000000"
            ingredient_availability: IN_STOCK
            batch_transactions:
              - batch_id: 1201
                quantity: 125.0
            cost: "437.5000000000"
            created_at: "2024-01-15T08:00:00Z"
            updated_at: "2024-01-20T14:30:00Z"
            deleted_at: null
    SerialNumber:
      description: |
        Individual serial number record for tracking specific units of
        serialized inventory items through transactions.

        **Transfer side-effects:** when a serial number is moved between
        resources (e.g. from a ManufacturingOrder to a SalesOrderRow via
        ``POST /serial_numbers``), the immediate response may report
        ``transaction_id`` equal to the literal string ``undefined`` and
        ``resource_id: null`` for the moved record. The subsequent
        ``GET /serial_numbers`` resolves the correct ``resource_id`` —
        re-fetch via GET to confirm the landing state.
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the serial number record
        transaction_id:
          type:
            - string
            - "null"
          description: |
            Identifier of the transaction that affected this serial number.
            May be the literal string ``undefined`` on a transfer
            response; expect ``null`` in some edge cases.
        serial_number:
          type: string
          description: The actual serial number string for the tracked item
        resource_type:
          description: Type of resource/transaction that generated or moved this serial number
          $ref: "#/components/schemas/SerialNumberResourceType"
        resource_id:
          type:
            - integer
            - "null"
          description: |
            Unique identifier of the specific resource instance.
            May be ``null`` on a transfer response — re-fetch via
            ``GET /serial_numbers`` to confirm.
        transaction_date:
          type:
            - string
            - "null"
          format: date-time
          description: Date and time when the transaction occurred
        quantity_change:
          type: integer
          description: Quantity change for this serial number transaction

    CreateSerialNumberFailedItem:
      description: |
        Single per-string failure block on a ``CreateSerialNumbersResponse``.
        Carries the input ``serial_number`` string and a ``reason`` code so
        the caller can react without inspecting status code or response
        body shape.
      type: object
      additionalProperties: false
      required:
        - serial_number
        - reason
      properties:
        serial_number:
          type: string
          description: The input serial-number string that failed.
        reason:
          $ref: "#/components/schemas/CreateSerialNumberFailureReason"
          description: Reason this serial number could not be created.

    CreateSerialNumbersResponse:
      description: |
        Attachment results from ``POST /serial_numbers``. A matching-variant
        attachment returned this 200 envelope in October 2026 with an empty
        failed array. Invalid strings and quantity conflicts can reject the
        entire request with 422 instead of returning per-string failures.
      type: object
      properties:
        successful:
          type: array
          description: |
            Serial-number records that were attached successfully.
          items:
            $ref: "#/components/schemas/SerialNumber"
        failed:
          type: array
          description: |
            Legacy per-string failures from the published schema. No current
            live invalid-input probe reached this field; those requests return
            ``422`` for the whole operation.
          items:
            $ref: "#/components/schemas/CreateSerialNumberFailedItem"
      required:
        - successful
        - failed
      example:
        successful:
          - id: 886853
            transaction_id: "0f054aa0-1234-5678-9abc-def012345678"
            serial_number: KNF001234567
            resource_type: ManufacturingOrder
            resource_id: 16920710
            transaction_date: "2024-01-15T08:00:00.000Z"
            quantity_change: 0
        failed:
          - serial_number: KNF001234568
            reason: DUPLICATE
    SerialNumberListResponse:
      type: object
      description: List of serial number records for tracking individual units and enabling full product traceability
      properties:
        data:
          type: array
          description: Array of serial number records with unique identifiers and tracking information
          items:
            $ref: "#/components/schemas/SerialNumber"
      example:
        data:
          - id: 5001
            serial_number: KNF001234567
            variant_id: 3001
            location_id: 1
            status: IN_STOCK
            created_at: "2024-01-15T08:00:00.000Z"
            updated_at: "2024-01-15T08:00:00.000Z"
          - id: 5002
            serial_number: KNF001234568
            variant_id: 3001
            location_id: 1
            status: SOLD
            created_at: "2024-01-15T08:30:00.000Z"
            updated_at: "2024-01-16T14:20:00.000Z"
    ManufacturingOrderListResponse:
      description: |
        Response containing a list of manufacturing orders with pagination support for retrieving production data.
      type: object
      properties:
        data:
          type: array
          description: Array of manufacturing orders
          items:
            $ref: "#/components/schemas/ManufacturingOrder"
      example:
        data:
          - id: 3001
            status: IN_PROGRESS
            order_no: MO-2024-001
            variant_id: 2101
            planned_quantity: 50
            actual_quantity: 35
            location_id: 1
            order_created_date: "2024-01-15T08:00:00Z"
            production_deadline_date: "2024-01-25T17:00:00Z"
            additional_info: Priority order for new product launch
            is_linked_to_sales_order: true
            ingredient_availability: IN_STOCK
            total_cost: 12500.0
            total_actual_time: 140.5
            total_planned_time: 200.0
            sales_order_id: 2001
            sales_order_row_id: 2501
            sales_order_delivery_deadline: "2024-01-30T12:00:00Z"
            material_cost: 8750.0
            subassemblies_cost: 2250.0
            operations_cost: 1500.0
            serial_numbers:
              - id: 1
                transaction_id: "MO-2024-001-001"
                serial_number: PKS-001-240115
                resource_type: ManufacturingOrder
                resource_id: 3001
                transaction_date: "2024-01-15T08:00:00Z"
                quantity_change: 1
              - id: 2
                transaction_id: "MO-2024-001-002"
                serial_number: PKS-002-240115
                resource_type: ManufacturingOrder
                resource_id: 3001
                transaction_date: "2024-01-15T08:00:00Z"
                quantity_change: 1
              - id: 3
                transaction_id: "MO-2024-001-003"
                serial_number: PKS-003-240115
                resource_type: ManufacturingOrder
                resource_id: 3001
                transaction_date: "2024-01-15T08:00:00Z"
                quantity_change: 1
            created_at: "2024-01-15T08:00:00Z"
            updated_at: "2024-01-20T14:30:00Z"
            deleted_at: null
    UnlinkManufacturingOrderRequest:
      description:
        Request to unlink a manufacturing order from its associated sales order row, removing the direct connection
        while preserving both orders.
      type: object
      additionalProperties: false
      required:
        - sales_order_row_id
      properties:
        sales_order_row_id:
          type: number
          description: ID of the sales order row to unlink from the manufacturing order
      example:
        sales_order_row_id: 2501
    ManufacturingOrderProductionIngredientListResponse:
      description: |
        Response containing a list of ingredient consumption records across manufacturing order productions, with
        pagination support.
      type: object
      properties:
        data:
          type: array
          description: Array of ingredient consumption records for manufacturing order productions
          items:
            $ref: "#/components/schemas/ManufacturingOrderProductionIngredientResponse"
      example:
        data:
          - id: 252
            location_id: 321
            variant_id: 24764
            manufacturing_order_id: 21400
            manufacturing_order_recipe_row_id: 20300
            production_id: 21300
            quantity: 4
            production_date: "2023-02-10T10:06:13.047Z"
            cost: 1
            created_at: "2023-02-10T10:06:14.435Z"
            updated_at: "2023-02-10T10:06:15.070Z"
            deleted_at: null

    ManufacturingOrderProductionIngredientResponse:
      description: Response containing ingredient consumption data for a manufacturing order production batch
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for this ingredient consumption record
        location_id:
          type: integer
          description: ID of the location where the ingredient was consumed
        variant_id:
          type: integer
          description: ID of the ingredient variant consumed
        manufacturing_order_id:
          type: integer
          description: ID of the manufacturing order this ingredient belongs to
        manufacturing_order_recipe_row_id:
          type: integer
          description: ID of the recipe row this ingredient consumption relates to
        production_id:
          type: integer
          description: ID of the production batch where ingredient was used
        quantity:
          type: number
          description: Actual quantity of ingredient consumed
        production_date:
          type: string
          format: date-time
          description: Date when the ingredient was consumed in production
        cost:
          type: number
          description: Cost of the ingredient consumed
      example:
        id: 4001
        location_id: 1
        variant_id: 2002
        manufacturing_order_id: 1001
        manufacturing_order_recipe_row_id: 1501
        production_id: 2001
        quantity: 2.5
        production_date: "2023-10-15T10:30:00Z"
        cost: 12.5
    ManufacturingOrderOperationRowListResponse:
      description: |
        Response containing a list of manufacturing order operation rows with time tracking and operator assignments
      type: object
      properties:
        data:
          type: array
          description: List of manufacturing order operation rows
          items:
            $ref: "#/components/schemas/ManufacturingOrderOperationRow"
      example:
        data:
          - id: 1501
            manufacturing_order_id: 1001
            operation_id: 201
            time: 45.5
            total_actual_time: "52.3"
            completed_by_operators:
              - operator_id: 101
                name: John Smith
                deleted_at: null
            created_at: "2023-10-15T09:00:00Z"
            updated_at: "2023-10-15T10:30:00Z"
    CreateMaterialRequest:
      description: Request payload for creating a new raw material with variants and specifications
      type: object
      additionalProperties: false
      required:
        - name
        - variants
      dependentRequired:
        purchase_uom: [purchase_uom_conversion_rate]
        purchase_uom_conversion_rate: [purchase_uom]
      properties:
        name:
          type: string
          description: Display name for the material used in inventory and manufacturing
        uom:
          type: string
          maxLength: 7
          description: Unit of measure for inventory tracking (e.g., kg, lb, pcs)
        category_name:
          type: string
          description: Material category for organization and classification
        default_supplier_id:
          type: integer
          maximum: 2147483647
          description: Primary supplier for purchasing this material
        additional_info:
          type: string
          description: Additional specifications or notes about the material
        batch_tracked:
          type: boolean
          description: Whether this material uses batch tracking for quality control
        is_sellable:
          type: boolean
          description: Whether this material can be sold directly to customers
        purchase_uom:
          type: string
          maxLength: 7
          description: |-
            If you are purchasing in a different unit of measure than the default unit of measure (used for tracking
            stock)
            for this item, you can define the purchase unit. Value null indicates that purchasing is done in same unit
            of measure. If value is not null, purchase_uom_conversion_rate must also be populated.
        purchase_uom_conversion_rate:
          type: number
          maximum: 1000000000000
          description: |-
            The conversion rate between the purchase and material UoMs. If used, material must have a purchase_uom
            that is different from uom.
        configs:
          type: array
          description: Material configuration options for creating variants
          items:
            $ref: "#/components/schemas/MaterialConfig"
        custom_field_collection_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: ID of the custom field collection to associate with this material
        variants:
          type: array
          minItems: 1
          description: Material variants with specific configurations and properties
          items:
            $ref: "#/components/schemas/CreateMaterialVariantRequest"
      example:
        name: Stainless Steel Sheet 304
        uom: m²
        category_name: Raw Materials
        default_supplier_id: 1501
        additional_info: Food-grade stainless steel, 1.5mm thickness
        batch_tracked: true
        is_sellable: false
        purchase_uom: sheet
        purchase_uom_conversion_rate: 2.0
        configs:
          - name: Grade
            values:
              - "304"
              - "316"
          - name: Thickness
            values:
              - 1.5mm
              - 2.0mm
              - 3.0mm
        variants:
          - sku: STEEL-304-1.5MM
            purchase_price: 45.00
            lead_time: 5
            minimum_order_quantity: 1
            config_attributes:
              - config_name: Grade
                config_value: "304"
              - config_name: Thickness
                config_value: "1.5mm"
    InventoryItem:
      description: |
        Base schema for products and materials with common inventory management features including tracking, supplier
        relationships, and variant configurations
      allOf:
        - $ref: "#/components/schemas/ArchivableEntity"
        - type: object
          properties:
            name:
              type: string
              description: Display name for the item used in sales, manufacturing, and purchasing contexts
            uom:
              type: string
              description: Unit of measurement for the item (e.g., pcs, kg, m)
            category_name:
              type:
                - string
                - "null"
              description: Category for organizational grouping and reporting
            is_sellable:
              type: boolean
              description: Whether this item can be sold to customers
            default_supplier_id:
              type:
                - integer
                - "null"
              maximum: 2147483647
              description: Primary supplier ID for purchasing this item
            additional_info:
              type: string
              description: Additional notes, specifications, or internal comments
            batch_tracked:
              type: boolean
              description: Whether inventory movements are tracked by batch numbers
            purchase_uom:
              type:
                - string
                - "null"
              description: |-
                If purchasing in a different unit of measure than the default unit of measure (used for tracking stock)
                for this item, you can define the purchase unit. Value null indicates that purchasing is done in same
                unit
                of measure. If value is not null, purchase_uom_conversion_rate must also be populated.
            purchase_uom_conversion_rate:
              type:
                - string
                - "null"
              description: |-
                The conversion rate between the purchase and default UoMs, returned as a fixed-precision decimal
                string. If used, item must have a purchase_uom that is different from uom.
            custom_field_collection_id:
              type:
                - integer
                - "null"
              maximum: 2147483647
              description: ID of the custom field collection associated with this item
            variants:
              type: array
              description: Item variants with different SKUs, pricing, and configurations
              items:
                $ref: "#/components/schemas/Variant"
            configs:
              type: array
              description: Configuration attributes that define variant combinations (size, color, etc.)
              items:
                $ref: "#/components/schemas/ItemConfig"
            supplier:
              anyOf:
                - $ref: "#/components/schemas/Supplier"
                - type: "null"
              description: Primary supplier information for this item
            type:
              description: Item type discriminator - either 'product' or 'material'
              $ref: "#/components/schemas/InventoryItemType"
          required:
            - name
            - type
    Material:
      description:
        Represents raw materials and components used in manufacturing, including
        inventory tracking, supplier information, and batch management.
      allOf:
        - $ref: "#/components/schemas/InventoryItem"
        - type: object
          properties:
            type:
              description: Item type discriminator. Material objects are of type "material"
              $ref: "#/components/schemas/MaterialType"
            deleted_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp when this material was soft-deleted
            serial_tracked:
              type: boolean
              description: Whether inventory movements are tracked by individual serial numbers
            operations_in_sequence:
              type: boolean
              description: Whether manufacturing operations must be completed in a specific sequence
          required:
            - type
      example:
        id: 3201
        name: Stainless Steel Sheet 304
        uom: m²
        category_name: Raw Materials
        default_supplier_id: 1501
        additional_info: Food-grade stainless steel, 1.5mm thickness
        batch_tracked: true
        is_sellable: false
        type: material
        purchase_uom: sheet
        purchase_uom_conversion_rate: "2.0"
        variants:
          - id: 5001
            sku: STEEL-304-1.5MM
            sales_price: null
            purchase_price: 45.00
            type: material
            lead_time: 5
            minimum_order_quantity: 1
            config_attributes:
              - config_name: Grade
                config_value: "304"
              - config_name: Thickness
                config_value: "1.5mm"
            created_at: "2024-01-10T10:00:00Z"
            updated_at: "2024-01-15T14:30:00Z"
        configs:
          - id: 101
            name: Grade
            values:
              - "304"
              - "316"
          - id: 102
            name: Thickness
            values:
              - 1.5mm
              - 2.0mm
              - 3.0mm
        custom_field_collection_id: 201
        supplier: null
        created_at: "2024-01-10T10:00:00Z"
        updated_at: "2024-01-15T14:30:00Z"
        archived_at: null
    MaterialListResponse:
      description: |
        Response containing a list of materials with pagination support for inventory and procurement management.
      type: object
      properties:
        data:
          type: array
          description: Array of materials including raw materials and components
          items:
            $ref: "#/components/schemas/Material"
      example:
        data:
          - id: 3201
            name: Stainless Steel Sheet 304
            uom: m²
            category_name: Raw Materials
            default_supplier_id: 1501
            additional_info: Food-grade stainless steel, 1.5mm thickness
            batch_tracked: true
            is_sellable: false
            type: material
            purchase_uom: sheet
            purchase_uom_conversion_rate: "2.0"
            variants:
              - id: 5001
                sku: STEEL-304-1.5MM
                sales_price: null
                purchase_price: 45.00
                type: material
                lead_time: 5
                minimum_order_quantity: 1
                config_attributes:
                  - config_name: Grade
                    config_value: "304"
                  - config_name: Thickness
                    config_value: "1.5mm"
                created_at: "2024-01-10T10:00:00Z"
                updated_at: "2024-01-15T14:30:00Z"
              - id: 5002
                sku: STEEL-316-1.5MM
                sales_price: null
                purchase_price: 52.00
                type: material
                lead_time: 7
                minimum_order_quantity: 1
                config_attributes:
                  - config_name: Grade
                    config_value: "316"
                  - config_name: Thickness
                    config_value: "1.5mm"
                created_at: "2024-01-10T10:00:00Z"
                updated_at: "2024-01-15T14:30:00Z"
            configs:
              - id: 101
                name: Grade
                values:
                  - "304"
                  - "316"
              - id: 102
                name: Thickness
                values:
                  - "1.5mm"
                  - "2.0mm"
            custom_field_collection_id: 201
            supplier: null
            created_at: "2024-01-10T10:00:00Z"
            updated_at: "2024-01-15T14:30:00Z"
            archived_at: null
    UpdateMaterialRequest:
      description: Request payload for updating an existing raw material's properties and specifications
      type: object
      additionalProperties: false
      dependentRequired:
        purchase_uom: [purchase_uom_conversion_rate]
        purchase_uom_conversion_rate: [purchase_uom]
      properties:
        name:
          type: string
          description: Display name for the material used in inventory and manufacturing
        uom:
          type: string
          maxLength: 7
          description: Unit of measure for inventory tracking (e.g., kg, lb, pcs)
        category_name:
          type: string
          description: Material category for organization and classification
        default_supplier_id:
          type: integer
          maximum: 2147483647
          description: Primary supplier for purchasing this material
        additional_info:
          type: string
          description: Additional specifications or notes about the material
        batch_tracked:
          type: boolean
          description: Whether this material uses batch tracking for quality control
        is_sellable:
          type: boolean
          description: Whether this material can be sold directly to customers
        is_archived:
          type: boolean
          description: Whether this material is archived and hidden from active use
        purchase_uom:
          type: string
          maxLength: 7
          description: |-
            If you are purchasing in a different unit of measure than the default unit of measure (used for tracking
            stock)
            for this item, you can define the purchase unit. Value null indicates that purchasing is done in same unit
            of measure. If value is not null, purchase_uom_conversion_rate must also be populated.
        purchase_uom_conversion_rate:
          type: number
          description: |-
            The conversion rate between the purchase and material UoMs. If used, material must have a purchase_uom
            that is different from uom.
          maximum: 1000000000000
        configs:
          type: array
          minItems: 1
          description: |-
            When updating configs, all configs and values must be provided. Existing ones are matched,
                    new ones are created, and configs not provided in the update are deleted. Each config must
                    identify itself with either id or name.
          items:
            type: object
            additionalProperties: false
            required:
              - values
            properties:
              id:
                type: integer
                description: If config ID is used to map the config, then name is ignored.
              name:
                type: string
                description: Config name used to map the config when id is omitted.
              values:
                type: array
                items:
                  type: string
        custom_field_collection_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: Reference to custom field collection for additional material data
      example:
        name: Stainless Steel Sheet 304 - Updated
        uom: m²
        category_name: Premium Raw Materials
        default_supplier_id: 1502
        additional_info: Food-grade stainless steel, 1.5mm thickness - Updated specifications
        batch_tracked: true
        is_sellable: false
        is_archived: false
        purchase_uom: sheet
        purchase_uom_conversion_rate: 2.0
        configs:
          - id: 101
            values:
              - "304"
              - "316"
              - "430"
          - name: Finish
            values:
              - Brushed
              - Mirror
              - Matte
        custom_field_collection_id: 201
    NegativeStock:
      type: object
      description:
        Record of a variant with negative inventory levels indicating oversold or under-received stock requiring
        immediate attention
      properties:
        variant_id:
          type: integer
          description: ID of the variant with negative stock levels
        location_id:
          type: integer
          description: ID of the location where the negative stock occurred
        latest_negative_stock_date:
          type: string
          format: date-time
          description: Most recent date when the stock went negative
        name:
          type: string
          description: Display name of the variant with negative stock
        sku:
          type: string
          description: Stock keeping unit (SKU) of the variant
        category:
          type: string
          description: Category classification of the variant
        quantity_on_hand:
          type: number
          description: Current negative quantity showing the deficit amount
        quantity_allocated:
          type: number
          description: Quantity allocated to orders despite negative stock
      example:
        variant_id: 3001
        location_id: 1
        latest_negative_stock_date: "2024-01-15T16:30:00.000Z"
        name: Professional Kitchen Knife Set - 8-Piece - Steel Handles
        sku: KNF-PRO-8PC-STL
        category: Kitchen Equipment
        quantity_on_hand: -15.0
        quantity_allocated: 25.0
    NegativeStockListResponse:
      type: object
      description: |
        List of inventory records showing variants with negative stock levels that require immediate attention
      properties:
        data:
          type: array
          description: Array of negative stock records with variant, location, and deficit information
          items:
            $ref: "#/components/schemas/NegativeStock"
      example:
        data:
          - variant_id: 3001
            location_id: 1
            latest_negative_stock_date: "2024-01-15T16:30:00.000Z"
            quantity_on_hand: -15.0
            quantity_allocated: 25.0
          - variant_id: 3003
            location_id: 2
            latest_negative_stock_date: "2024-01-16T09:45:00.000Z"
            quantity_on_hand: -5.0
            quantity_allocated: 10.0
    CreateProductRequest:
      description: |
        Request payload for creating a new finished product with variants, configurations, and manufacturing
        specifications
      type: object
      additionalProperties: false
      required:
        - name
        - variants
      dependentRequired:
        purchase_uom: [purchase_uom_conversion_rate]
        purchase_uom_conversion_rate: [purchase_uom]
      properties:
        name:
          type: string
          description: Display name for the finished product used in sales and manufacturing
        uom:
          type: string
          maxLength: 7
          description: Base unit of measure for the product (e.g., pcs, kg, m)
        category_name:
          type: string
          description: Product category for organization and reporting purposes
        is_sellable:
          type: boolean
          description: Whether this product can be included in sales orders
        is_producible:
          type: boolean
          description: Whether this product can be manufactured using recipes
        is_purchasable:
          type: boolean
          description: Whether this product can be purchased from suppliers
        is_auto_assembly:
          type: boolean
          description: Whether assembly operations are automatically performed when stock is available
        default_supplier_id:
          type: integer
          maximum: 2147483647
          description: Primary supplier for purchasing this product
        additional_info:
          type: string
          description: Additional notes or specifications for the product
        batch_tracked:
          type: boolean
          description: Whether this product uses batch tracking for inventory management
        serial_tracked:
          type: boolean
          description: Whether this product uses serial number tracking for individual units
        operations_in_sequence:
          type: boolean
          description: Whether manufacturing operations must be completed in sequence
        purchase_uom:
          type: string
          maxLength: 7
          description: |-
            If you are purchasing in a different unit of measure than the default unit of measure (used for tracking
            stock)
            for this item, you can define the purchase unit. Value null indicates that purchasing is done in same unit
            of measure. If value is not null, purchase_uom_conversion_rate must also be populated.
        purchase_uom_conversion_rate:
          type: number
          maximum: 1000000000000
          description: |-
            The conversion rate between the purchase and product UoMs. If used, product must have a purchase_uom
            that is different from uom.
        configs:
          type: array
          minItems: 1
          description: Product configuration options for creating variants
          items:
            type: object
            additionalProperties: false
            required:
              - name
              - values
            properties:
              name:
                type: string
                description: Configuration attribute name (e.g., Color, Size)
              values:
                type: array
                description: Available values for this configuration attribute
                items:
                  type: string
        custom_field_collection_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: Reference to custom field collection for additional product data
        variants:
          type: array
          minItems: 1
          description: Product variants with specific configurations and properties
          items:
            $ref: "#/components/schemas/CreateVariantRequest"
      example:
        name: Professional Kitchen Knife Set
        uom: set
        category_name: Kitchen Equipment
        is_sellable: true
        is_producible: true
        is_purchasable: false
        is_auto_assembly: false
        additional_info: High-quality steel construction with ergonomic handles
        batch_tracked: false
        serial_tracked: true
        operations_in_sequence: true
        configs:
          - name: Piece Count
            values:
              - 6-piece
              - 8-piece
              - 12-piece
          - name: Handle Material
            values:
              - Steel
              - Wooden
              - Composite
        variants:
          - sku: KNF-PRO-8PC-STL
            sales_price: 299.99
            purchase_price: 150.0
            supplier_item_codes:
              - "KNF-8PC-STEEL-001"
            lead_time: 14
            minimum_order_quantity: 1
            config_attributes:
              - config_name: Piece Count
                config_value: 8-piece
              - config_name: Handle Material
                config_value: Steel
    UpdateProductRequest:
      description:
        Request payload for updating an existing finished product's properties, configurations, and manufacturing
        specifications
      type: object
      additionalProperties: false
      dependentRequired:
        purchase_uom: [purchase_uom_conversion_rate]
        purchase_uom_conversion_rate: [purchase_uom]
      properties:
        name:
          type: string
          description: Display name for the finished product used in sales and manufacturing
        uom:
          type: string
          maxLength: 7
          description: Unit of measurement for the product (e.g., pcs, kg, m)
        category_name:
          type: string
          description: Product category for organizational grouping and reporting
        is_sellable:
          type: boolean
          description: Whether this product can be sold to customers
        is_producible:
          type: boolean
          description: Whether this product can be manufactured in-house
        is_purchasable:
          type: boolean
          description: Whether this product can be purchased from suppliers
        is_auto_assembly:
          type: boolean
          description: Whether the product should be automatically assembled when components are available
        is_archived:
          type: boolean
          description: Whether this product is archived and hidden from active use
        default_supplier_id:
          type: integer
          maximum: 2147483647
          description: Primary supplier ID for purchasing this product
        additional_info:
          type: string
          description: Additional notes or specifications for the product
        batch_tracked:
          type: boolean
          description: Whether inventory movements are tracked by batch numbers
        serial_tracked:
          type: boolean
          description: Whether inventory movements are tracked by individual serial numbers
        operations_in_sequence:
          type: boolean
          description: Whether manufacturing operations must be completed in a specific sequence
        purchase_uom:
          type: string
          maxLength: 7
          description: |-
            If you are purchasing in a different unit of measure than the default unit of measure (used for tracking
            stock)
            for this item, you can define the purchase unit. Value null indicates that purchasing is done in same unit
            of measure. If value is not null, purchase_uom_conversion_rate must also be populated.
        purchase_uom_conversion_rate:
          type: number
          maximum: 1000000000000
          description: |-
            The conversion rate between the purchase and product UoMs. If used, product must have a purchase_uom
            that is different from uom.
        configs:
          type: array
          minItems: 1
          description: |-
            Configuration attributes that define variant combinations (size, color, etc.).
            When updating configs, all configs and values must be provided. Existing ones are matched,
            new ones are created, and configs not provided in the update are deleted.
            If you want to remove all configs, delete variants first, then you can omit this field.
          items:
            type: object
            additionalProperties: false
            properties:
              id:
                type: integer
                description: |
                  ID of the existing config to update. When set, the server
                  matches by ID instead of by ``name`` — required if you want
                  to rename a config.
              name:
                type: string
                description: Name of the configuration attribute (e.g., Size, Color)
              values:
                type: array
                description: Available values for this configuration attribute
                items:
                  type: string
        custom_field_collection_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: ID of the custom field collection associated with this product
      example:
        name: Professional Kitchen Knife Set
        uom: set
        category_name: Premium Kitchenware
        is_sellable: true
        is_producible: true
        is_purchasable: false
        is_auto_assembly: false
        is_archived: false
        default_supplier_id: 1501
        additional_info: High-carbon stainless steel with ergonomic handles, dishwasher safe
        batch_tracked: false
        serial_tracked: true
        operations_in_sequence: true
        purchase_uom: set
        purchase_uom_conversion_rate: 1.0
        custom_field_collection_id: 5
        configs:
          - name: Piece Count
            values:
              - 6-piece
              - 8-piece
              - 12-piece
          - name: Handle Material
            values:
              - Wood
              - Steel
              - Composite
    Product:
      description:
        A finished good or component that can be sold, manufactured, or purchased, with support for variants and
        configurations
      allOf:
        - $ref: "#/components/schemas/InventoryItem"
        - type: object
          properties:
            type:
              description: Item type discriminator. Product objects are of type "product"
              $ref: "#/components/schemas/ProductType"
            is_producible:
              type: boolean
              description: Whether this product can be manufactured in-house
            is_purchasable:
              type: boolean
              description: Whether this product can be purchased from suppliers
            is_auto_assembly:
              type: boolean
              description: Whether the product should be automatically assembled when components are available
            serial_tracked:
              type: boolean
              description: Whether inventory movements are tracked by individual serial numbers
            operations_in_sequence:
              type: boolean
              description: Whether manufacturing operations must be completed in a specific sequence
            lead_time:
              type:
                - integer
                - "null"
              maximum: 999
              description: Expected lead time for procurement or production
            minimum_order_quantity:
              type:
                - number
                - "null"
              maximum: 999999999
              minimum: 0
              description: Minimum quantity that must be ordered
            configs:
              type: array
              description: Configuration attributes that define variant combinations (size, color, etc.)
              items:
                $ref: "#/components/schemas/ItemConfig"
            deleted_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp when this product was soft-deleted
          required:
            - type
      example:
        id: 1
        name: Standard-hilt lightsaber
        uom: pcs
        category_name: lightsaber
        is_sellable: true
        is_producible: true
        is_purchasable: true
        is_auto_assembly: true
        default_supplier_id: 1
        additional_info: additional info
        batch_tracked: true
        serial_tracked: false
        operations_in_sequence: false
        type: product
        purchase_uom: pcs
        purchase_uom_conversion_rate: "1"
        lead_time: 1
        minimum_order_quantity: 3
        custom_field_collection_id: 1
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        archived_at: null
        variants:
          - id: 1
            sku: EM
            sales_price: 40
            purchase_price: 0
            type: product
            created_at: "2020-10-23T10:37:05.085Z"
            updated_at: "2020-10-23T10:37:05.085Z"
            lead_time: 1
            minimum_order_quantity: 3
            config_attributes:
              - config_name: Type
                config_value: Standard
            internal_barcode: internalcode
            registered_barcode: registeredcode
            supplier_item_codes:
              - code
            custom_fields:
              - field_name: Power level
                field_value: Strong
        configs:
          - id: 1
            name: Type
            values:
              - Standard
              - Double-bladed
            product_id: 1
        supplier: null
    ProductListResponse:
      description: Response containing a paginated list of products with their variants and configurations
      type: object
      properties:
        data:
          type: array
          description: Array of product objects returned by the API
          items:
            $ref: "#/components/schemas/Product"
      example:
        data:
          - id: 101
            name: Professional Kitchen Knife Set
            uom: set
            category_name: Kitchenware
            is_sellable: true
            is_producible: true
            is_purchasable: false
            type: product
            variants:
              - id: 301
                sku: KNF-PRO-8PC
                name: 8-Piece Professional Set
                sales_price: 299.99
          - id: 102
            name: Stainless Steel Mixing Bowls
            uom: set
            category_name: Kitchenware
            is_sellable: true
            is_producible: false
            is_purchasable: true
            type: product
            variants:
              - id: 302
                sku: BOWL-SS-5PC
                name: 5-Piece Mixing Bowl Set
                sales_price: 79.99
    CreatePurchaseOrderRequest:
      description: Request payload for creating a new purchase order to procure materials or products from suppliers
      type: object
      additionalProperties: false
      required:
        - supplier_id
        - location_id
        - purchase_order_rows
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        order_no:
          type: string
          description: |
            Unique purchase order number for tracking and reference. Optional —
            Katana auto-generates a sequential ``PO-N`` value when omitted.
        entity_type:
          description: Whether this purchase order is regular procurement or an outsourced manufacturing order
          $ref: "#/components/schemas/PurchaseOrderEntityType"
        supplier_id:
          type: integer
          maximum: 2147483647
          description: Unique identifier of the supplier providing the materials or services
        currency:
          type: string
          pattern: ^[A-Z]{3}$
          description: Active ISO 4217 currency code (e.g. USD, EUR).
        status:
          description: Initial status of the purchase order when created
          $ref: "#/components/schemas/CreatePurchaseOrderInitialStatus"
        order_created_date:
          type: string
          format: date-time
          description: Date when the purchase order was created
        location_id:
          type: integer
          maximum: 2147483647
          description: Primary location where the purchased items will be received and stored
        additional_info:
          type: string
          description: Optional notes or special instructions for the supplier
        expected_arrival_date:
          type: string
          format: date-time
          description: Expected date when the purchase order items will arrive
        tracking_location_id:
          type: integer
          maximum: 2147483647
          description: Location ID for tracking outsourced orders
        purchase_order_rows:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/PurchaseOrderRowRequest"
          description: List of line items being ordered, including quantities and pricing
      # Business rule validations for outsourced orders
      if:
        properties:
          entity_type:
            const: "outsourced"
      then:
        # Outsourced orders require tracking_location_id
        required: ["tracking_location_id"]
        properties:
          tracking_location_id:
            type: integer
            maximum: 2147483647
      else:
        properties:
          tracking_location_id:
            type: "null"

      example:
        order_no: PO-2024-0156
        entity_type: regular
        supplier_id: 4001
        currency: USD
        status: NOT_RECEIVED
        order_created_date: "2024-01-15T09:30:00Z"
        location_id: 1
        additional_info: Rush order - needed for Valentine's Day production run
        purchase_order_rows:
          - quantity: 250
            price_per_unit: 2.85
            variant_id: 501
            tax_rate_id: 1
            purchase_uom: kg
            purchase_uom_conversion_rate: 1.0
            arrival_date: "2024-08-20T14:45:00Z"
          - quantity: 100
            price_per_unit: 12.5
            variant_id: 502
            tax_rate_id: 1
            purchase_uom: pieces
            purchase_uom_conversion_rate: 1.0
            arrival_date: "2024-08-20T14:45:00Z"
    PurchaseOrderRowRequest:
      description: Request payload for creating a line item within a purchase order
      type: object
      additionalProperties: false
      required:
        - quantity
        - price_per_unit
        - variant_id
      properties:
        quantity:
          type: number
          description: Quantity of items to order for this purchase order line
        price_per_unit:
          type: number
          description: Unit price for each item in this purchase order line
        variant_id:
          type: integer
          description: Unique identifier of the product variant being ordered
        tax_rate_id:
          type: integer
          description: Tax rate identifier to apply to this line item
        purchase_uom_conversion_rate:
          type: number
          description: Conversion rate between purchase unit of measure and base unit
        purchase_uom:
          type: string
          description: Unit of measure for purchasing this item (e.g., kg, pieces, liters)
        arrival_date:
          type: string
          format: date-time
          description: Expected arrival date for this line item
        location_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: |-
            Destination location for this row. Declared by the gateway on the nested
            create-PO row, but **not honored at PO-create time** — Katana silently
            overrides nested rows to the order-level location (verified live
            2026-06-09). To set a per-row location, use `POST /purchase_order_rows` /
            `PATCH /purchase_order_rows/{id}` after creation, or pass it at receive time
            via `POST /purchase_order_receive`.
      example:
        quantity: 250
        price_per_unit: 2.85
        variant_id: 501
        tax_rate_id: 1
        purchase_uom: kg
        purchase_uom_conversion_rate: 1.0
        arrival_date: "2024-08-20T14:45:00Z"

    # Base schema for common purchase order properties
    PurchaseOrderBase:
      description: Base properties shared by all purchase order types
      allOf:
        - $ref: "#/components/schemas/DeletableEntity"
        - type: object
          properties:
            status:
              description: Status of the order.
              $ref: "#/components/schemas/PurchaseOrderStatus"
            order_no:
              type: string
              description: A unique, identifying string used in the UI and controlled by the user.
            entity_type:
              description: Either "regular" or "outsourced", depending on the purchase order type.
              $ref: "#/components/schemas/PurchaseOrderEntityType"
            default_group_id:
              type: integer
              description: |-
                Receipt group of rows that have not been received. A receive call moves the rows it
                receives to a new group, unless it receives the whole order at once; reverting the order
                returns every row here.
            supplier_id:
              type: integer
              description: ID of the supplier who this order belongs to.
            currency:
              type: string
              description: Currency of the purchase order. Filled with supplier currency by default.
            expected_arrival_date:
              type: string
              format: date-time
              description: The timestamp when the items are expected to arrive (in full) in your warehouse.
            order_created_date:
              type: string
              format: date-time
              description: The timestamp of creating the document.
            additional_info:
              type: string
              description: |
                A string attached to the object to add any internal comments, links to external files, additional
                instructions, etc.
            location_id:
              type: integer
              description: The ID of the location to which items are received.
            total:
              type: number
              description: The total value of the order (including taxes) in purchase order currency.
            total_in_base_currency:
              type: number
              description: The total value of the order (including taxes) in base currency.
            billing_status:
              description: |
                Indicating the status of generating the bill through accounting integration to either Xero or QuickBooks
                Online. "PARTIALLY_BILLED" does not apply to Xero integration.
              $ref: "#/components/schemas/PurchaseOrderBillingStatus"
            last_document_status:
              description: Status of the last e-mail sent from (O)PO card.
              $ref: "#/components/schemas/DocumentSendStatus"
            purchase_order_rows:
              type: array
              items:
                $ref: "#/components/schemas/PurchaseOrderRow"
              description: List of line items in this purchase order
            supplier:
              $ref: "#/components/schemas/Supplier"
              description: Complete supplier information for this purchase order

    # Regular purchase order schema
    RegularPurchaseOrder:
      description: Regular purchase order for standard procurement from suppliers
      type: object
      allOf:
        - $ref: "#/components/schemas/PurchaseOrderBase"
        - type: object
          properties:
            entity_type:
              type: string
              enum: ["regular"]
              description: Purchase order type identifier
            tracking_location_id:
              type: "null"
              description: Regular orders do not have tracking locations

    # Outsourced purchase order schema
    OutsourcedPurchaseOrder:
      description: Outsourced purchase order for subcontracted manufacturing
      type: object
      allOf:
        - $ref: "#/components/schemas/PurchaseOrderBase"
        - type: object
          required:
            - tracking_location_id
          properties:
            entity_type:
              type: string
              enum: ["outsourced"]
              description: Purchase order type identifier
            tracking_location_id:
              type: integer
              description: The ID location where the ingredients on the outsourced purchase order are processed
            ingredient_availability:
              $ref: "#/components/schemas/OutsourcedPurchaseOrderIngredientAvailability"
            ingredient_expected_date:
              type:
                - string
                - "null"
              format: date-time
              description: |
                The latest date of a manufacturing order production deadline or a purchasing order expected arrival date
                that relates to the required ingredient
        # Conditional validation for ingredient_expected_date based on ingredient_availability
        - if:
            properties:
              ingredient_availability:
                const: "EXPECTED"
          then:
            properties:
              ingredient_expected_date:
                type: string
                format: date-time
          else:
            properties:
              ingredient_expected_date:
                type: "null"

    # Main purchase order schema using discriminator
    PurchaseOrder:
      description:
        Complete purchase order for procuring materials or products from suppliers, including order details, line
        items, and supplier information
      type: object
      discriminator:
        propertyName: entity_type
        mapping:
          regular: "#/components/schemas/RegularPurchaseOrder"
          outsourced: "#/components/schemas/OutsourcedPurchaseOrder"
      oneOf:
        - $ref: "#/components/schemas/RegularPurchaseOrder"
        - $ref: "#/components/schemas/OutsourcedPurchaseOrder"
      example:
        id: 156
        status: NOT_RECEIVED
        order_no: PO-2024-0156
        entity_type: regular
        default_group_id: 1
        supplier_id: 4001
        currency: USD
        expected_arrival_date: "2024-02-15T00:00:00Z"
        order_created_date: "2024-01-28T00:00:00Z"
        additional_info: Rush order - needed for Valentine's Day production run
        location_id: 1
        tracking_location_id: null
        total: 1962.5
        total_in_base_currency: 1962.5
        billing_status: NOT_BILLED
        last_document_status: NOT_SENT
        ingredient_availability: IN_STOCK
        ingredient_expected_date: null
        created_at: "2024-01-28T09:15:00Z"
        updated_at: "2024-01-28T09:15:00Z"
        deleted_at: null
        purchase_order_rows:
          - id: 501
            quantity: 250
            variant_id: 501
            tax_rate_id: 1
            price_per_unit: 2.85
            price_per_unit_in_base_currency: 2.85
            purchase_uom_conversion_rate: 1.0
            purchase_uom: kg
            currency: USD
            conversion_rate: 1.0
            total: 712.5
            total_in_base_currency: 712.5
            conversion_date: "2024-01-28T09:15:00Z"
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-01-28T09:15:00Z"
            deleted_at: null
          - id: 502
            quantity: 100
            variant_id: 502
            tax_rate_id: 1
            price_per_unit: 12.5
            price_per_unit_in_base_currency: 12.5
            purchase_uom_conversion_rate: 1.0
            purchase_uom: pieces
            currency: USD
            conversion_rate: 1.0
            total: 1250.0
            total_in_base_currency: 1250.0
            conversion_date: "2024-01-28T09:15:00Z"
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-01-28T09:15:00Z"
            deleted_at: null
        supplier:
          id: 4001
          name: Premium Kitchen Supplies Ltd
          email: orders@premiumkitchen.com
          phone: +1-555-0134
          currency: USD
          comment: Primary supplier for kitchen equipment and utensils
          default_address_id: 4001
          created_at: "2023-06-15T08:30:00Z"
          updated_at: "2024-01-15T14:20:00Z"
          deleted_at: null
    PurchaseOrderListResponse:
      description: Response containing a list of purchase orders with pagination support for procurement management
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrder"
          description: Array of purchase order objects
      example:
        data:
          - id: 156
            status: NOT_RECEIVED
            order_no: PO-2024-0156
            entity_type: regular
            supplier_id: 4001
            currency: USD
            expected_arrival_date: "2024-02-15T00:00:00Z"
            order_created_date: "2024-01-28T00:00:00Z"
            total: 1962.5
            total_in_base_currency: 1962.5
            billing_status: NOT_BILLED
            tracking_location_id: null
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-01-28T09:15:00Z"
            deleted_at: null
          - id: 158
            status: PARTIALLY_RECEIVED
            order_no: PO-2024-0158
            entity_type: outsourced
            supplier_id: 4003
            currency: USD
            expected_arrival_date: "2024-02-20T00:00:00Z"
            order_created_date: "2024-01-30T00:00:00Z"
            total: 2450.0
            total_in_base_currency: 2450.0
            billing_status: PARTIALLY_BILLED
            tracking_location_id: 2
            ingredient_availability: EXPECTED
            ingredient_expected_date: "2024-02-18T10:00:00Z"
            created_at: "2024-01-30T11:20:00Z"
            updated_at: "2024-01-30T11:20:00Z"
            deleted_at: null
    PurchaseOrderRow:
      description:
        Individual line item within a purchase order, representing a specific product with quantities, pricing,
        and delivery details
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for this purchase order line item
            quantity:
              type: number
              description: The quantity of items for the order line.
            variant_id:
              type: integer
              description: ID of product or material variant added to the order line.
            tax_rate_id:
              type: integer
              description: ID of tax added to price per unit.
            price_per_unit:
              type: number
              description: The purchase price of one unit (excluding taxes) in purchase order currency.
            price_per_unit_in_base_currency:
              type: number
              description: Unit price converted to the base currency
            purchase_uom_conversion_rate:
              type:
                - number
                - "null"
              description: The conversion rate between the purchase and stock tracking UoMs.
            purchase_uom:
              type:
                - string
                - "null"
              description: |
                The unit used to measure the quantity of the items (e.g. pcs, kg, m) you purchase. It can be different
                from the unit used to track stock.
            currency:
              type: string
              description: Currency used for this line item pricing
            conversion_rate:
              type:
                - number
                - "null"
              description: Currency rate used to convert from purchase order currency into factory base currency.
            total:
              type: number
              description: The total value of the purchase order row (excluding taxes) in purchase order currency.
            total_in_base_currency:
              type: number
              description: The total value of the purchase order row (excluding taxes) in base currency.
            conversion_date:
              type:
                - string
                - "null"
              format: date-time
              description: The date of the conversion rate used.
            received_date:
              type:
                - string
                - "null"
              format: date-time
              description: The date when the items on the purchase order row were received to your stock.
            arrival_date:
              type:
                - string
                - "null"
              format: date-time
              description: |
                The timestamp when the item on the row is expected to arrive (in full) in your warehouse. ISO 8601
                format with time and timezone must be used.
            batch_transactions:
              type: array
              items:
                type: object
                properties:
                  quantity:
                    type: number
                    description: The quantity received in a particular batch.
                  batch_id:
                    type:
                      - integer
                      - "null"
                    description: |
                      ID of the batch for the received item, or ``null``
                      when the receipt targets unbatched stock (e.g. an
                      aggregate receipt against a non-batch-tracked
                      variant). Same nullability semantics as
                      ``StockAdjustmentBatchTransaction.batch_id``.
              description: |
                An array of batch transactions and their quantities. You can receive stock for the same item in multiple
                batches.
            purchase_order_id:
              type: integer
              description: Unique identifier of the parent purchase order
            location_id:
              type:
                - integer
                - "null"
              description: |-
                Destination location for this row when multi-location receiving is used.
                Null when the row inherits the order-level location.
            landed_cost:
              type: number
              description: Total landed cost including shipping, duties, and other charges
            group_id:
              type: integer
              description: |-
                Receipt group of this row. Unreceived rows share the order's `default_group_id`. Each
                POST /purchase_order_receive call assigns the rows it receives a new group, except a call
                that receives the whole order at once, which keeps them in `default_group_id`.
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 501
        quantity: 250
        variant_id: 501
        tax_rate_id: 1
        price_per_unit: 2.85
        price_per_unit_in_base_currency: 2.85
        purchase_uom_conversion_rate: 1.0
        purchase_uom: kg
        currency: USD
        conversion_rate: 1.0
        total: 712.5
        total_in_base_currency: 712.5
        conversion_date: "2024-01-28T09:15:00Z"
        received_date: "2024-02-15T14:30:00Z"
        arrival_date: "2024-02-15T10:00:00Z"
        purchase_order_id: 156
        location_id: 1
        landed_cost: 735.5
        group_id: 1
        created_at: "2024-01-28T09:15:00Z"
        updated_at: "2024-02-15T14:30:00Z"
        deleted_at: null
        batch_transactions:
          - quantity: 150
            batch_id: 1001
          - quantity: 100
            batch_id: 1002
    PurchaseOrderRowListResponse:
      description: |
        Response containing a list of purchase order line items with pagination support for detailed order management
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderRow"
          description: Array of purchase order line item objects
      example:
        data:
          - id: 501
            quantity: 250
            variant_id: 501
            tax_rate_id: 1
            price_per_unit: 2.85
            price_per_unit_in_base_currency: 2.85
            purchase_uom: kg
            currency: USD
            total: 712.5
            total_in_base_currency: 712.5
            purchase_order_id: 156
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-02-15T14:30:00Z"
            deleted_at: null
          - id: 502
            quantity: 100
            variant_id: 502
            tax_rate_id: 1
            price_per_unit: 12.5
            price_per_unit_in_base_currency: 12.5
            purchase_uom: pieces
            currency: USD
            total: 1250.0
            total_in_base_currency: 1250.0
            purchase_order_id: 156
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-02-15T14:30:00Z"
            deleted_at: null
    UpdatePurchaseOrderRequest:
      description: Request payload for updating an existing purchase order's details, status, and line items
      type: object
      additionalProperties: false
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        order_no:
          type: string
          minLength: 3
          description: Updatable only when status is in NOT_RECEIVED or PARTIALLY_RECEIVED
        supplier_id:
          type: integer
          maximum: 2147483647
          description: Updatable only when status is in NOT_RECEIVED
        currency:
          type: string
          description: Updatable only when status is in NOT_RECEIVED
        tracking_location_id:
          type: integer
          maximum: 2147483647
          description: Updatable only when status is in NOT_RECEIVED and entity_type is outsourced
        status:
          description: |-
            Current status indicating progress of order fulfillment. Setting NOT_RECEIVED on a RECEIVED
            order reverts all receipts: `received_date` is cleared, rows and additional cost rows return to
            `default_group_id`, and rows that are identical apart from quantity are merged into one row.
            Returns 422 when the order is PARTIALLY_RECEIVED.
          $ref: "#/components/schemas/PurchaseOrderStatus"
        expected_arrival_date:
          type: string
          format: date-time
          description:
            Updatable only when status is in NOT_RECEIVED or PARTIALLY_RECEIVED. Update will override arrival_date
            on purchase order rows
        order_created_date:
          type: string
          format: date-time
          description: Date when the purchase order was originally created
        location_id:
          type: integer
          maximum: 2147483647
          description: Updatable only when status is in NOT_RECEIVED
        additional_info:
          type: string
          description: Optional notes or special instructions for the supplier

      example:
        order_no: PO-2024-0156-REVISED
        expected_arrival_date: "2024-02-20T00:00:00Z"
        status: PARTIALLY_RECEIVED
        additional_info: Delivery delayed due to weather - updated schedule
    CreatePurchaseOrderAdditionalCostRowRequest:
      description: Request payload for adding additional costs (shipping, duties, handling fees) to a purchase order
      type: object
      additionalProperties: false
      required:
        - additional_cost_id
        - group_id
        - tax_rate_id
        - price
      properties:
        additional_cost_id:
          type: integer
          description: Unique identifier of the additional cost type (e.g., shipping, duty, handling)
        group_id:
          type: integer
          description: Group identifier for organizing related additional costs
        tax_rate_id:
          type: integer
          description: Tax rate identifier to apply to this additional cost
        price:
          type: number
          maximum: 100000000000000000
          minimum: 0
          description: Amount of the additional cost in the purchase order currency
        distribution_method:
          description: How this additional cost is allocated across purchase order line items (e.g., by value or by quantity)
          $ref: "#/components/schemas/CostDistributionMethod"
        reference:
          type:
            - string
            - "null"
          maxLength: 255
          description: Free-text label describing what this cost row is, e.g. a customs invoice or freight surcharge
      example:
        additional_cost_id: 1
        group_id: 1
        tax_rate_id: 1
        price: 125.0
        distribution_method: BY_VALUE
        reference: "Customs invoice #123"
    PurchaseOrderAdditionalCostRow:
      description:
        Additional cost line item within a purchase order, representing charges like shipping, duties, or handling
        fees
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for this additional cost line item
            additional_cost_id:
              type: integer
              description: Unique identifier of the additional cost type (e.g., shipping, duty, handling)
            group_id:
              type: integer
              description: Group identifier for organizing related additional costs
            name:
              type: string
              description: Name or description of the additional cost
            reference:
              type:
                - string
                - "null"
              description: Free-text label describing what this cost row is, e.g. a customs invoice or freight surcharge
            distribution_method:
              type: string
              description: Method used for distributing this cost across purchase order items
            tax_rate_id:
              type: integer
              description: Tax rate identifier applied to this additional cost
            tax_rate:
              type:
                - number
                - "null"
              description: Tax rate percentage applied to this additional cost
            price:
              type: number
              description: Amount of the additional cost in the purchase order currency
            price_in_base:
              type:
                - number
                - "null"
              description: Amount of the additional cost converted to base currency
            currency:
              type: string
              description: Currency used for this additional cost
            currency_conversion_rate:
              type:
                - number
                - "null"
              description: Exchange rate used for currency conversion
            currency_conversion_rate_fix_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date when the currency conversion rate was fixed
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 201
        additional_cost_id: 1
        group_id: 1
        name: International Shipping
        distribution_method: BY_VALUE
        tax_rate_id: 1
        tax_rate: 8.5
        price: 125.0
        price_in_base: 125.0
        currency: USD
        currency_conversion_rate: 1.0
        currency_conversion_rate_fix_date: "2024-01-28T09:15:00Z"
        created_at: "2024-01-28T09:15:00Z"
        updated_at: "2024-01-28T09:15:00Z"
        deleted_at: null
    PurchaseOrderAdditionalCostRowListResponse:
      description: Response containing a list of additional cost line items for purchase orders with pagination support
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderAdditionalCostRow"
          description: Array of additional cost line item objects
      example:
        data:
          - id: 201
            additional_cost_id: 1
            group_id: 1
            name: International Shipping
            reference: "Customs invoice #123"
            distribution_method: BY_VALUE
            tax_rate_id: 1
            tax_rate: 8.5
            price: 125.0
            price_in_base: 125.0
            currency: USD
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-01-28T09:15:00Z"
            deleted_at: null
          - id: 202
            additional_cost_id: 2
            group_id: 1
            name: Import Duty
            reference: null
            distribution_method: BY_VALUE
            tax_rate_id: 1
            tax_rate: 8.5
            price: 85.0
            price_in_base: 85.0
            currency: USD
            created_at: "2024-01-28T09:15:00Z"
            updated_at: "2024-01-28T09:15:00Z"
            deleted_at: null
    UpdatePurchaseOrderAdditionalCostRowRequest:
      description: Request payload for updating an existing additional cost line item on a purchase order
      type: object
      additionalProperties: false
      properties:
        additional_cost_id:
          type: integer
          maximum: 2147483647
          description: Unique identifier of the additional cost type (e.g., shipping, duty, handling)
        tax_rate_id:
          type: integer
          maximum: 2147483647
          description: Tax rate identifier to apply to this additional cost
        price:
          type: number
          minimum: 0
          maximum: 100000000000000000
          description: Updated amount of the additional cost in the purchase order currency
        distribution_method:
          description: How this additional cost is allocated across purchase order line items (e.g., by value or by quantity)
          $ref: "#/components/schemas/CostDistributionMethod"
        reference:
          type:
            - string
            - "null"
          maxLength: 255
          description: Free-text label describing what this cost row is; pass null to clear it
      example:
        additional_cost_id: 1
        tax_rate_id: 1
        price: 150.0
        distribution_method: BY_VALUE
        reference: "Customs invoice #123"
    PurchaseOrderReceiveTraceability:
      type: object
      additionalProperties: false
      description: Traceability allocation supplied when receiving a purchase order row.
      properties:
        batch_id:
          description: Batch to receive into, or null for unallocated stock
          type: [number, "null"]
          minimum: 0
          maximum: 2147483647
        bin_location_id:
          description: Destination bin, or null when no bin is allocated
          type: [number, "null"]
          minimum: 0
          maximum: 2147483647
        serial_number_id:
          description: Received serial number, or null for nonserialized stock
          type: [number, "null"]
          minimum: 0
          maximum: 2147483647
        quantity:
          description: Positive quantity, accepted as a number or decimal string.
          anyOf:
            - type: number
              exclusiveMinimum: 0
            - type: string
              pattern: ^[0-9]+?\.?[0-9]*$
              not:
                pattern: ^(-|)[0]+?\.?[0]*$
    PurchaseOrderReceiveRow:
      description: Row-level data for receiving items against a purchase order, including quantity and batch details
      type: object
      additionalProperties: false
      required:
        - purchase_order_row_id
        - quantity
      properties:
        purchase_order_row_id:
          type: integer
          maximum: 2147483647
          description: Unique identifier of the purchase order row being received
        quantity:
          type: number
          maximum: 100000000000000000
          description: Quantity of items being received for this row
        received_date:
          type: string
          format: date-time
          description: Optional received date in ISO 8601 format.
        location_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: |-
            Destination location to receive this row into, enabling multi-location
            receiving on a single purchase order. Defaults to the row's location (or the
            order-level location) when omitted.
        traceability:
          type: array
          description: Batch, serial number, or bin allocations for this receipt.
          items:
            $ref: "#/components/schemas/PurchaseOrderReceiveTraceability"
        batch_transactions:
          type: array
          description: Array of batch-specific transactions for this received quantity
          items:
            type: object
            additionalProperties: false
            required:
              - batch_id
              - quantity
            properties:
              batch_id:
                type: integer
              quantity:
                type: number
                maximum: 100000000000000000
    RerankPlace:
      description: Exact placement for reranked orders. Supply exactly one of before_id, after_id, or
        position.
      type: object
      additionalProperties: false
      properties:
        after_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the order to place the reranked order after.
        position:
          type: string
          enum: [top, bottom]
          description: Move the reranked orders to the top or bottom of the list.
        before_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the order to place the reranked orders directly above.
      example:
        before_id: 4

      minProperties: 1
      maxProperties: 1
    RerankManufacturingOrderRequest:
      description:
        Request payload for repositioning a manufacturing order in the production schedule, relative to another
        manufacturing order
      type: object
      additionalProperties: false
      required:
        - order_ids
        - place
      properties:
        order_ids:
          type: array
          minItems: 1
          maxItems: 250
          uniqueItems: true
          items:
            type: integer
            minimum: 1
            maximum: 2147483647
          description:
            Manufacturing orders to rerank, in the desired order. Accepts up to 250 distinct IDs.
        place:
          description: Where to place the reranked order, relative to another manufacturing order
          $ref: "#/components/schemas/RerankPlace"
      example:
        order_ids:
          - 1
        place:
          before_id: 4

    RerankSalesOrderRequest:
      description: Request payload for repositioning a sales order in the schedule, relative to another sales order
      type: object
      additionalProperties: false
      required:
        - order_ids
        - place
      properties:
        order_ids:
          type: array
          minItems: 1
          maxItems: 250
          uniqueItems: true
          items:
            type: integer
            minimum: 1
            maximum: 2147483647
          description:
            Sales orders to rerank, in the desired order. Accepts up to 250 distinct IDs.
        place:
          description: Where to place the reranked order, relative to another sales order
          $ref: "#/components/schemas/RerankPlace"
      example:
        order_ids:
          - 1
        place:
          before_id: 4

    PurchaseOrderReceiveRequest:
      description: Request payload for recording the receipt of purchase order items at the facility
      anyOf:
        - type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderReceiveRow"
          minItems: 1
          description: Array of receive records for multiple line items
        - $ref: "#/components/schemas/PurchaseOrderReceiveRow"
          description: Single receive record for one line item
      example:
        - purchase_order_row_id: 501
          quantity: 150
          received_date: "2024-02-15T10:00:00Z"
        - purchase_order_row_id: 502
          quantity: 75
          received_date: "2024-02-15T10:00:00Z"
    CreatePurchaseOrderRowRequest:
      description: Request payload for adding a new line item to an existing purchase order
      type: object
      additionalProperties: false
      required:
        - purchase_order_id
        - price_per_unit
        - quantity
        - variant_id
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        purchase_order_id:
          type: integer
          maximum: 2147483647
          description: Unique identifier of the purchase order to add this line item to
        quantity:
          type: number
          maximum: 100000000000000000
          description: Quantity of items to order for this line item
        variant_id:
          type: integer
          maximum: 2147483647
          description: Unique identifier of the product variant being ordered
        tax_rate_id:
          type: integer
          maximum: 2147483647
          description: Tax rate identifier to apply to this line item
        tax_name:
          type: string
          description: Tax label snapshot to record on this line item
        tax_rate:
          type: string
          description: |
            Tax rate percentage snapshot to record on this line item. Sent
            as a string to preserve exact decimal precision (Katana's wire
            format).
        currency:
          type: string
          pattern: ^[A-Z]{3}$
          description: ISO 4217 currency code for the line price (overrides PO currency)
        price_per_unit:
          type: number
          minimum: 0
          maximum: 100000000000000000
          description: Unit price for each item in this line
        purchase_uom_conversion_rate:
          type: number
          minimum: 0
          maximum: 100000000000000000
          description: Conversion rate between purchase unit of measure and base unit
        purchase_uom:
          type: string
          maxLength: 7
          description: Unit of measure for purchasing this item
        arrival_date:
          type: string
          format: date-time
          description: Optional arrival date in ISO 8601 format.
        location_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: |-
            Destination location for this row, enabling multi-location receiving on a
            single purchase order. Defaults to the order-level location when omitted.

      example:
        purchase_order_id: 156
        quantity: 50
        variant_id: 503
        tax_rate_id: 1
        price_per_unit: 8.75
        purchase_uom_conversion_rate: 1.0
        purchase_uom: pieces
        arrival_date: "2024-02-15T10:00:00Z"
    UpdatePurchaseOrderRowRequest:
      description: Request payload for updating an existing purchase order line item's details and status
      type: object
      additionalProperties: false
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        quantity:
          type: number
          maximum: 100000000000000000
          description: Updatable only when received_date is null
        variant_id:
          type: integer
          maximum: 2147483647
          description: Updatable only when received_date is null
        tax_rate_id:
          type: integer
          maximum: 2147483647
          description: Updatable only when received_date is null
        tax_name:
          type: string
          description: Tax label snapshot to record on this line item
        tax_rate:
          type: string
          description: |
            Tax rate percentage snapshot to record on this line item. Sent
            as a string to preserve exact decimal precision (Katana's wire
            format).
        price_per_unit:
          type: number
          minimum: 0
          maximum: 100000000000000000
          description: Updatable only when received_date is null
        purchase_uom_conversion_rate:
          type: number
          minimum: 0
          maximum: 100000000000000000
          description: Updatable only when received_date is null
        purchase_uom:
          type: string
          maxLength: 7
          description: Updatable only when received_date is null
        received_date:
          type: string
          format: date-time
          description: Updatable only when already set
        arrival_date:
          type: string
          format: date-time
          description: Updatable only when received_date is not null
        location_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: |-
            Destination location for this row (multi-location receiving). Updatable only
            when received_date is null.

      example:
        quantity: 275
        price_per_unit: 2.95
        purchase_uom: kg
        received_date: "2024-02-15T14:30:00Z"
        arrival_date: "2024-02-15T10:00:00Z"
    PurchaseOrderAccountingMetadata:
      description:
        Accounting integration metadata linking purchase orders to external accounting systems for bill processing
        and financial record synchronization
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the accounting metadata record
        purchase_order_id:
          type: integer
          description: ID of the purchase order linked to the accounting system
        received_items_group_id:
          type: integer
          description: ID of the received items group for accounting cost allocation
        integration_type:
          type: string
          description: Type of accounting system integration (e.g., quickBooks, xero, sage)
        bill_id:
          type: string
          description: Bill identifier in the external accounting system
        created_at:
          type: string
          format: date-time
          description: Date and time when the accounting metadata was created
      required:
        - id
        - purchase_order_id
      example:
        id: 156
        purchase_order_id: 8001
        received_items_group_id: 2001
        integration_type: quickBooks
        bill_id: BILL-2024-001
        created_at: "2024-01-15T11:30:00Z"
    PurchaseOrderAccountingMetadataListResponse:
      description:
        Response containing a paginated list of purchase order accounting metadata for financial system integration
        and bill processing
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderAccountingMetadata"
          description: Array of purchase order accounting metadata objects linking to external financial systems
      example:
        data:
          - id: 156
            purchase_order_id: 8001
            received_items_group_id: 2001
            integration_type: quickBooks
            bill_id: BILL-2024-001
            created_at: "2024-01-15T11:30:00Z"
          - id: 157
            purchase_order_id: 8002
            received_items_group_id: 2002
            integration_type: xero
            bill_id: BILL-2024-002
            created_at: "2024-01-15T12:00:00Z"
    CreateSupplierRequest:
      description: Request payload for creating a new supplier with contact information and addresses
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        name:
          type: string
          description: Business name of the supplier company or individual
        currency:
          type: string
          description: Default currency code for transactions with this supplier (e.g., USD, EUR)
        email:
          type: string
          format: email
          description: Primary email address for supplier communication and order confirmations
        phone:
          type: string
          description: Primary phone number for supplier contact and communication
        comment:
          type: string
          description: Optional notes or comments about the supplier relationship
        addresses:
          type: array
          items:
            $ref: "#/components/schemas/SupplierAddressRequest"
          description: List of addresses to associate with this supplier

      example:
        name: Premium Kitchen Supplies Ltd
        currency: USD
        email: orders@premiumkitchen.com
        phone: +1-555-0134
        comment: Primary supplier for kitchen equipment and utensils
        addresses:
          - line_1: 1250 Industrial Blvd
            line_2: Suite 200
            city: Chicago
            state: IL
            zip: "60601"
            country: US
    SupplierAddressRequest:
      description: Request payload for creating or specifying a supplier address
      type: object
      additionalProperties: false
      required:
        - line_1
      properties:
        supplier_id:
          type: integer
          description: Unique identifier of the supplier this address belongs to
        line_1:
          type: string
          description: Primary address line (street number, street name)
        line_2:
          type: string
          description: Secondary address line (suite, apartment, building)
        city:
          type: string
          description: City name
        state:
          type: string
          description: State, province, or region
        zip:
          type: string
          description: Postal code or ZIP code
        country:
          type: string
          description: Country code (ISO 3166-1 alpha-2 format)
      example:
        line_1: 1250 Industrial Blvd
        line_2: Suite 200
        city: Chicago
        state: IL
        zip: "60601"
        country: US
    Supplier:
      description: Supplier company or individual providing materials, products, or services for procurement operations
      allOf:
        - type: object
          properties:
            name:
              type: string
              description: Business name of the supplier company or individual
            email:
              type: string
              description: Primary email address for supplier communication and order confirmations
            phone:
              type: string
              description: Primary phone number for supplier contact and communication
            currency:
              type: string
              pattern: ^[A-Z]{3}$
              description: Default currency used for transactions with this supplier (ISO 4217 format)
            comment:
              type: string
              description: Optional notes or comments about the supplier relationship
            default_address_id:
              type: integer
              description: Unique identifier of the default address for this supplier
            addresses:
              type: array
              items:
                $ref: "#/components/schemas/SupplierAddress"
              description: List of addresses associated with this supplier
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 4001
        name: Premium Kitchen Supplies Ltd
        email: orders@premiumkitchen.com
        phone: +1-555-0134
        currency: USD
        comment: Primary supplier for kitchen equipment and utensils. Reliable delivery times.
        default_address_id: 4001
        created_at: "2023-06-15T08:30:00Z"
        updated_at: "2024-01-15T14:20:00Z"
        deleted_at: null
        addresses:
          - id: 4001
            company: Premium Kitchen Supplies Ltd
            street: 1250 Industrial Blvd
            street2: Suite 200
            city: Chicago
            state: IL
            zip: "60601"
            country: US
            created_at: "2023-06-15T08:30:00Z"
            updated_at: "2023-06-15T08:30:00Z"
            deleted_at: null
    SupplierListResponse:
      description: Response containing a list of suppliers with pagination support for supplier management
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Supplier"
          description: Array of supplier objects
      example:
        data:
          - id: 4001
            name: Premium Kitchen Supplies Ltd
            email: orders@premiumkitchen.com
            phone: +1-555-0134
            currency: USD
            comment: Primary supplier for kitchen equipment and utensils
            default_address_id: 4001
            created_at: "2023-06-15T08:30:00Z"
            updated_at: "2024-01-15T14:20:00Z"
            deleted_at: null
          - id: 4002
            name: Industrial Food Systems
            email: procurement@indufood.com
            phone: +1-555-0276
            currency: USD
            comment: Specialized in commercial kitchen appliances
            default_address_id: 4002
            created_at: "2023-08-22T10:15:00Z"
            updated_at: "2023-12-10T16:30:00Z"
            deleted_at: null
    UpdateSupplierRequest:
      description: Request payload for updating an existing supplier's contact information and details
      type: object
      additionalProperties: false
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        name:
          type: string
          description: Business name of the supplier company or individual
        email:
          type: string
          format: email
          description: Primary email address for supplier communication and order confirmations
        phone:
          type: string
          description: Primary phone number for supplier contact and communication
        currency:
          type: string
          pattern: ^[A-Z]{3}$
          description: The supplier's currency (ISO 4217).
        comment:
          type: string
          description: Optional notes or comments about the supplier relationship

      example:
        name: Premium Kitchen Supplies Ltd
        email: orders@premiumkitchen.com
        phone: +1-555-0134
        currency: USD
        comment: Primary supplier for kitchen equipment and utensils. Excellent customer service.
    SupplierAddress:
      description: Physical address information for a supplier, used for shipping, billing, and correspondence
      allOf:
        - type: object
          properties:
            supplier_id:
              type: integer
              description: Unique identifier of the supplier this address belongs to
            line_1:
              type: string
              description: Primary address line (street number, street name)
            line_2:
              type:
                - string
                - "null"
              description: Secondary address line (suite, apartment, building)
            city:
              type:
                - string
                - "null"
              description: City name
            state:
              type:
                - string
                - "null"
              description: State, province, or region
            zip:
              type:
                - string
                - "null"
              description: Postal code or ZIP code
            country:
              type:
                - string
                - "null"
              description: Country code (ISO 3166-1 alpha-2 format)
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 4001
        supplier_id: 4001
        line_1: 1250 Industrial Blvd
        line_2: Suite 200
        city: Chicago
        state: IL
        zip: "60601"
        country: US
        created_at: "2023-06-15T08:30:00Z"
        updated_at: "2023-06-15T08:30:00Z"
        deleted_at: null
    SupplierAddressListResponse:
      description: Response containing a list of supplier addresses with pagination support for address management
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SupplierAddress"
          description: Array of supplier address objects
      example:
        data:
          - id: 4001
            supplier_id: 4001
            line_1: 1250 Industrial Blvd
            line_2: Suite 200
            city: Chicago
            state: IL
            zip: "60601"
            country: US
            created_at: "2023-06-15T08:30:00Z"
            updated_at: "2023-06-15T08:30:00Z"
            deleted_at: null
          - id: 4002
            supplier_id: 4001
            line_1: 856 Distribution Center Dr
            line_2: null
            city: Milwaukee
            state: WI
            zip: "53218"
            country: US
            created_at: "2023-06-15T08:30:00Z"
            updated_at: "2023-06-15T08:30:00Z"
            deleted_at: null
    CreateSupplierAddressRequest:
      description: Request payload for creating a new address for an existing supplier
      type: object
      additionalProperties: false
      required:
        - supplier_id
      properties:
        supplier_id:
          type: integer
          description: Unique identifier of the supplier this address belongs to
        line_1:
          type: string
          description: Primary address line (street number, street name)
        line_2:
          type:
            - string
            - "null"
          description: Secondary address line (suite, apartment, building)
        city:
          type:
            - string
            - "null"
          description: City name
        state:
          type:
            - string
            - "null"
          description: State, province, or region
        zip:
          type:
            - string
            - "null"
          description: Postal code or ZIP code
        country:
          type:
            - string
            - "null"
          description: Country code (ISO 3166-1 alpha-2 format)
      example:
        supplier_id: 4001
        line_1: 856 Distribution Center Dr
        line_2: null
        city: Milwaukee
        state: WI
        zip: "53218"
        country: US
    UpdateSupplierAddressRequest:
      description: Request payload for updating an existing supplier address
      type: object
      additionalProperties: false
      properties:
        line_1:
          type:
            - string
            - "null"
          description: Primary address line (street number, street name)
        line_2:
          type:
            - string
            - "null"
          description: Secondary address line (suite, apartment, building)
        city:
          type:
            - string
            - "null"
          description: City name
        state:
          type:
            - string
            - "null"
          description: State, province, or region
        zip:
          type:
            - string
            - "null"
          description: Postal code or ZIP code
        country:
          type:
            - string
            - "null"
          description: Country code (ISO 3166-1 alpha-2 format)
      example:
        line_1: 1250 Industrial Blvd
        line_2: Suite 300
        city: Chicago
        state: IL
        zip: "60601"
        country: US
    CreateTaxRateRequest:
      description: |
        Request payload for creating a new tax rate to be applied to sales and purchase orders for financial compliance
      type: object
      additionalProperties: false
      required:
        - rate
      properties:
        name:
          type: string
          description: Descriptive name for the tax rate (e.g., "VAT 20%", "Sales Tax", "GST")
        rate:
          type: number
          minimum: 0
          maximum: 999.999
          multipleOf: 0.001
          description: Tax rate as a percentage (e.g., 20.5 for 20.5%)
      example:
        name: VAT 20%
        rate: 20.0
    TaxRate:
      description:
        Tax rate configuration for applying taxes to sales and purchase transactions based on jurisdiction and
        business requirements
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the tax rate
            name:
              type: string
              description: Descriptive name for the tax rate (e.g., "VAT 20%", "Sales Tax", "GST")
            rate:
              type: number
              description: Tax rate as a percentage (e.g., 20.5 for 20.5% tax)
            is_default_sales:
              type: boolean
              description: Whether this tax rate is the default for sales transactions
            is_default_purchases:
              type: boolean
              description: Whether this tax rate is the default for purchase transactions
            display_name:
              type: string
              description: Formatted display name for user interface presentation
        - $ref: "#/components/schemas/UpdatableEntity"
      example:
        id: 301
        name: VAT 20%
        rate: 20.0
        is_default_sales: true
        is_default_purchases: false
        display_name: VAT (20.0%)
        created_at: "2024-01-15T09:30:00Z"
        updated_at: "2024-01-15T09:30:00Z"
    TaxRateListResponse:
      description:
        Response containing a paginated list of tax rates configured for the organization's sales and purchase
        tax compliance
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/TaxRate"
          description: Array of tax rate objects
      example:
        data:
          - id: 301
            name: VAT 20%
            rate: 20.0
            is_default_sales: true
            is_default_purchases: false
            display_name: VAT (20.0%)
            created_at: "2024-01-15T09:30:00Z"
            updated_at: "2024-01-15T09:30:00Z"
          - id: 302
            name: VAT 5%
            rate: 5.0
            is_default_sales: false
            is_default_purchases: true
            display_name: VAT (5.0%)
            created_at: "2024-01-15T09:35:00Z"
            updated_at: "2024-01-15T09:35:00Z"
    CreateMaterialVariantRequest:
      description: |
        Variant embedded in POST /materials. The material parent is implicit.
        Unlike product creation and POST /variants, this shape rejects sales_price.
        Set a material selling price afterward with PATCH /variants/{id}.
      type: object
      additionalProperties: false
      properties:
        sku:
          type: string
          description: Stock keeping unit code for unique identification of this product variant
        purchase_price:
          type:
            - number
            - "null"
          minimum: 0
          description: Default purchase cost per unit for this product variant
          maximum: 100000000000
        supplier_item_codes:
          type: array
          description: Supplier-specific part numbers or SKUs for purchasing this variant
          items:
            type: string
            minLength: 1
            maxLength: 40
        internal_barcode:
          type: string
          minLength: 3
          maxLength: 40
          description: Internal barcode for warehouse scanning and tracking
        registered_barcode:
          type: string
          maxLength: 40
          description: Official registered barcode (UPC, EAN, etc.) for retail use
        lead_time:
          type:
            - integer
            - "null"
          maximum: 999
          description: Days required to manufacture or procure this variant
        minimum_order_quantity:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 999999999
          description: Minimum quantity that must be ordered from suppliers
        config_attributes:
          type: array
          minItems: 1
          description: Configuration attribute values that define this variant (color, size, etc.)
          items:
            type: object
            additionalProperties: false
            required:
              - config_name
              - config_value
            properties:
              config_name:
                type: string
                description: Name of the configuration attribute (e.g., Color, Size)
              config_value:
                type: string
                description: Value for this configuration attribute (e.g., Blue, Large)
        custom_fields:
          description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
          anyOf:
            - type: object
              propertyNames:
                pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
              additionalProperties:
                type:
                  - string
                  - number
                  - boolean
                  - 'null'
            - type: array
              maxItems: 3
              items:
                type: object
                additionalProperties: false
                required:
                  - field_name
                  - field_value
                properties:
                  field_name:
                    type: string
                    description: Name of the custom field
                  field_value:
                    type: string
                    description: Value stored in the custom field
                title: CustomFieldsItem

      example:
        sku: KNF-PRO-12PC-WD
        purchase_price: 200.0
        supplier_item_codes:
          - SUP-KNF-12PC-002
        internal_barcode: INT-KNF-002
        registered_barcode: "789123456790"
        lead_time: 10
        minimum_order_quantity: 1
        config_attributes:
          - config_name: Piece Count
            config_value: 12-piece
          - config_name: Handle Material
            config_value: Wood
        custom_fields:
          - field_name: Warranty Period
            field_value: 5 years
          - field_name: Care Instructions
            field_value: Hand wash only
    CreateVariantRequest:
      description: |
        Request payload for creating a new product or material variant with specific SKU and configuration attributes.

        **Parent reference:** specify **exactly one** of ``product_id`` or
        ``material_id``, never both — variants are scoped to a single parent
        item.
      type: object
      additionalProperties: false
      properties:
        sku:
          type: string
          description: Stock keeping unit code for unique identification of this product variant
        sales_price:
          type: number
          description: Default selling price per unit for this product variant
          minimum: 0
          maximum: 100000000000
        purchase_price:
          type: number
          minimum: 0
          description: Default purchase cost per unit for this product variant
          maximum: 100000000000
        product_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: |
            ID of the parent product if this variant belongs to a finished
            good. Mutually exclusive with ``material_id``.
        material_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: |
            ID of the parent material if this variant belongs to a raw
            material. Mutually exclusive with ``product_id``.
        supplier_item_codes:
          type: array
          description: Supplier-specific part numbers or SKUs for purchasing this variant
          items:
            type: string
            minLength: 1
            maxLength: 40
        internal_barcode:
          type: string
          minLength: 3
          maxLength: 40
          description: Internal barcode for warehouse scanning and tracking
        registered_barcode:
          type: string
          maxLength: 120
          description: Official registered barcode (UPC, EAN, etc.) for retail use
        lead_time:
          type:
            - integer
            - "null"
          maximum: 999
          description: Days required to manufacture or procure this variant
        minimum_order_quantity:
          type: number
          minimum: 0
          maximum: 999999999
          description: Minimum quantity that must be ordered from suppliers
        config_attributes:
          type: array
          minItems: 1
          description: Configuration attribute values that define this variant (color, size, etc.)
          items:
            type: object
            additionalProperties: false
            required:
              - config_name
              - config_value
            properties:
              config_name:
                type: string
                description: Name of the configuration attribute (e.g., Color, Size)
              config_value:
                type: string
                description: Value for this configuration attribute (e.g., Blue, Large)
        custom_fields:
          description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
          anyOf:
            - type: object
              propertyNames:
                pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
              additionalProperties:
                type:
                  - string
                  - number
                  - boolean
                  - 'null'
            - type: array
              maxItems: 3
              items:
                type: object
                additionalProperties: false
                required:
                  - field_name
                  - field_value
                properties:
                  field_name:
                    type: string
                    description: Name of the custom field
                  field_value:
                    type: string
                    description: Value stored in the custom field
                title: CustomFieldsItem

      example:
        sku: KNF-PRO-12PC-WD
        sales_price: 399.99
        purchase_price: 200.0
        product_id: 101
        material_id: null
        supplier_item_codes:
          - SUP-KNF-12PC-002
        internal_barcode: INT-KNF-002
        registered_barcode: "789123456790"
        lead_time: 10
        minimum_order_quantity: 1
        config_attributes:
          - config_name: Piece Count
            config_value: 12-piece
          - config_name: Handle Material
            config_value: Wood
        custom_fields:
          - field_name: Warranty Period
            field_value: 5 years
          - field_name: Care Instructions
            field_value: Hand wash only
    VariantResponse:
      description: |
        Response containing a variant with its configuration attributes and related product or material details
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for this variant
            sku:
              type:
                - string
                - "null"
              description: |-
                Stock keeping unit code for unique identification. Katana allows
                variants to be created without a SKU; the value may be null for
                such rows. ``VariantResponse`` does not declare ``sku`` as required,
                so the key may also be omitted entirely on some response shapes —
                consumers should handle both ``null`` and missing keys.
            sales_price:
              type: number
              description: Price at which this variant is sold to customers
            purchase_price:
              type: number
              description: Cost to purchase this variant from suppliers
            product_id:
              type:
                - integer
                - "null"
              description: ID of the parent product if this variant belongs to a finished good
            material_id:
              type:
                - integer
                - "null"
              description: ID of the parent material if this variant belongs to a raw material
            type:
              $ref: "#/components/schemas/VariantType"
            internal_barcode:
              type:
                - string
                - "null"
              description: Internal barcode for warehouse scanning and tracking
            registered_barcode:
              type:
                - string
                - "null"
              description: Official registered barcode (UPC, EAN, etc.) for retail use
            supplier_item_codes:
              type: array
              description: Supplier-specific part numbers or SKUs for purchasing
              items:
                type: string
            lead_time:
              type:
                - integer
                - "null"
              description: Days required to manufacture or procure this variant
            minimum_order_quantity:
              type:
                - number
                - "null"
              description: Minimum quantity that must be ordered from suppliers
            config_attributes:
              type:
                - array
                - "null"
              description: Configuration attribute values that define this variant
              items:
                type: object
                properties:
                  config_name:
                    type: string
                    description: Name of the configuration attribute (e.g., Color, Size)
                  config_value:
                    type: string
                    description: Value for this configuration attribute (e.g., Blue, Large)
            custom_fields:
              description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
              anyOf:
                - type: array
                  items:
                    type: object
                    properties:
                      field_name:
                        type: string
                        description: Name of the custom field
                      field_value:
                        type: string
                        description: Value stored in the custom field
                - type: object
                  propertyNames:
                    pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
                  additionalProperties:
                    type:
                      - string
                      - number
                      - boolean
                      - 'null'
                - type: 'null'
            product_or_material:
              oneOf:
                - $ref: "#/components/schemas/Product"
                - $ref: "#/components/schemas/Material"
              discriminator:
                propertyName: type
                mapping:
                  product: "#/components/schemas/Product"
                  material: "#/components/schemas/Material"
              description: Details of the parent product or material this variant belongs to
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3001
        sku: KNF-PRO-8PC-STL
        sales_price: 299.99
        purchase_price: 150.0
        product_id: 101
        material_id:
        type: product
        internal_barcode: INT-KNF-001
        registered_barcode: "789123456789"
        supplier_item_codes:
          - SUP-KNF-8PC-001
        lead_time: 7
        minimum_order_quantity: 1
        config_attributes:
          - config_name: Piece Count
            config_value: 8-piece
          - config_name: Handle Material
            config_value: Steel
        custom_fields:
          - field_name: Warranty Period
            field_value: 5 years
        product_or_material:
          id: 101
          name: Professional Kitchen Knife Set
          uom: set
          category_name: Kitchenware
          is_sellable: true
          is_producible: true
          is_purchasable: false
          type: product
          created_at: "2024-01-15T08:00:00.000Z"
          updated_at: "2024-08-20T14:45:00.000Z"
          archived_at:
        created_at: "2024-01-15T08:00:00.000Z"
        updated_at: "2024-08-20T14:45:00.000Z"
        deleted_at:
    UpdateVariantRequest:
      description: |
        Request payload for updating product variant details including pricing, configuration, and inventory information.
        Note: ``product_id`` and ``material_id`` are not present here — a variant's parent
        is set at create time and cannot be reassigned via PATCH.
      type: object
      additionalProperties: false
      properties:
        sku:
          type: string
          description: Stock keeping unit code for unique identification of this product variant
        sales_price:
          type: number
          description: Default selling price per unit for this product variant
          minimum: 0
          maximum: 100000000000
        purchase_price:
          type: number
          minimum: 0
          description: Default purchase cost per unit for this product variant
          maximum: 100000000000
        supplier_item_codes:
          type: array
          description: Supplier-specific codes for ordering this variant
          items:
            type: string
        internal_barcode:
          type: string
          minLength: 3
          maxLength: 40
          description: Internal barcode for warehouse operations and tracking
        registered_barcode:
          type: string
          maxLength: 120
          description: External barcode registered for retail scanning (UPC, EAN)
        lead_time:
          type:
            - integer
            - "null"
          maximum: 999
          description: Expected lead time in days for procurement or production
        minimum_order_quantity:
          type: number
          minimum: 0
          maximum: 999999999
          description: Minimum quantity that must be ordered from suppliers
        config_attributes:
          type: array
          description: Configuration attribute values that define this variant
          items:
            type: object
            properties:
              config_name:
                type: string
                description: Name of the configuration attribute
              config_value:
                type: string
                description: Value of the configuration attribute for this variant
        custom_fields:
          description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
          anyOf:
            - type: object
              propertyNames:
                pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
              additionalProperties:
                type:
                  - string
                  - number
                  - boolean
                  - 'null'
            - type: array
              maxItems: 3
              items:
                type: object
                properties:
                  field_name:
                    type: string
                    description: Name of the custom field
                  field_value:
                    type: string
                    description: Value of the custom field for this variant
                title: CustomFieldsItem
                additionalProperties: false
                required:
                  - field_name
                  - field_value

      example:
        sku: KNF-PRO-8PC-UPD
        sales_price: 319.99
        purchase_price: 160.0
        supplier_item_codes:
          - SUP-KNF-8PC-002
        internal_barcode: INT-KNF-002
        registered_barcode: "789123456790"
        lead_time: 5
        minimum_order_quantity: 1
        config_attributes:
          - config_name: Piece Count
            config_value: 8-piece
          - config_name: Handle Material
            config_value: Premium Steel
        custom_fields:
          - field_name: Warranty Period
            field_value: 7 years
    VariantListResponse:
      description:
        Response containing a paginated list of variants with their configuration attributes and parent product
        details
      type: object
      properties:
        data:
          type: array
          description: Array of variant objects returned by the API
          items:
            $ref: "#/components/schemas/VariantResponse"
      example:
        data:
          - id: 3001
            sku: KNF-PRO-8PC-STL
            sales_price: 299.99
            type: product
            config_attributes:
              - config_name: Piece Count
                config_value: 8-piece
              - config_name: Handle Material
                config_value: Steel
          - id: 3002
            sku: KNF-PRO-12PC-WD
            sales_price: 399.99
            type: product
            config_attributes:
              - config_name: Piece Count
                config_value: 12-piece
              - config_name: Handle Material
                config_value: Wood
          - id: 5001
            sku: STEEL-304-1.5MM
            sales_price: 65.00
            purchase_price: 45.00
            type: material
            lead_time: 5
            minimum_order_quantity: 1
            config_attributes:
              - config_name: Grade
                config_value: "304"
              - config_name: Thickness
                config_value: "1.5mm"
          - id: 5003
            sku: ALU-6061-2.0MM
            sales_price: 55.00
            purchase_price: 38.50
            type: material
            lead_time: 3
            minimum_order_quantity: 2
            config_attributes:
              - config_name: Alloy
                config_value: "6061"
              - config_name: Thickness
                config_value: "2.0mm"
    VariantDefaultStorageBinLink:
      type: object
      description:
        Link defining the default storage bin assignment for a specific variant to optimize warehouse picking and
        storage
      additionalProperties: false
      required:
        - bin_name
        - variant_id
      properties:
        location_id:
          type: integer
          maximum: 2147483647
          description: ID of the location where the storage bin is located
        variant_id:
          type: integer
          maximum: 2147483647
          description: ID of the variant to link to the storage bin
        bin_name:
          type: string
          minLength: 0
          maxLength: 40
          description: Name of the storage bin to set as default for this variant
      example:
        location_id: 1
        variant_id: 3001
        bin_name: A-01-SHELF-1
    VariantDefaultStorageBinLinkResponse:
      description: Complete variant storage bin link record with system metadata for warehouse configuration management
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the variant-storage bin link
            bin_name:
              type: string
              description: Name of the storage bin linked to this variant
            variant_id:
              type: integer
              description: ID of the variant linked to the storage bin
            storage_bin_id:
              type: integer
              description: ID of the storage bin assigned as default for this variant
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 501
        bin_name: A-01-SHELF-1
        variant_id: 3001
        storage_bin_id: 12345
        created_at: "2024-01-15T08:00:00.000Z"
        updated_at: "2024-01-15T08:00:00.000Z"
        deleted_at: null
    UnlinkVariantBinLocationRequest:
      type: object
      description: Request to remove a variant's default storage bin assignment for a specific location
      additionalProperties: false
      required:
        - location_id
        - variant_id
      properties:
        location_id:
          type: integer
          maximum: 2147483647
          description: ID of the location where the variant-bin link should be removed
        variant_id:
          type: integer
          maximum: 2147483647
          description: ID of the variant whose storage bin assignment should be removed
      example:
        location_id: 1
        variant_id: 3001
    UnlinkVariantBinLocationListRequest:
      type: array
      description: Batch request to remove variant storage bin assignments for multiple location-variant combinations
      minItems: 1
      maxItems: 150
      items:
        $ref: "#/components/schemas/UnlinkVariantBinLocationRequest"
      example:
        - location_id: 1
          variant_id: 3001
        - location_id: 1
          variant_id: 3002
    WebhookEvent:
      type: string
      description: |-
        Available webhook events for real-time notifications.
        Mirrors the event list the live gateway accepts; see the Katana API
        changelog for newly added events.
      enum:
        - sales_order.created
        - sales_order.approved
        - sales_order.updated
        - sales_order.deleted
        - sales_order.ready_for_fulfillment
        - sales_order.packed
        - sales_order.delivered
        - sales_order.invoiced
        - sales_order.availability_updated
        - purchase_order.created
        - purchase_order.approved
        - purchase_order.updated
        - purchase_order.deleted
        - purchase_order.partially_received
        - purchase_order.received
        - purchase_order.billed
        - purchase_order_row.created
        - purchase_order_row.updated
        - purchase_order_row.deleted
        - purchase_order_row.received
        - manufacturing_order.created
        - manufacturing_order.updated
        - manufacturing_order.deleted
        - manufacturing_order.in_progress
        - manufacturing_order.blocked
        - manufacturing_order.done
        - manufacturing_order_operation_row.created
        - manufacturing_order_operation_row.updated
        - manufacturing_order_operation_row.deleted
        - manufacturing_order_operation_row.in_progress
        - manufacturing_order_operation_row.paused
        - manufacturing_order_operation_row.blocked
        - manufacturing_order_operation_row.completed
        - manufacturing_order_recipe_row.created
        - manufacturing_order_recipe_row.updated
        - manufacturing_order_recipe_row.deleted
        - manufacturing_order_recipe_row.ingredients_in_stock
        - current_inventory.product_updated
        - current_inventory.material_updated
        - current_inventory.product_out_of_stock
        - current_inventory.material_out_of_stock
        - product.created
        - product.updated
        - product.deleted
        - material.created
        - material.updated
        - material.deleted
        - variant.created
        - variant.updated
        - variant.deleted
        - product_recipe_row.created
        - product_recipe_row.updated
        - product_recipe_row.deleted
        - bom_row.created
        - bom_row.updated
        - bom_row.deleted
        - outsourced_purchase_order.created
        - outsourced_purchase_order.approved
        - outsourced_purchase_order.updated
        - outsourced_purchase_order.deleted
        - outsourced_purchase_order.received
        - outsourced_purchase_order.billed
        - outsourced_purchase_order_row.created
        - outsourced_purchase_order_row.updated
        - outsourced_purchase_order_row.deleted
        - outsourced_purchase_order_row.received
        - outsourced_purchase_order_recipe_row.created
        - outsourced_purchase_order_recipe_row.updated
        - outsourced_purchase_order_recipe_row.deleted
    WebhookEventPayload:
      type: object
      description: |-
        Webhook event payload structure sent to registered webhook endpoints.
        Contains information about the event and the affected resource.
      required:
        - resource_type
        - action
        - webhook_id
        - object
      properties:
        resource_type:
          type: string
          description: Indicates the resource type affected by this event
          example: sales_order
        action:
          $ref: "#/components/schemas/WebhookEvent"
          description: The event that triggered this webhook
          example: sales_order.delivered
        webhook_id:
          type: integer
          description: ID of the registered webhook that was used to send the payload
          example: 123
        object:
          type: object
          description: |-
            The object affected by this event. Contains id, status and href to retrieve the resource.

            Notes:
            - href property doesn't apply to deleted events (e.g., sales_order.deleted, product_recipe_row.deleted)
            - status field appears in examples but is not documented in official Katana API docs
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: Unique identifier of the affected resource
              example: "12345"
            status:
              type: string
              description: |-
                Current status of the affected resource.
                Note: This field appears in webhook payload examples but is not documented
                in the official Katana API documentation. The actual values and format
                may vary by resource type and may not be reliable for programmatic use.
              example: DELIVERED
            href:
              type: string
              description: API endpoint URL to retrieve the full resource (not available for deleted events)
              example: https://api.katanamrp.com/v1/sales_orders/12345
      example:
        resource_type: sales_order
        action: sales_order.delivered
        webhook_id: 123
        object:
          id: "12345"
          status: DELIVERED
          href: https://api.katanamrp.com/v1/sales_orders/12345
    CreateWebhookRequest:
      type: object
      description: Request payload for creating a new webhook subscription to receive real-time event notifications
      additionalProperties: false
      required:
        - url
        - subscribed_events
      properties:
        url:
          type: string
          pattern: ^https://.*$
          description: HTTPS endpoint URL where webhook events will be sent (must use HTTPS for security)
        enabled:
          type: boolean
          description: Whether this webhook subscription should be active immediately on creation (defaults to true)
        subscribed_events:
          type: array
          minItems: 1
          description: List of event types to subscribe to (at least one event type required)
          items:
            $ref: "#/components/schemas/WebhookEvent"
        description:
          type: string
          description: Optional human-readable description of this webhook's purpose for management and documentation
      example:
        url: https://api.customer.com/webhooks/katana
        enabled: true
        subscribed_events:
          - sales_order.created
          - sales_order.delivered
          - current_inventory.product_out_of_stock
          - manufacturing_order.done
        description: ERP integration webhook for inventory and order sync
    UpdateWebhookRequest:
      type: object
      description: Request payload for updating an existing webhook subscription configuration
      additionalProperties: false
      properties:
        url:
          type: string
          pattern: ^https://.*$
          description: HTTPS endpoint URL where webhook events will be sent (must use HTTPS for security)
        enabled:
          type: boolean
          description: Whether this webhook subscription should be active and receive events
        subscribed_events:
          type: array
          minItems: 1
          description: List of event types to subscribe to (at least one event type required)
          items:
            $ref: "#/components/schemas/WebhookEvent"
        description:
          type: string
          description: Optional human-readable description of this webhook's purpose for management and documentation
      example:
        url: https://api.customer.com/webhooks/katana-v2
        enabled: true
        subscribed_events:
          - sales_order.created
          - sales_order.updated
          - sales_order.delivered
          - current_inventory.product_updated
          - manufacturing_order.done
          - purchase_order.received
        description: Updated ERP integration webhook with expanded event coverage
    Webhook:
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the webhook subscription
            url:
              type: string
              description: HTTPS endpoint URL where webhook events will be sent
            token:
              type: string
              description: |
                Server-generated verification token included with every webhook
                delivery so subscribers can authenticate the payload. Returned as
                a 16-character lowercase hexadecimal string (e.g.
                ``"46aec160c0efe1d6"``).
              pattern: "^[0-9a-f]{16}$"
            enabled:
              type: boolean
              description: Whether this webhook subscription is active and will receive events
            description:
              type:
                - string
                - "null"
              description: Optional human-readable description of this webhook's purpose
            subscribed_events:
              type: array
              description: |-
                List of event types that will trigger this webhook. Known
                values are listed in the ``WebhookEvent`` enum (enforced on
                Create / Update request DTOs), but the read shape stays an
                open string list so newly-released server events deserialize
                without breaking older clients.
              items:
                type: string
        - $ref: "#/components/schemas/UpdatableEntity"
      description: Webhook subscription configuration for real-time event notifications to external systems
      example:
        id: 1
        url: https://api.customer.com/webhooks/katana
        token: 46aec160c0efe1d6
        enabled: true
        description: ERP integration webhook for inventory sync
        subscribed_events:
          - sales_order.created
          - sales_order.updated
          - manufacturing_order.done
          - purchase_order.received
        created_at: "2024-01-10T09:00:00Z"
        updated_at: "2024-01-15T11:30:00Z"
    WebhookListResponse:
      type: object
      description: List of webhook subscriptions configured for event notifications
      properties:
        data:
          type: array
          description: Array of webhook configurations with their subscription details and status
          items:
            $ref: "#/components/schemas/Webhook"
      example:
        data:
          - id: 1
            url: https://api.customer.com/webhooks/katana
            token: 46aec160c0efe1d6
            enabled: true
            description: ERP integration webhook for inventory sync
            subscribed_events:
              - sales_order.created
              - sales_order.updated
              - current_inventory.product_updated
            created_at: "2024-01-10T09:00:00Z"
            updated_at: "2024-01-15T11:30:00Z"
          - id: 2
            url: https://reporting.company.com/katana-events
            token: 73f82127d57a2cea
            enabled: false
            description: Business intelligence reporting
            subscribed_events:
              - manufacturing_order.done
              - purchase_order.received
            created_at: "2024-01-12T14:00:00Z"
            updated_at: "2024-01-14T16:45:00Z"
    WebhookLogsExportRequest:
      type: object
      description: Request parameters for exporting webhook delivery logs for analysis and debugging
      additionalProperties: false
      properties:
        webhook_id:
          type: integer
          description: Filter logs to specific webhook subscription (optional - if not provided, exports all webhook logs)
        event:
          type: string
          description: Filter logs by event type
          enum:
            - sales_order.created
            - sales_order.approved
            - sales_order.ready_for_fulfillment
            - sales_order.packed
            - sales_order.delivered
            - sales_order.invoiced
            - sales_order.updated
            - sales_order.deleted
            - sales_order.availability_updated
            - purchase_order.created
            - purchase_order.approved
            - purchase_order.updated
            - purchase_order.deleted
            - purchase_order.partially_received
            - purchase_order.received
            - purchase_order.billed
            - purchase_order_row.created
            - purchase_order_row.received
            - purchase_order_row.updated
            - purchase_order_row.deleted
            - outsourced_purchase_order.created
            - outsourced_purchase_order.approved
            - outsourced_purchase_order.updated
            - outsourced_purchase_order.deleted
            - outsourced_purchase_order.received
            - outsourced_purchase_order.billed
            - outsourced_purchase_order_row.created
            - outsourced_purchase_order_row.updated
            - outsourced_purchase_order_row.deleted
            - outsourced_purchase_order_row.received
            - outsourced_purchase_order_recipe_row.created
            - outsourced_purchase_order_recipe_row.updated
            - outsourced_purchase_order_recipe_row.deleted
            - manufacturing_order.created
            - manufacturing_order.updated
            - manufacturing_order.deleted
            - manufacturing_order.in_progress
            - manufacturing_order.blocked
            - manufacturing_order.done
            - manufacturing_order_recipe_row.created
            - manufacturing_order_recipe_row.updated
            - manufacturing_order_recipe_row.deleted
            - manufacturing_order_recipe_row.ingredients_in_stock
            - manufacturing_order_operation_row.created
            - manufacturing_order_operation_row.updated
            - manufacturing_order_operation_row.deleted
            - manufacturing_order_operation_row.in_progress
            - manufacturing_order_operation_row.paused
            - manufacturing_order_operation_row.blocked
            - manufacturing_order_operation_row.completed
            - current_inventory.product_updated
            - current_inventory.material_updated
            - current_inventory.product_out_of_stock
            - current_inventory.material_out_of_stock
            - product.created
            - product.updated
            - product.deleted
            - material.created
            - material.updated
            - material.deleted
            - variant.created
            - variant.updated
            - variant.deleted
            - product_recipe_row.created
            - product_recipe_row.deleted
            - bom_row.created
            - bom_row.updated
            - bom_row.deleted
            - product_recipe_row.updated
        status_code:
          type: integer
          description: Filter logs by HTTP status code
        delivered:
          type: boolean
          description: Filter logs by delivery status (true for successful deliveries)
        created_at_min:
          type: string
          description: Minimum creation date for log export range (ISO 8601 format)
        created_at_max:
          type: string
          description: Maximum creation date for log export range (ISO 8601 format)
      example:
        webhook_id: 1
        event: sales_order.created
        status_code: 200
        delivered: true
        created_at_min: "2024-01-10T00:00:00Z"
        created_at_max: "2024-01-15T23:59:59Z"
    WebhookLogsExport:
      type: object
      description: Webhook log export result containing downloadable data for debugging and monitoring webhook delivery
      properties:
        url:
          type: string
          format: uri
          description: Pre-signed download URL for the webhook logs export file (CSV or JSON format)
      example:
        url: https://katana-exports.s3.amazonaws.com/webhook-logs-2024-01-15.csv?expires=1705392000
    MakeToOrderManufacturingOrderRequest:
      description:
        Request to create a manufacturing order directly from a sales order row, linking production to customer
        demand for make-to-order manufacturing.
      type: object
      additionalProperties: false
      required:
        - sales_order_row_id
      properties:
        sales_order_row_id:
          type: number
          description: ID of the sales order row to create a manufacturing order for
        create_subassemblies:
          type: boolean
          default: false
          description: Whether to automatically create manufacturing orders for subassemblies as well
      example:
        sales_order_row_id: 2501
        create_subassemblies: true
    Service:
      description: External service that can be used as part of manufacturing operations or business processes
      allOf:
        - $ref: "#/components/schemas/ArchivableDeletableEntity"
        - type: object
          properties:
            name:
              type: string
              description: The service's unique name
            uom:
              type: string
              description: The unit used to measure the quantity of the service (e.g. pcs, hours)
            category_name:
              type: string
              description: A string used to group similar items for better organization and analysis
            is_sellable:
              type: boolean
              description: Sellable services can be added to Quotes and Sales orders
            type:
              description: Indicating the item type. Service objects are of type "service"
              $ref: "#/components/schemas/ServiceType"
            additional_info:
              type: string
              description: |
                A string attached to the object to add any internal comments, links to external files, additional
                instructions, etc.
            custom_field_collection_id:
              type:
                - integer
                - "null"
              description: ID of the custom field collection associated with this service
            variants:
              type: array
              description: An array of service variant objects
              items:
                $ref: "#/components/schemas/ServiceVariant"
      example:
        id: 1
        name: Service name
        uom: pcs
        category_name: Service
        is_sellable: true
        type: service
        custom_field_collection_id: 1
        additional_info: additional info
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
        deleted_at: null
        archived_at: "2020-10-20T10:37:05.085Z"
        variants:
          - id: 1
            sku: S-2486
            sales_price: null
            default_cost: null
            service_id: 1
            type: service
            created_at: "2020-10-23T10:37:05.085Z"
            updated_at: "2020-10-23T10:37:05.085Z"
            deleted_at: null
            custom_fields:
              - field_name: Power level
                field_value: Strong
    ServiceListResponse:
      description: Response containing a list of services available for purchase orders and operations
      type: object
      properties:
        data:
          type: array
          description: List of service records
          items:
            $ref: "#/components/schemas/Service"
      example:
        data:
          - id: 401
            name: Assembly Service
            uom: hours
            category_name: Manufacturing Services
            is_sellable: true
            type: service
            additional_info: Professional product assembly service
            custom_field_collection_id: 1
            variants:
              - id: 4001
                sku: ASSM-001
                sales_price: 75.0
                default_cost: 50.0
                service_id: 401
                type: service
                custom_fields:
                  - field_name: Skill Level
                    field_value: Expert
                created_at: "2023-10-01T09:00:00Z"
                updated_at: "2023-10-01T09:00:00Z"
                deleted_at: null
            created_at: "2023-10-01T09:00:00Z"
            updated_at: "2023-10-01T09:00:00Z"
            archived_at: null
            deleted_at: null
    CreateServiceRequest:
      description: Request payload for creating a new service with variants and specifications
      type: object
      additionalProperties: false
      required:
        - name
        - variants
      properties:
        name:
          type: string
          description: The service's unique name
        uom:
          type: string
          maxLength: 7
          description: The unit used to measure the quantity of the service (e.g. pcs, hours)
        category_name:
          type: string
          description: A string used to group similar items for better organization and analysis
        additional_info:
          type: string
          description: |
            A string attached to the object to add any internal comments, links to external files, additional
            instructions, etc.
        is_sellable:
          type: boolean
          description: Sellable services can be added to Quotes and Sales orders
        custom_field_collection_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: ID of the custom field collection to associate with this service
        variants:
          type: array
          minItems: 1
          maxItems: 1
          description: Array containing exactly one service variant object to create
          items:
            $ref: "#/components/schemas/CreateServiceVariantRequest"
      example:
        name: Assembly Service
        uom: hours
        category_name: Manufacturing Services
        additional_info: Professional product assembly service
        is_sellable: true
        custom_field_collection_id: 1
        variants:
          - sku: ASSM-001
            sales_price: 75.0
            default_cost: 50.0
            custom_fields:
              - field_name: Skill Level
                field_value: Expert
    CreateServiceVariantRequest:
      description: Request payload for creating a service variant with pricing and custom fields
      type: object
      additionalProperties: false
      properties:
        sku:
          type: string
          description: Optional unique service code
        sales_price:
          type:
            - number
            - "null"
          maximum: 100000000000
          minimum: 0
          description: Default sales price (excluding tax)
        default_cost:
          type:
            - number
            - "null"
          maximum: 100000000000
          minimum: 0
          description: Default cost which is used to calculate profit
        custom_fields:
          description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
          anyOf:
            - type: array
              maxItems: 3
              items:
                type: object
                additionalProperties: false
                required:
                  - field_name
                  - field_value
                properties:
                  field_name:
                    type: string
                    maxLength: 40
                    description: Custom field name
                  field_value:
                    type: string
                    maxLength: 100
                    description: Custom field value
                title: CustomFieldsItem
            - type: object
              propertyNames:
                pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
              additionalProperties:
                type:
                  - string
                  - number
                  - boolean
                  - 'null'
      example:
        sku: ASSM-001
        sales_price: 75.0
        default_cost: 50.0
        custom_fields:
          - field_name: Skill Level
            field_value: Expert

    UpdateServiceRequest:
      description: Request payload for updating an existing service's properties and specifications
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          description: The service's unique name
        uom:
          type: string
          maxLength: 7
          description: The unit used to measure the quantity of the service (e.g. pcs, hours)
        category_name:
          type: string
          description: A string used to group similar items for better organization and analysis
        additional_info:
          type: string
          description: |
            A string attached to the object to add any internal comments, links to external files, additional
            instructions, etc.
        is_sellable:
          type: boolean
          description: Sellable services can be added to Quotes and Sales orders
        is_archived:
          type: boolean
          description: Whether the service is archived or not
        sales_price:
          type:
            - number
            - "null"
          maximum: 100000000000
          minimum: 0
          description: Default sales price (excluding tax)
        default_cost:
          type:
            - number
            - "null"
          maximum: 100000000000
          minimum: 0
          description: Default cost which is used to calculate profit
        sku:
          type: string
          description: A unique service code for the primary variant
        custom_field_collection_id:
          type:
            - integer
            - "null"
          maximum: 2147483647
          description: ID of the custom field collection to associate with this service
        custom_fields:
          description: Custom field values on the variant. Served in one of two representations depending on the account — the legacy `{field_name, field_value}` array, or an object keyed by custom field definition id. See the `X-Custom-Fields-Format` header for how the representation is chosen, and note that a single request must not mix the two.
          anyOf:
            - type: object
              propertyNames:
                pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
              additionalProperties:
                type:
                  - string
                  - number
                  - boolean
                  - 'null'
            - type: array
              maxItems: 3
              items:
                $ref: '#/components/schemas/CustomFieldValue'

      example:
        name: Updated Assembly Service
        uom: hours
        category_name: Professional Services
        is_sellable: true
        is_archived: false
        sales_price: 85.0
        default_cost: 55.0
        sku: ASSM-001-UPD
        additional_info: Updated professional product assembly service
        custom_field_collection_id: 1
    DemandForecastPeriod:
      description: A single demand forecast period with stock and demand quantities
      type: object
      properties:
        period_start:
          type: string
          format: date-time
          description: Period start date in ISO 8601 format (inclusive)
        period_end:
          type: string
          format: date-time
          description: Period end date in ISO 8601 format (inclusive)
        in_stock:
          type: string
          description: Calculated stock level at the end of the period
        expected:
          type: string
          description: Expected incoming quantity during the period
        committed:
          type: string
          description: Total forecasted demand quantity for the period
      required:
        - period_start
        - period_end
      example:
        period_start: "2024-01-01T00:00:00.000Z"
        period_end: "2024-01-06T23:59:59.999Z"
        in_stock: "125"
        expected: "50"
        committed: "25"
    DemandForecastResponse:
      description: Demand forecast for a variant in a specific location with period breakdowns
      type: object
      properties:
        variant_id:
          type: integer
          description: ID of the variant this forecast is for
        location_id:
          type: integer
          description: ID of the location this forecast is for
        in_stock:
          type: string
          description: Current in-stock quantity for this variant at this location
        periods:
          type: array
          description: Array of forecast periods with stock and demand data
          items:
            $ref: "#/components/schemas/DemandForecastPeriod"
      required:
        - variant_id
        - location_id
      example:
        variant_id: 1
        location_id: 1
        in_stock: "100"
        periods:
          - period_start: "2024-01-01T00:00:00.000Z"
            period_end: "2024-01-06T23:59:59.999Z"
            in_stock: "125"
            expected: "50"
            committed: "25"
    CreateDemandForecastRequest:
      description: Request payload for adding planned demand forecast periods for a variant in a location
      type: object
      additionalProperties: false
      required:
        - variant_id
        - location_id
        - periods
      properties:
        variant_id:
          type: integer
          maximum: 2147483647
          description: ID of the variant to add forecast for
        location_id:
          type: integer
          maximum: 2147483647
          description: ID of the location to add forecast for
        periods:
          type: array
          minItems: 1
          maxItems: 100
          description: Array of forecast periods to add
          items:
            type: object
            additionalProperties: false
            required:
              - period_start
              - period_end
              - committed
            properties:
              period_start:
                type: string
                format: date-time
                description: Period start date in ISO 8601 format (inclusive)
              period_end:
                type: string
                format: date-time
                description: Period end date in ISO 8601 format (inclusive)
              committed:
                type: string
                description: Total forecasted demand quantity for the period
      example:
        variant_id: 1
        location_id: 1
        periods:
          - period_start: "2024-01-01T00:00:00.000Z"
            period_end: "2024-01-06T23:59:59.999Z"
            committed: "25"
    ClearDemandForecastRequest:
      description: Request payload for clearing planned demand forecast periods for a variant in a location
      type: object
      additionalProperties: false
      required:
        - variant_id
        - location_id
        - periods
      properties:
        variant_id:
          type: integer
          maximum: 2147483647
          description: ID of the variant to clear forecast for
        location_id:
          type: integer
          maximum: 2147483647
          description: ID of the location to clear forecast for
        periods:
          type: array
          minItems: 1
          maxItems: 100
          description: Array of forecast periods to clear
          items:
            type: object
            additionalProperties: false
            required:
              - period_start
              - period_end
            properties:
              period_start:
                type: string
                format: date-time
                description: Period start date in ISO 8601 format (inclusive)
              period_end:
                type: string
                format: date-time
                description: Period end date in ISO 8601 format (inclusive)
      example:
        variant_id: 1
        location_id: 1
        periods:
          - period_start: "2024-01-01T00:00:00.000Z"
            period_end: "2024-01-06T23:59:59.999Z"
    Customer:
      description: Customer entity representing individuals or companies that purchase products or services
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            name:
              type: string
              description: Customer display name, either individual name or company name
            first_name:
              type:
                - string
                - "null"
              description: Customer's first name for individual contacts
            last_name:
              type:
                - string
                - "null"
              description: Customer's last name for individual contacts
            company:
              type:
                - string
                - "null"
              description: Company name for business customers
            email:
              type:
                - string
                - "null"
              description: Primary email address for communication and order notifications
            phone:
              type:
                - string
                - "null"
              description: Primary phone number for customer contact
            comment:
              type:
                - string
                - "null"
              description: Internal notes and comments about the customer
            currency:
              type: string
              description: Default currency code for all transactions with this customer
            reference_id:
              type:
                - string
                - "null"
              description: External reference ID for integration with other systems
            category:
              type:
                - string
                - "null"
              description: Customer category for segmentation and reporting
            discount_rate:
              type:
                - number
                - "null"
              description: Default discount percentage applied to all orders (0-100)
            default_billing_id:
              type:
                - integer
                - "null"
              description: ID of the default billing address for this customer
            default_shipping_id:
              type:
                - integer
                - "null"
              description: ID of the default shipping address for this customer
            addresses:
              type: array
              description: Complete list of billing and shipping addresses for this customer
              items:
                $ref: "#/components/schemas/CustomerAddress"
          required:
            - name
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 2001
        name: Kitchen Pro Restaurants
        first_name: Sarah
        last_name: Johnson
        company: Kitchen Pro Restaurants Ltd
        email: orders@kitchenpro.com
        phone: +1-555-0123
        comment: Preferred customer - high volume orders
        currency: USD
        reference_id: KPR-2024-001
        category: Restaurant Chain
        discount_rate: 5.0
        default_billing_id: 3001
        default_shipping_id: 3002
        created_at: "2024-01-10T09:00:00Z"
        updated_at: "2024-01-15T14:30:00Z"
        deleted_at: null
    CustomerAddress:
      description: Customer address for billing and shipping purposes with complete contact information
      allOf:
        - type: object
          properties:
            customer_id:
              type: integer
              description: ID of the customer this address belongs to
            entity_type:
              $ref: "#/components/schemas/AddressEntityType"
            default:
              type: boolean
              description: Whether this is the default address for the specified entity type
            first_name:
              type:
                - string
                - "null"
              description: First name for the contact person at this address
            last_name:
              type:
                - string
                - "null"
              description: Last name for the contact person at this address
            company:
              type:
                - string
                - "null"
              description: Company name for business addresses
            phone:
              type:
                - string
                - "null"
              description: Phone number for this address location
            line_1:
              type:
                - string
                - "null"
              description: Primary address line (street address, building number)
            line_2:
              type:
                - string
                - "null"
              description: Secondary address line (apartment, suite, floor)
            city:
              type:
                - string
                - "null"
              description: City or locality name
            state:
              type:
                - string
                - "null"
              description: State, province, or region
            zip:
              type:
                - string
                - "null"
              description: Postal code or ZIP code
            country:
              type:
                - string
                - "null"
              description: Country name or country code
          required:
            - customer_id
            - entity_type
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3001
        customer_id: 2001
        entity_type: billing
        default: true
        first_name: Sarah
        last_name: Johnson
        company: Kitchen Pro Restaurants Ltd
        phone: +1-555-0123
        line_1: 123 Restaurant Row
        line_2: Suite 200
        city: Chicago
        state: IL
        zip: "60601"
        country: US
        created_at: "2024-01-10T09:15:00Z"
        updated_at: "2024-01-10T09:15:00Z"
    CustomerListResponse:
      description: Response containing a list of customers with pagination metadata
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Customer"
          description: Array of customer entities
      example:
        data:
          - id: 2001
            name: Kitchen Pro Restaurants
            first_name: Sarah
            last_name: Johnson
            company: Kitchen Pro Restaurants Ltd
            email: orders@kitchenpro.com
            phone: +1-555-0123
            comment: Preferred customer - high volume orders
            currency: USD
            reference_id: KPR-2024-001
            category: Restaurant Chain
            discount_rate: 5.0
            default_billing_id: 3001
            default_shipping_id: 3002
            created_at: "2024-01-10T09:00:00Z"
            updated_at: "2024-01-15T14:30:00Z"
            deleted_at: null
          - id: 2002
            name: Baker's Choice Bakery
            first_name: Michael
            last_name: Chen
            company: Baker's Choice Bakery
            email: mike@bakerschoice.com
            phone: +1-555-0124
            comment: Weekly wholesale orders
            currency: USD
            reference_id: BC-2024-002
            category: Bakery
            discount_rate: 3.0
            default_billing_id: 3003
            default_shipping_id: 3004
            created_at: "2024-01-12T10:30:00Z"
            updated_at: "2024-01-18T16:45:00Z"
            deleted_at: null
    CreateCustomerRequest:
      description: Request payload for creating a new customer with contact and business information
      type: object
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        name:
          type: string
          description: Customer display name, either individual name or company name
        first_name:
          type:
            - string
            - "null"
          description: Customer's first name for individual contacts
        last_name:
          type:
            - string
            - "null"
          description: Customer's last name for individual contacts
        company:
          type:
            - string
            - "null"
          description: Company name for business customers
        email:
          type:
            - string
            - "null"
          format: email
          description: Primary email address for communication and order notifications
        phone:
          type:
            - string
            - "null"
          description: Primary phone number for customer contact
        comment:
          type:
            - string
            - "null"
          description: Internal notes and comments about the customer
        currency:
          type:
            - string
            - "null"
          description: Default currency code for all transactions with this customer
        reference_id:
          type:
            - string
            - "null"
          description: External reference ID for integration with other systems
        category:
          type:
            - string
            - "null"
          description: Customer category for segmentation and reporting
        discount_rate:
          type:
            - number
            - "null"
          description: Default discount percentage applied to all orders (0-100)
        addresses:
          type: array
          description: Customer addresses to create with the customer
          items:
            type: object
            properties:
              entity_type:
                $ref: "#/components/schemas/AddressEntityType"
              first_name:
                type: string
              last_name:
                type: string
              company:
                type: string
              phone:
                type: string
              line_1:
                type: string
              line_2:
                type: string
              city:
                type: string
              state:
                type: string
              zip:
                type: string
              country:
                type: string
      required:
        - name

      example:
        name: Gourmet Bistro Group
        first_name: Elena
        last_name: Rodriguez
        company: Gourmet Bistro Group Inc
        email: procurement@gourmetbistro.com
        phone: +1-555-0125
        comment: Premium restaurant chain - priority orders
        currency: USD
        reference_id: GBG-2024-003
        category: Fine Dining
        discount_rate: 7.5
    UpdateCustomerRequest:
      description: Request payload for updating an existing customer with contact and business information
      type: object
      additionalProperties: false
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        name:
          type: string
          description: Customer display name, either individual name or company name
        first_name:
          type:
            - string
            - "null"
          description: Customer's first name for individual contacts
        last_name:
          type:
            - string
            - "null"
          description: Customer's last name for individual contacts
        company:
          type:
            - string
            - "null"
          description: Company name for business customers
        email:
          type:
            - string
            - "null"
          format: email
          description: Primary email address for communication and order notifications
        phone:
          type:
            - string
            - "null"
          description: Primary phone number for customer contact
        comment:
          type:
            - string
            - "null"
          description: Internal notes and comments about the customer
        currency:
          type:
            - string
            - "null"
          description: Default currency code for all transactions with this customer
        reference_id:
          type:
            - string
            - "null"
          description: External reference ID for integration with other systems
        category:
          type:
            - string
            - "null"
          description: Customer category for segmentation and reporting
        discount_rate:
          type:
            - number
            - "null"
          description: Default discount percentage applied to all orders (0-100)
        default_shipping_id:
          type:
            - integer
            - "null"
          description: Default shipping address ID for this customer

      example:
        name: Gourmet Bistro Group
        first_name: Elena
        last_name: Rodriguez
        company: Gourmet Bistro Group Inc
        email: procurement@gourmetbistro.com
        phone: +1-555-0125
        comment: Premium restaurant chain - priority orders
        currency: USD
        reference_id: GBG-2024-003
        category: Fine Dining
        discount_rate: 7.5
        default_shipping_id: 2
    SalesOrder:
      description: Sales order representing a customer's request to purchase products with delivery and payment terms
      allOf:
        - $ref: "#/components/schemas/BaseEntity"
        - type: object
          properties:
            customer_id:
              type: integer
              description: Unique identifier of the customer placing the order
            order_no:
              type: string
              description: Unique order number for tracking and reference purposes
            source:
              type:
                - string
                - "null"
              description: Source system or channel where the order originated (e.g., Shopify, manual entry)
            order_created_date:
              type: string
              format: date-time
              description: Date and time when the sales order was created in the system
            delivery_date:
              type:
                - string
                - "null"
              format: date-time
              description: Requested or promised delivery date for the order
            picked_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date when items were picked from inventory for shipment
            location_id:
              type: integer
              description: Unique identifier of the fulfillment location for this order
            status:
              description: Current fulfillment status of the sales order
              $ref: "#/components/schemas/SalesOrderStatus"
            currency:
              type: string
              pattern: ^[A-Z]{3}$
              description: Currency code for the order pricing (ISO 4217 format)
            conversion_rate:
              type:
                - number
                - "null"
              description: Exchange rate used to convert order currency to base company currency
            conversion_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date when the currency conversion rate was applied
            invoicing_status:
              anyOf:
                - $ref: "#/components/schemas/SalesOrderInvoicingStatus"
                - type: "null"
              description: |
                Order-level invoicing status, rolled up from the underlying
                fulfillment-level statuses. Uses camelCase wire values
                (``notInvoiced`` / ``partiallyInvoiced`` / ``invoiced``) —
                **not** the SCREAMING_SNAKE_CASE values used by
                ``SalesOrderFulfillment.invoice_status``. ``null`` when the
                order has no fulfillments yet.
            total:
              type: number
              description: Total order amount in the order currency
            total_in_base_currency:
              type: number
              description: Total order amount converted to the company's base currency
            additional_info:
              type:
                - string
                - "null"
              description: Additional notes or instructions for the sales order
            customer_ref:
              type:
                - string
                - "null"
              description: Customer's reference number or purchase order number
            sales_order_rows:
              type: array
              description: Line items included in the sales order with product details and quantities
              items:
                $ref: "#/components/schemas/SalesOrderRow"
            ecommerce_order_type:
              type:
                - string
                - "null"
              description: >-
                Source ecommerce platform for orders imported from a native Katana
                integration, as the exact camelCase literal (`shopify`,
                `wooCommerce`, or `bigCommerce`); `null` otherwise. Free-string on
                the wire and create-only — the literal is stored verbatim and
                cannot be changed via update.
            ecommerce_store_name:
              type:
                - string
                - "null"
              description: >-
                Storefront host or slug of the source integration — a full host
                for Shopify/WooCommerce (e.g. `acme.myshopify.com`) or a bare
                subdomain slug for BigCommerce; `null` when the order is not from a
                native integration. Create-only — like the other `ecommerce_*`
                fields it cannot be changed via update.
            ecommerce_order_id:
              type:
                - string
                - "null"
              description: >-
                The source platform's own order identifier (e.g. `19433769`), as a
                string; `null` when the order is not from a native ecommerce
                integration. Create-only — like the other `ecommerce_*` fields it
                cannot be changed via update.
            product_availability:
              anyOf:
                - $ref: "#/components/schemas/ProductAvailability"
                - type: "null"
            product_expected_date:
              type:
                - string
                - "null"
              format: date-time
              description: Expected date when products will be available for fulfillment
            ingredient_availability:
              anyOf:
                - $ref: "#/components/schemas/IngredientAvailability"
                - type: "null"
            ingredient_expected_date:
              type:
                - string
                - "null"
              format: date-time
              description: Expected date when ingredients will be available for production
            production_status:
              anyOf:
                - $ref: "#/components/schemas/SalesOrderProductionStatus"
                - type: "null"
              description: Current status of production for items in this order
            tracking_number:
              type:
                - string
                - "null"
              description: Shipping carrier tracking number for package tracking
            tracking_number_url:
              type:
                - string
                - "null"
              description: URL link to track the shipment on carrier website
            billing_address_id:
              type:
                - integer
                - "null"
              description: Reference to the customer address used for billing
            shipping_address_id:
              type:
                - integer
                - "null"
              description: Reference to the customer address used for shipping
            linked_manufacturing_order_id:
              type:
                - integer
                - "null"
              description: ID of the linked manufacturing order if this sales order has associated production
            shipping_fee:
              anyOf:
                - $ref: "#/components/schemas/SalesOrderShippingFee"
                - type: "null"
                - type: object
                  maxProperties: 0
                  additionalProperties: false
              description: Shipping fee details, null, or an empty object when no fee is set
            addresses:
              type: array
              description: Complete address information for billing and shipping
              items:
                $ref: "#/components/schemas/SalesOrderAddress"
            custom_fields:
              type:
                - object
                - "null"
              additionalProperties: true
              description: |
                Custom field values for the sales order, keyed by the
                definition ``id`` (UUID) — the ``id`` returned by
                ``GET /custom_field_definitions``, not the field label.
                Each value matches the definition's ``field_type``: string
                for ``shortText`` / ``url``, number for ``number``, boolean
                for ``boolean``, a ``YYYY-MM-DD`` string for ``date``, or
                the integer choice ``id`` for ``singleSelect``. Example
                (keys are definition UUIDs):
                ``{"0c8f1d6e-…": "EMEA", "7a21b4c2-…": 2}`` — a
                ``shortText`` value and a ``singleSelect`` choice ``id``.
                ``null`` when no values are set. Values for soft-deleted
                definitions are stripped from read responses. Keys are
                tenant-specific, so the schema declares
                ``additionalProperties: true`` rather than enumerating
                them.
          required:
            - customer_id
            - order_no
            - location_id
            - status
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 2001
        customer_id: 1501
        order_no: SO-2024-001
        source: Shopify
        order_created_date: "2024-01-15T10:00:00Z"
        delivery_date: "2024-01-22T14:00:00Z"
        picked_date: null
        location_id: 1
        status: PACKED
        currency: USD
        conversion_rate: 1.0
        conversion_date: "2024-01-15T10:00:00Z"
        invoicing_status: invoiced
        total: 1250.0
        total_in_base_currency: 1250.0
        additional_info: Customer requested expedited delivery
        customer_ref: CUST-REF-2024-001
        sales_order_rows:
          - id: 2501
            quantity: 2
            variant_id: 2101
            tax_rate_id: 301
            location_id: 1
            product_availability: IN_STOCK
            product_expected_date: null
            price_per_unit: "599.9900000000"
            price_per_unit_in_base_currency: 599.99
            total: 1199.98
            total_in_base_currency: 1199.98
            cogs_value: "400.0000000000"
            created_at: "2024-01-15T10:00:00Z"
            updated_at: "2024-01-15T10:00:00Z"
        ecommerce_order_type: shopify
        ecommerce_store_name: acme.myshopify.com
        ecommerce_order_id: "19433769"
        product_availability: IN_STOCK
        product_expected_date: null
        ingredient_availability: IN_STOCK
        ingredient_expected_date: null
        production_status: NOT_APPLICABLE
        tracking_number: UPS1234567890
        tracking_number_url: https://www.ups.com/track?track=UPS1234567890
        billing_address_id: 1201
        shipping_address_id: 1202
        addresses:
          - id: 1201
            sales_order_id: 2001
            entity_type: billing
            first_name: Sarah
            last_name: Johnson
            company: Johnson's Restaurant
            address_line_1: 123 Main Street
            city: Portland
            state: OR
            zip: "97201"
            country: US
        created_at: "2024-01-15T10:00:00Z"
        updated_at: "2024-01-20T16:30:00Z"
    SalesOrderRow:
      description:
        Individual line item within a sales order representing a specific product variant, quantity, pricing, and
        delivery details
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the sales order row
            sales_order_id:
              type: integer
              description: ID of the sales order this row belongs to
            quantity:
              type: number
              description: Ordered quantity of the product variant
            variant_id:
              type: integer
              description: ID of the product variant being ordered
            tax_rate_id:
              type:
                - integer
                - "null"
              description: ID of the tax rate applied to this line item
            tax_rate:
              type:
                - number
                - "null"
              description: Tax rate percentage applied to this line item
            location_id:
              type:
                - integer
                - "null"
              description: Location where the product should be picked from
            product_availability:
              description: Current availability status of the product for this order row
              anyOf:
                - $ref: "#/components/schemas/ProductAvailability"
                - type: "null"
            product_expected_date:
              type:
                - string
                - "null"
              format: date-time
              description: Expected date when the product will be available if not currently in stock
            price_per_unit:
              type: string
              description: Selling price per unit in the order currency
            price_per_unit_in_base_currency:
              type: number
              description: Selling price per unit converted to the base company currency
            total:
              type: number
              description: Total line amount (quantity * price_per_unit) in order currency
            total_in_base_currency:
              type: number
              description: Total line amount converted to the base company currency
            total_discount:
              type:
                - string
                - "null"
              description: Discount amount applied to this line item
            cogs_value:
              type:
                - string
                - "null"
              description: Cost of goods sold value for this line item, null when not yet computed
            attributes:
              type: array
              description: Custom attributes associated with this sales order row
              items:
                type: object
                properties:
                  key:
                    type: string
                    description: Attribute name/key
                  value:
                    type: string
                    description: Attribute value
            batch_transactions:
              type: array
              description: Batch allocations for this order row when using batch tracking
              items:
                type: object
                properties:
                  batch_id:
                    type:
                      - integer
                      - "null"
                    description: ID of the batch being allocated
                  quantity:
                    type: number
                    description: Quantity allocated from this batch
            serial_numbers:
              type: array
              description: Serial numbers allocated to this order row for serialized products
              items:
                type: integer
            serial_number_transactions:
              type: array
              description: |-
                Audit trail of serial-number actions on this row. Each entry records
                whether a serial number was added (``quantity: 1``) or removed
                (``quantity: 0``). Use this for incremental updates; ``serial_numbers``
                reflects the resulting current state.
              items:
                type: object
                properties:
                  serial_number_id:
                    type: integer
                    description: ID of the serial number for the fulfilled item
                  quantity:
                    type: integer
                    enum:
                      - 0
                      - 1
                    description: "1 to add the serial number, 0 to remove it"
                required:
                  - serial_number_id
            linked_manufacturing_order_id:
              type:
                - integer
                - "null"
              description: ID of the manufacturing order linked to this sales order row for make-to-order items
            conversion_rate:
              type:
                - number
                - "null"
              description: Currency conversion rate used for this row
            conversion_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date when the currency conversion rate was applied
            custom_fields:
              type:
                - object
                - "null"
              additionalProperties: true
              description: |
                Row-level custom field values, keyed by the
                definition ``id`` (UUID) — the ``id`` returned by
                ``GET /custom_field_definitions``, not the field label.
                Each value matches the definition's ``field_type``: string
                for ``shortText`` / ``url``, number for ``number``, boolean
                for ``boolean``, a ``YYYY-MM-DD`` string for ``date``, or
                the integer choice ``id`` for ``singleSelect``. ``null``
                when no values are set on the row. Values for soft-deleted
                definitions are stripped from read responses. Keys are
                tenant-specific, so the schema declares
                ``additionalProperties: true`` rather than enumerating
                them.
          required:
            - id
            - quantity
            - variant_id
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 2501
        quantity: 2
        variant_id: 2101
        tax_rate_id: 301
        location_id: 1
        product_availability: IN_STOCK
        product_expected_date: null
        price_per_unit: "599.9900000000"
        price_per_unit_in_base_currency: 599.99
        total: 1199.98
        total_in_base_currency: 1199.98
        cogs_value: "400.0000000000"
        attributes:
          - key: engrave_text
            value: Johnson's Kitchen
          - key: gift_wrap
            value: "true"
        batch_transactions:
          - batch_id: 1801
            quantity: 2.0
        serial_numbers:
          - 10001
          - 10002
        linked_manufacturing_order_id: null
        conversion_rate: 1.0
        conversion_date: "2024-01-15T10:00:00Z"
        created_at: "2024-01-15T10:00:00Z"
        updated_at: "2024-01-15T10:00:00Z"
    SalesOrderAddress:
      description: |
        Billing or shipping address associated with a sales order, containing complete contact and location information
      allOf:
        - type: object
          properties:
            sales_order_id:
              type: integer
              description: ID of the sales order this address belongs to
            entity_type:
              $ref: "#/components/schemas/AddressEntityType"
            first_name:
              type:
                - string
                - "null"
              description: First name of the contact person
            last_name:
              type:
                - string
                - "null"
              description: Last name of the contact person
            company:
              type:
                - string
                - "null"
              description: Company name for business deliveries
            phone:
              type:
                - string
                - "null"
              description: Contact phone number for delivery coordination
            line_1:
              type:
                - string
                - "null"
              description: Primary address line (street address)
            line_2:
              type:
                - string
                - "null"
              description: Secondary address line (apartment, suite, etc.)
            city:
              type:
                - string
                - "null"
              description: City name
            state:
              type:
                - string
                - "null"
              description: State or province
            zip:
              type:
                - string
                - "null"
              description: Postal or ZIP code
            country:
              type:
                - string
                - "null"
              description: Country code (e.g., US, CA, GB)
          required:
            - sales_order_id
            - entity_type
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 1201
        sales_order_id: 2001
        entity_type: shipping
        first_name: Sarah
        last_name: Johnson
        company: Johnson's Restaurant
        phone: +1-503-555-0123
        line_1: 123 Main Street
        line_2: Suite 4B
        city: Portland
        state: OR
        zip: "97201"
        country: US
        created_at: "2024-01-15T10:00:00Z"
        updated_at: "2024-01-15T10:00:00Z"
    CreateSalesOrderRowRequest:
      description: Request payload for creating a new sales order row (line item)
      type: object
      additionalProperties: false
      required:
        - sales_order_id
        - variant_id
        - quantity
      properties:
        sales_order_id:
          type: integer
          description: ID of the sales order this row belongs to
        variant_id:
          type: integer
          description: ID of the product variant being ordered
        quantity:
          type: number
          description: Ordered quantity of the product variant
        price_per_unit:
          type: number
          description: Selling price per unit in the order currency
        tax_rate_id:
          type: integer
          description: ID of the tax rate applied to this line item
        location_id:
          type: integer
          description: Location where the product should be picked from
        attributes:
          type: array
          description: Custom attributes for this line item
          items:
            type: object
            properties:
              key:
                type: string
                description: Attribute name/key
              value:
                type: string
                description: Attribute value
        total_discount:
          type: number
          description: Total discount amount applied to this line item
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: |
            Row-level custom field values, keyed by the
            definition ``id`` (UUID) — the ``id`` returned by
            ``GET /custom_field_definitions``, not the field label. Each
            value matches the definition's ``field_type``: string for
            ``shortText`` / ``url``, number for ``number``, boolean for
            ``boolean``, a ``YYYY-MM-DD`` string for ``date``, or the
            integer choice ``id`` for ``singleSelect``. Keys are
            tenant-specific, so the schema declares
            ``additionalProperties: true`` rather than enumerating them.
      example:
        sales_order_id: 2001
        variant_id: 2101
        quantity: 2
        price_per_unit: 599.99
        tax_rate_id: 301
        location_id: 1
    UpdateSalesOrderRowRequest:
      description: Request payload for updating an existing sales order row
      type: object
      additionalProperties: false
      properties:
        variant_id:
          type: integer
          description: ID of the product variant being ordered
        quantity:
          type: number
          description: Ordered quantity of the product variant
        price_per_unit:
          type: number
          description: Selling price per unit in the order currency
        tax_rate_id:
          type: integer
          description: ID of the tax rate applied to this line item
        location_id:
          type: integer
          description: Location where the product should be picked from
        total_discount:
          type: number
          description: Total discount amount applied to this line item
        batch_transactions:
          type: array
          description: Batch transactions for inventory tracking
          items:
            $ref: "#/components/schemas/SalesOrderRowBatchTransactionUpdate"
        serial_number_transactions:
          type: array
          description: Serial number transactions for tracking
          items:
            type: object
            properties:
              serial_number_id:
                type: integer
              quantity:
                type: number
        traceability:
          type: array
          description: >-
            Unified batch/serial/bin allocations for this row. The current way
            to attach serial-tracked units to a sales order row — an
            alternative to `serial_number_transactions` that also carries batch
            and bin context per allocation.
          items:
            $ref: "#/components/schemas/TraceabilityRequest"
        attributes:
          type: array
          description: Custom attributes for this line item
          items:
            type: object
            properties:
              key:
                type: string
                description: Attribute name/key
              value:
                type: string
                description: Attribute value
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: |
            Row-level custom field values, keyed by the
            definition ``id`` (UUID) — the ``id`` returned by
            ``GET /custom_field_definitions``, not the field label. Each
            value matches the definition's ``field_type``: string for
            ``shortText`` / ``url``, number for ``number``, boolean for
            ``boolean``, a ``YYYY-MM-DD`` string for ``date``, or the
            integer choice ``id`` for ``singleSelect``.

            On ``PATCH`` the object is **merged** with the existing values,
            not replaced:

            - omit the ``custom_fields`` key — existing values unchanged;
            - ``{"<id>": value}`` — that key is set / overwritten, all
              other keys kept;
            - ``null`` — all custom field values on the row are cleared.

            Keys are tenant-specific, so the schema declares
            ``additionalProperties: true`` rather than enumerating them.
      example:
        quantity: 3
        price_per_unit: 549.99
    SearchScalarValue:
      description: |
        A scalar filter value used in search ``where`` predicates — the
        bare-equality value and the operand type inside
        ``SearchComparator`` operator objects. Covers the full range of
        Katana field value types: string (max 256 chars), number, boolean,
        or ``null``. Note: the pydantic generator emits the ``str`` branch
        as a separate ``RootModel[str]`` class (``SearchScalarValue1``)
        rather than producing a single named union — ``SearchScalarValue1``
        is the string branch only, not the full union.
      anyOf:
        - type: string
          maxLength: 256
        - type: number
        - type: boolean
        - type: "null"
    SearchComparator:
      description: |
        Operator object for a search ``where`` predicate. Supply this only
        when you need something other than equality — for equality, pass a
        bare ``SearchScalarValue`` instead. Only the operators listed below
        are accepted; the server rejects any other key with 422.
      type: object
      additionalProperties: false
      properties:
        neq:
          $ref: "#/components/schemas/SearchScalarValue"
          description: Not equal.
        gt:
          $ref: "#/components/schemas/SearchScalarValue"
          description: Greater than.
        gte:
          $ref: "#/components/schemas/SearchScalarValue"
          description: Greater than or equal.
        lt:
          $ref: "#/components/schemas/SearchScalarValue"
          description: Less than.
        lte:
          $ref: "#/components/schemas/SearchScalarValue"
          description: Less than or equal.
        inq:
          type: array
          maxItems: 100
          description: Value is in this list (max 100 entries).
          items:
            $ref: "#/components/schemas/SearchScalarValue"
        nin:
          type: array
          maxItems: 100
          description: Value is not in this list (max 100 entries).
          items:
            $ref: "#/components/schemas/SearchScalarValue"
        between:
          type: array
          minItems: 2
          maxItems: 2
          description: Inclusive range ``[low, high]``.
          items:
            $ref: "#/components/schemas/SearchScalarValue"
        like:
          type: string
          maxLength: 256
          description: |
            Pattern match, case-sensitive. ``%`` matches any sequence,
            ``_`` matches any single character.
        ilike:
          type: string
          maxLength: 256
          description: Pattern match, case-insensitive (see ``like``).
    CustomerSearchFilter:
      description: |
        Filter clause for ``POST /customers/search``. Only the fields listed
        here may appear; unknown fields are rejected with 422. Custom field
        values are addressable via ``custom_fields.<uuid>`` keys.
      type: object
      additionalProperties: true
      properties:
        and:
          type: array
          description: Logical AND - every nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        or:
          type: array
          description: Logical OR - at least one nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        category:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Customer category for segmentation and reporting"
        comment:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Internal notes and comments about the customer"
        company:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Company name for business customers"
        created_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the record was created."
        currency:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Default currency code for all transactions with this customer"
        default_billing_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ID of the default billing address for this customer"
        default_shipping_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ID of the default shipping address for this customer"
        email:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Primary email address for communication and order notifications"
        first_name:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Customer's first name for individual contacts"
        id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Record id."
        last_name:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Customer's last name for individual contacts"
        name:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Customer display name, either individual name or company name"
        phone:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Primary phone number for customer contact"
        reference_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "External reference ID for integration with other systems"
        updated_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the record was last updated."

    VariantSearchFilter:
      description: |
        Filter clause for ``POST /variants/search``. Only the fields listed
        here may appear; unknown fields are rejected with 422. Custom field
        values are addressable via ``custom_fields.<uuid>`` keys.
      type: object
      additionalProperties: true
      properties:
        and:
          type: array
          description: Logical AND - every nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        or:
          type: array
          description: Logical OR - at least one nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        abc_classification:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ABC inventory classification."
        created_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ISO 8601 timestamp the variant was created."
        id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Variant id."
        internal_barcode:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Internal barcode."
        item_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Id of the product, material, or service this variant belongs to."
        item_type:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Kind of item the variant belongs to."
        lead_time:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Lead time in days."
        minimum_order_quantity:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Minimum order quantity."
        purchase_price:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Purchase price."
        registered_barcode:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Registered (GTIN/EAN/UPC) barcode."
        sales_price:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Sales price."
        sku:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Stock keeping unit."
        supplier_item_codes:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Supplier item code."
        updated_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ISO 8601 timestamp the variant was last updated."

    ManufacturingOrderSearchFilter:
      description: |
        Filter clause for ``POST /manufacturing_orders/search``. Only the fields listed
        here may appear; unknown fields are rejected with 422. Custom field
        values are addressable via ``custom_fields.<uuid>`` keys.
      type: object
      additionalProperties: true
      properties:
        and:
          type: array
          description: Logical AND - every nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        or:
          type: array
          description: Logical OR - at least one nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        actual_quantity:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Actual quantity produced, null if production not completed"
        completed_quantity:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Total quantity completed so far (including partial completions)"
        created_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the record was created."
        done_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the manufacturing order was completed"
        id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Record id."
        includes_partial_completions:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Whether this order has been partially completed"
        ingredient_availability:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Status of material ingredient availability for production"
        is_linked_to_sales_order:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Whether this manufacturing order is linked to a sales order"
        location_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ID of the factory location where production takes place"
        order_created_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Date and time when the manufacturing order was created"
        order_no:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Unique manufacturing order number for tracking and reference"
        planned_quantity:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Originally planned quantity to produce"
        production_deadline_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Target deadline for completing production (null when none is set)"
        remaining_quantity:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Remaining quantity to produce (planned - completed)"
        status:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Current production status of the manufacturing order"
        total_cost:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Total cost of the manufacturing order including all materials and operations"
        updated_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the record was last updated."
        variant_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ID of the product variant being manufactured"

    PurchaseOrderSearchFilter:
      description: |
        Filter clause for ``POST /purchase_orders/search``. Only the fields listed
        here may appear; unknown fields are rejected with 422. Custom field
        values are addressable via ``custom_fields.<uuid>`` keys.
      type: object
      additionalProperties: true
      properties:
        and:
          type: array
          description: Logical AND - every nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        or:
          type: array
          description: Logical OR - at least one nested clause must match. Maximum nesting depth 2.
          items:
            type: object
            additionalProperties: true
        billing_status:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Indicating the status of generating the bill through accounting integration to either Xero or QuickBooks Online. \"PARTIALLY_BILLED\" does not apply..."
        created_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the record was created."
        currency:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Currency of the purchase order. Filled with supplier currency by default."
        default_group_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Default grouping identifier for organizational purposes"
        entity_type:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Either \"regular\" or \"outsourced\", depending on the purchase order type."
        expected_arrival_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: "The timestamp when the items are expected to arrive (in full) in your warehouse."
        id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Record id."
        last_document_status:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Status of the last e-mail sent from (O)PO card."
        location_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "The ID of the location to which items are received."
        order_created_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: "The timestamp of creating the document."
        order_no:
          $ref: "#/components/schemas/SearchPredicate"
          description: "A unique, identifying string used in the UI and controlled by the user."
        status:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Status of the order."
        supplier_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "ID of the supplier who this order belongs to."
        tracking_location_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Regular orders do not have tracking locations"
        updated_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: "Timestamp when the record was last updated."

    CustomerSearchRequest:
      description: |
        Structured search body for ``POST /customers/search``. Returns the
        same paginated ``{"data": [...]}`` shape as the corresponding list
        endpoint, plus an ``X-Pagination`` header.
      type: object
      additionalProperties: false
      properties:
        filter:
          $ref: "#/components/schemas/CustomerSearchFilter"
          description: Filter conditions used to select matching customers.
        order:
          description: |
            Sort directive(s). Each entry is ``<field> ASC|DESC``
            (direction defaults to ASC). Only filterable fields may be
            used; ``custom_fields.<uuid>`` paths are orderable.
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        limit:
          type: integer
          minimum: 0
          maximum: 200
          description: |
            Page size; maximum 200. Omit to let the server apply its
            default of 50.
        page:
          type: integer
          minimum: 1
          description: |
            1-based page number. Omit to let the server default to 1.
      example:
        filter:
          and:
            - category:
              eq: "Wholesale"
        order:
          - name ASC
        limit: 50
        page: 1

    VariantSearchRequest:
      description: |
        Structured search body for ``POST /variants/search``. Returns the
        same paginated ``{"data": [...]}`` shape as the corresponding list
        endpoint, plus an ``X-Pagination`` header.
      type: object
      additionalProperties: false
      properties:
        filter:
          $ref: "#/components/schemas/VariantSearchFilter"
          description: Filter conditions used to select matching variants.
        order:
          description: |
            Sort directive(s). Each entry is ``<field> ASC|DESC``
            (direction defaults to ASC). Only filterable fields may be
            used; ``custom_fields.<uuid>`` paths are orderable.
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        limit:
          type: integer
          minimum: 0
          maximum: 200
          description: |
            Page size; maximum 200. Omit to let the server apply its
            default of 50.
        page:
          type: integer
          minimum: 1
          description: |
            1-based page number. Omit to let the server default to 1.
        include:
          type: array
          description: |
            Related data to include, and result-set widening. ``item``
            enriches each variant with its parent item under ``item``;
            ``archived`` and ``deleted`` include otherwise-excluded
            variants in the results.
          items:
            type: string
            enum:
              - item
              - archived
              - deleted
      example:
        filter:
          and:
            - item_type:
              eq: "product"
        order:
          - sku ASC
        limit: 50
        page: 1

    ManufacturingOrderSearchRequest:
      description: |
        Structured search body for ``POST /manufacturing_orders/search``. Returns the
        same paginated ``{"data": [...]}`` shape as the corresponding list
        endpoint, plus an ``X-Pagination`` header.
      type: object
      additionalProperties: false
      properties:
        filter:
          $ref: "#/components/schemas/ManufacturingOrderSearchFilter"
          description: Filter conditions used to select matching manufacturing orders.
        order:
          description: |
            Sort directive(s). Each entry is ``<field> ASC|DESC``
            (direction defaults to ASC). Only filterable fields may be
            used; ``custom_fields.<uuid>`` paths are orderable.
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        limit:
          type: integer
          minimum: 0
          maximum: 200
          description: |
            Page size; maximum 200. Omit to let the server apply its
            default of 50.
        page:
          type: integer
          minimum: 1
          description: |
            1-based page number. Omit to let the server default to 1.
      example:
        filter:
          and:
            - status:
              inq: ["NOT_STARTED", "IN_PROGRESS"]
        order:
          - order_no ASC
        limit: 50
        page: 1

    PurchaseOrderSearchRequest:
      description: |
        Structured search body for ``POST /purchase_orders/search``. Returns the
        same paginated ``{"data": [...]}`` shape as the corresponding list
        endpoint, plus an ``X-Pagination`` header.
      type: object
      additionalProperties: false
      properties:
        filter:
          $ref: "#/components/schemas/PurchaseOrderSearchFilter"
          description: Filter conditions used to select matching purchase orders.
        order:
          description: |
            Sort directive(s). Each entry is ``<field> ASC|DESC``
            (direction defaults to ASC). Only filterable fields may be
            used; ``custom_fields.<uuid>`` paths are orderable.
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        limit:
          type: integer
          minimum: 0
          maximum: 200
          description: |
            Page size; maximum 200. Omit to let the server apply its
            default of 50.
        page:
          type: integer
          minimum: 1
          description: |
            1-based page number. Omit to let the server default to 1.
      example:
        filter:
          and:
            - status:
              inq: ["NOT_RECEIVED"]
        order:
          - order_no ASC
        limit: 50
        page: 1

    SearchPredicate:
      description: |
        A single ``where`` predicate: either a bare ``SearchScalarValue``
        (equality) or a ``SearchComparator`` operator object.
      anyOf:
        - $ref: "#/components/schemas/SearchScalarValue"
        - $ref: "#/components/schemas/SearchComparator"
    SalesOrderSearchRequest:
      description: |
        Structured filter body for ``POST /sales_orders/search``. Returns
        the same paginated ``{"data": [...]}`` shape as
        ``GET /sales_orders`` plus an ``X-Pagination`` header. Beta —
        request/response shape may evolve before GA.
      type: object
      additionalProperties: false
      properties:
        filter:
          $ref: "#/components/schemas/SalesOrderSearchFilter"
          description: Filter conditions used to select matching sales orders.
        order:
          description: |
            Sort directive(s). Each entry is ``<field> ASC|DESC``
            (direction defaults to ASC). Only filterable fields may be
            used; ``custom_fields.<uuid>`` paths are orderable.
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        limit:
          type: integer
          minimum: 0
          maximum: 200
          description: |
            Page size; maximum 200. Omit to let the server apply its
            default of 50 (the client omits the key when unset rather than
            sending a default, so direct construction and round-tripped
            ``from_dict`` payloads behave identically).
        page:
          type: integer
          minimum: 1
          description: |
            1-based page number. Omit to let the server default to 1.
      example:
        filter:
          and:
            - status:
                inq: [NOT_SHIPPED, PACKED]
            - created_at:
                gte: "2026-01-01T00:00:00.000Z"
            - custom_fields.0c8f1d6e-3c2a-4f5b-9d77-12ab34cd56ef: 2
        order:
          - created_at DESC
          - id DESC
        limit: 50
        page: 1
    SalesOrderSearchFilter:
      description: |
        ``filter`` clause for ``POST /sales_orders/search``. Only the fields
        listed here may appear; unknown fields are rejected with 422.
        Custom field values are addressable via additional
        ``custom_fields.<uuid>`` keys (snake_case, matching the
        request/response body), where ``<uuid>`` is the custom field
        definition id — its value is a bare value or a ``SearchComparator``
        like any other predicate (for ``singleSelect`` the value is the
        integer choice ``id``). Compose with ``and`` / ``or`` (max nesting
        depth 2).
      type: object
      additionalProperties: true
      properties:
        and:
          type: array
          description: Logical AND — every nested where-clause must match. Max nesting depth 2.
          items:
            type: object
            additionalProperties: true
        or:
          type: array
          description: Logical OR — at least one nested where-clause must match. Max nesting depth 2.
          items:
            type: object
            additionalProperties: true
        id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Sales order id.
        order_no:
          $ref: "#/components/schemas/SearchPredicate"
          description: Order number.
        customer_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Customer id.
        customer_ref:
          $ref: "#/components/schemas/SearchPredicate"
          description: Caller-supplied customer reference.
        location_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Location id the order ships from.
        status:
          $ref: "#/components/schemas/SearchPredicate"
          description: |
            Delivery status. Allowed values: ``PENDING``, ``NOT_SHIPPED``,
            ``PACKED``, ``DELIVERED``, ``PARTIALLY_PACKED``,
            ``PARTIALLY_DELIVERED``.
        invoicing_status:
          $ref: "#/components/schemas/SearchPredicate"
          description: |
            Invoicing status. Allowed values: ``invoiced``,
            ``partiallyInvoiced``, ``notInvoiced``.
        production_status:
          $ref: "#/components/schemas/SearchPredicate"
          description: |
            Production status. Allowed values: ``NOT_STARTED``, ``NONE``,
            ``NOT_APPLICABLE``, ``IN_PROGRESS``, ``BLOCKED``, ``DONE``.
        source:
          $ref: "#/components/schemas/SearchPredicate"
          description: Source the order was created from (e.g. ``api``, ``shopify``).
        currency:
          $ref: "#/components/schemas/SearchPredicate"
          description: ISO 4217 currency code.
        product_availability:
          $ref: "#/components/schemas/SearchPredicate"
          description: |
            Product availability rollup. Allowed values: ``IN_STOCK``,
            ``EXPECTED``, ``PICKED``, ``NOT_AVAILABLE``, ``NOT_APPLICABLE``.
        ingredient_availability:
          $ref: "#/components/schemas/SearchPredicate"
          description: |
            Ingredient (material) availability rollup. Allowed values:
            ``PROCESSED``, ``IN_STOCK``, ``NOT_AVAILABLE``, ``EXPECTED``,
            ``NO_RECIPE``, ``NOT_APPLICABLE``.
        ecommerce_order_type:
          $ref: "#/components/schemas/SearchPredicate"
          description: Filter by source ecommerce platform identifier (e.g. `shopify`).
        ecommerce_store_name:
          $ref: "#/components/schemas/SearchPredicate"
          description: Filter by storefront host or slug (e.g. `acme.myshopify.com`).
        ecommerce_order_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Filter by the source platform's order identifier.
        tracking_number:
          $ref: "#/components/schemas/SearchPredicate"
          description: Carrier tracking number.
        created_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: ISO 8601 timestamp the order was created.
        updated_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: ISO 8601 timestamp the order was last updated.
        order_created_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: Business-meaningful order creation date (separate from ``created_at``).
        delivery_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: Planned delivery date.
        picked_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: Date the order was picked / shipped.
    SalesOrderRowSearchRequest:
      description: |
        Structured filter body for ``POST /sales_order_rows/search``.
        Returns the same paginated ``{"data": [...]}`` shape as
        ``GET /sales_order_rows`` plus an ``X-Pagination`` header. Beta —
        request/response shape may evolve before GA.
      type: object
      additionalProperties: false
      properties:
        filter:
          $ref: "#/components/schemas/SalesOrderRowSearchFilter"
          description: Filter conditions used to select matching sales order rows.
        order:
          description: |
            Sort directive(s). Each entry is ``<field> ASC|DESC``
            (direction defaults to ASC). Only filterable fields may be
            used; ``custom_fields.<uuid>`` paths are orderable.
          anyOf:
            - type: string
            - type: array
              items:
                type: string
        limit:
          type: integer
          minimum: 0
          maximum: 200
          description: |
            Page size; maximum 200. Omit to let the server apply its
            default of 50 (the client omits the key when unset rather than
            sending a default, so direct construction and round-tripped
            ``from_dict`` payloads behave identically).
        page:
          type: integer
          minimum: 1
          description: |
            1-based page number. Omit to let the server default to 1.
      example:
        filter:
          and:
            - sales_order_id:
                inq: [12345, 12346, 12347]
            - quantity:
                gt: 0
            - product_availability: IN_STOCK
        order:
          - delivery_date ASC
          - id ASC
        limit: 100
        page: 1
    SalesOrderRowSearchFilter:
      description: |
        ``filter`` clause for ``POST /sales_order_rows/search``. Only the
        fields listed here may appear; unknown fields are rejected with
        422. Custom field values are addressable via additional
        ``custom_fields.<uuid>`` keys (snake_case), where ``<uuid>`` is the
        custom field definition id. Compose with ``and`` / ``or`` (max
        nesting depth 2).
      type: object
      additionalProperties: true
      properties:
        and:
          type: array
          description: Logical AND — every nested where-clause must match. Max nesting depth 2.
          items:
            type: object
            additionalProperties: true
        or:
          type: array
          description: Logical OR — at least one nested where-clause must match. Max nesting depth 2.
          items:
            type: object
            additionalProperties: true
        id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Sales order row id.
        sales_order_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Parent sales order id.
        variant_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Variant id sold on this row.
        location_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Location id this row ships from.
        tax_rate_id:
          $ref: "#/components/schemas/SearchPredicate"
          description: Tax rate id applied to this row.
        quantity:
          $ref: "#/components/schemas/SearchPredicate"
          description: Ordered quantity.
        price_per_unit:
          $ref: "#/components/schemas/SearchPredicate"
          description: Unit price.
        total_discount:
          $ref: "#/components/schemas/SearchPredicate"
          description: Total discount applied to this row.
        tax_rate:
          $ref: "#/components/schemas/SearchPredicate"
          description: Tax rate percentage applied to this row.
        currency:
          $ref: "#/components/schemas/SearchPredicate"
          description: ISO 4217 currency code.
        product_availability:
          $ref: "#/components/schemas/SearchPredicate"
          description: |
            Product availability rollup. Allowed values: ``IN_STOCK``,
            ``EXPECTED``, ``PICKED``, ``NOT_AVAILABLE``, ``NOT_APPLICABLE``.
        created_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: ISO 8601 timestamp the row was created.
        updated_at:
          $ref: "#/components/schemas/SearchPredicate"
          description: ISO 8601 timestamp the row was last updated.
        delivery_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: Planned delivery date for this row.
        shipping_date:
          $ref: "#/components/schemas/SearchPredicate"
          description: Actual shipping date for this row.
    CreateSalesOrderAddressRequest:
      description: Request payload for creating a new sales order address
      type: object
      additionalProperties: false
      required:
        - sales_order_id
        - entity_type
      properties:
        sales_order_id:
          type: integer
          description: ID of the sales order this address belongs to
        entity_type:
          description: Whether this address is the shipping or billing address for the sales order
          $ref: "#/components/schemas/AddressEntityType"
        first_name:
          type: string
          description: First name for the address contact
        last_name:
          type: string
          description: Last name for the address contact
        company:
          type: string
          description: Company name for the address
        line_1:
          type: string
          description: Primary address line
        line_2:
          type: string
          description: Secondary address line
        city:
          type: string
          description: City name
        state:
          type: string
          description: State or province
        zip:
          type: string
          description: Postal code
        country:
          type: string
          description: Country code
        phone:
          type: string
          description: Contact phone number
      example:
        sales_order_id: 2001
        entity_type: shipping
        first_name: John
        last_name: Johnson
        company: Johnson's Restaurant
        line_1: 123 Main Street
        city: Portland
        state: OR
        zip: "97201"
        country: US
        phone: +1-555-0123
    UpdateSalesOrderAddressRequest:
      description: Request payload for updating an existing sales order address
      type: object
      additionalProperties: false
      properties:
        first_name:
          type: string
          description: First name for the address contact
        last_name:
          type: string
          description: Last name for the address contact
        company:
          type: string
          description: Company name for the address
        line_1:
          type: string
          description: Primary address line
        line_2:
          type: string
          description: Secondary address line
        city:
          type: string
          description: City name
        state:
          type: string
          description: State or province
        zip:
          type: string
          description: Postal code
        country:
          type: string
          description: Country code
        phone:
          type: string
          description: Contact phone number
      example:
        line_1: 456 Oak Avenue
        phone: +1-555-0456
    SalesOrderListResponse:
      description: Response containing a list of sales orders with pagination support for retrieving customer order data
      type: object
      properties:
        data:
          type: array
          description: Array of sales orders with complete order details and status information
          items:
            $ref: "#/components/schemas/SalesOrder"
      example:
        data:
          - id: 2001
            customer_id: 1501
            order_no: SO-2024-001
            source: Shopify
            order_created_date: "2024-01-15T10:00:00Z"
            delivery_date: "2024-01-22T14:00:00Z"
            picked_date: null
            location_id: 1
            status: PACKED
            currency: USD
            conversion_rate: 1.0
            conversion_date: "2024-01-15T10:00:00Z"
            invoicing_status: invoiced
            total: 1250.0
            total_in_base_currency: 1250.0
            additional_info: Customer requested expedited delivery
            customer_ref: CUST-REF-2024-001
            ecommerce_order_type: shopify
            ecommerce_store_name: acme.myshopify.com
            ecommerce_order_id: "19433769"
            product_availability: IN_STOCK
            ingredient_availability: IN_STOCK
            production_status: NOT_APPLICABLE
            tracking_number: UPS1234567890
            billing_address_id: 1201
            shipping_address_id: 1202
            created_at: "2024-01-15T10:00:00Z"
            updated_at: "2024-01-20T16:30:00Z"
    CreateSalesOrderRequest:
      description: |
        Request payload for creating a new sales order with customer information, order lines, and delivery details
      type: object
      properties:
        order_no:
          type: string
          description: |
            Unique order number for tracking and reference. Optional — Katana
            auto-generates a sequential ``SO-N`` value when omitted.
        customer_id:
          type: integer
          description: ID of the customer placing the order
        sales_order_rows:
          type: array
          minItems: 1
          description: List of products and quantities being ordered
          items:
            type: object
            properties:
              quantity:
                type: number
                description: Quantity of the product variant being ordered
              variant_id:
                type: integer
                description: ID of the product variant being ordered
              tax_rate_id:
                type:
                  - integer
                  - "null"
                description: Tax rate to apply to this line item
              location_id:
                type:
                  - integer
                  - "null"
                description: Location to pick the product from
              price_per_unit:
                type:
                  - number
                  - "null"
                description: Override price per unit (uses default if not specified)
              total_discount:
                type:
                  - number
                  - "null"
                description: Discount amount to apply to this line
              attributes:
                type: array
                description: Custom attributes for the order line
                items:
                  type: object
                  properties:
                    key:
                      type: string
                      description: Attribute name
                    value:
                      type: string
                      description: Attribute value
              custom_fields:
                type:
                  - object
                  - "null"
                additionalProperties: true
                description: |
                  Row-level custom field values, keyed by the
                  definition ``id`` (UUID) — the ``id`` returned by
                  ``GET /custom_field_definitions``, not the field label.
                  Each value matches the definition's ``field_type``:
                  string for ``shortText`` / ``url``, number for
                  ``number``, boolean for ``boolean``, a ``YYYY-MM-DD``
                  string for ``date``, or the integer choice ``id`` for
                  ``singleSelect``. Keys are tenant-specific, so the schema
                  declares ``additionalProperties: true`` rather than
                  enumerating them.
            required:
              - quantity
              - variant_id
        tracking_number:
          type:
            - string
            - "null"
          description: Shipping tracking number if already known
        tracking_number_url:
          type:
            - string
            - "null"
          format: uri
          description: URL for tracking shipment status
        addresses:
          type: array
          description: |
            Billing and shipping addresses for the order. Inline-create shape —
            ``sales_order_id`` is implicit (set by the parent sales-order create)
            and server-assigned fields (``id`` / ``sales_order_id``) are rejected
            by the live API on this endpoint. For the standalone create endpoint
            (``POST /sales_order_addresses``) see ``CreateSalesOrderAddressRequest``.
          items:
            type: object
            additionalProperties: false
            required:
              - entity_type
            properties:
              entity_type:
                description: Whether this address is the shipping or billing address for the sales order
                $ref: "#/components/schemas/AddressEntityType"
              first_name:
                type: string
                description: First name for the address contact
              last_name:
                type: string
                description: Last name for the address contact
              company:
                type: string
                description: Company name for the address
              line_1:
                type: string
                description: Primary address line
              line_2:
                type: string
                description: Secondary address line
              city:
                type: string
                description: City name
              state:
                type: string
                description: State or province
              zip:
                type: string
                description: Postal code
              country:
                type: string
                description: Country code
              phone:
                type: string
                description: Contact phone number
        order_created_date:
          type:
            - string
            - "null"
          format: date-time
          description: Date when the order was originally created (defaults to current time)
        delivery_date:
          type:
            - string
            - "null"
          format: date-time
          description: Requested delivery date
        currency:
          type:
            - string
            - "null"
          description: Currency code for the order (defaults to company base currency)
        location_id:
          type: integer
          description: Primary fulfillment location for the order
        status:
          description: Initial status of the order
          $ref: "#/components/schemas/CreateSalesOrderStatus"
        additional_info:
          type:
            - string
            - "null"
          description: Additional notes or instructions for the order
        customer_ref:
          type:
            - string
            - "null"
          description: Customer's internal reference number
        ecommerce_order_type:
          type:
            - string
            - "null"
          description: >-
            Source ecommerce platform, set at creation only (update cannot change
            it). Use the exact camelCase literal (`shopify`, `wooCommerce`, or
            `bigCommerce`) for Katana to recognize and deep-link the order; other
            values are stored verbatim but not deep-linked.
        ecommerce_store_name:
          type:
            - string
            - "null"
          description: >-
            Storefront host or slug — a full host for Shopify/WooCommerce (e.g.
            `acme.myshopify.com`) or a bare BigCommerce subdomain slug. Set at
            creation only.
        ecommerce_order_id:
          type:
            - string
            - "null"
          description: >-
            The source platform's order identifier (e.g. `19433769`). Set at
            creation only.
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: |
            Custom field values for the sales order, keyed by the
            definition ``id`` (UUID) — the ``id`` returned by
            ``GET /custom_field_definitions``, not the field label. Each
            value matches the definition's ``field_type``: string for
            ``shortText`` / ``url``, number for ``number``, boolean for
            ``boolean``, a ``YYYY-MM-DD`` string for ``date``, or the
            integer choice ``id`` for ``singleSelect``. Example (keys are
            definition UUIDs): ``{"0c8f1d6e-…": "EMEA", "7a21b4c2-…": 2}``
            — a ``shortText`` value and a ``singleSelect`` choice ``id``.
            Keys are tenant-specific, so the schema declares
            ``additionalProperties: true`` rather than enumerating them.
      required:
        - customer_id
        - sales_order_rows
      example:
        order_no: SO-2024-002
        customer_id: 1501
        sales_order_rows:
          - quantity: 3
            variant_id: 2101
            tax_rate_id: 301
            location_id: 1
            price_per_unit: 599.99
            total_discount: 50.0
            attributes:
              - key: engrave_text
                value: Professional Kitchen
              - key: rush_order
                value: "true"
        tracking_number: null
        tracking_number_url: null
        addresses:
          - entity_type: billing
            first_name: David
            last_name: Wilson
            company: Wilson's Catering
            line_1: 456 Commerce Ave
            city: Seattle
            state: WA
            zip: "98101"
            country: US
          - entity_type: shipping
            first_name: David
            last_name: Wilson
            company: Wilson's Catering
            line_1: 789 Industrial Blvd
            city: Seattle
            state: WA
            zip: "98102"
            country: US
        order_created_date: "2024-01-16T09:00:00Z"
        delivery_date: "2024-01-23T15:00:00Z"
        currency: USD
        location_id: 1
        status: PENDING
        additional_info: Customer prefers morning delivery
        customer_ref: WC-ORDER-2024-003
        ecommerce_order_type: wooCommerce
        ecommerce_store_name: shop.example.com
        ecommerce_order_id: "501"
    StockAdjustmentBatchTransaction:
      description: |
        Batch-specific transaction for tracking stock adjustments. Each
        entry pairs a quantity with the batch it applies to; ``batch_id``
        is nullable because some adjustments target unbatched stock (e.g.
        an aggregate correction to a non-batch-tracked variant) — Katana
        returns ``batch_id: null`` in that case.
      type: object
      additionalProperties: false
      required:
        - quantity
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: |
            Unique identifier for the batch being adjusted, or ``null``
            when the adjustment targets unbatched stock.
        quantity:
          type: number
          description: Quantity adjusted for this specific batch
      example:
        batch_id: 1001
        quantity: 50
    StockAdjustmentTraceability:
      description: Batch, serial, and bin allocation returned in a stock-adjustment response
      type: object
      additionalProperties: false
      properties:
        batch_id:
          type:
            - integer
            - "null"
          description: Batch ID, or null for unallocated stock
        serial_number_id:
          type:
            - integer
            - "null"
          description: Serial number ID, or null for nonserialized stock
        bin_location_id:
          type:
            - integer
            - "null"
          description: Bin ID, or null when no bin is allocated
        quantity:
          type: string
          description: Allocated quantity as a decimal string
      example:
        batch_id: null
        serial_number_id: null
        bin_location_id: null
        quantity: "5.0000000000"
    StockAdjustmentRow:
      description: Individual line item in a stock adjustment showing specific variant and quantity changes
      type: object
      additionalProperties: false
      required:
        - variant_id
        - quantity
      properties:
        id:
          type: integer
          description: Unique identifier for the stock adjustment row (present in responses only)
        variant_id:
          type: integer
          description: ID of the product or material variant being adjusted
        quantity:
          type: number
          description: Quantity to adjust (positive or negative)
        cost_per_unit:
          type: number
          description: Cost per unit for this adjustment (defaults to current average cost if not specified)
        batch_transactions:
          type: array
          description: Optional batch-specific adjustments for tracked inventory
          items:
            $ref: "#/components/schemas/StockAdjustmentBatchTransaction"
        traceability:
          type: array
          description: Batch, serial, and bin allocations returned for this adjustment row
          items:
            $ref: "#/components/schemas/StockAdjustmentTraceability"
        deleted_at:
          type:
            - string
            - "null"
          format: date-time
          description: Deletion timestamp for this row, or null while active
      example:
        id: 3001
        variant_id: 501
        quantity: 100
        cost_per_unit: 123.45
        batch_transactions:
          - batch_id: 1001
            quantity: 50
          - batch_id: 1002
            quantity: 50
    StockAdjustment:
      description:
        Manual inventory adjustment record for correcting stock discrepancies and maintaining accurate inventory
        levels
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the stock adjustment
            stock_adjustment_number:
              type: string
              description: Human-readable reference number for tracking and audit purposes
            stock_adjustment_date:
              type: string
              format: date-time
              description: Date and time when the adjustment was performed
            location_id:
              type: integer
              description: ID of the location where the stock adjustment is performed
            reason:
              type:
                - string
                - "null"
              description: Reason for the stock adjustment
            additional_info:
              type:
                - string
                - "null"
              description: Optional notes or comments about the adjustment reason
            stock_adjustment_rows:
              type: array
              description: Line items showing specific variants and quantities being adjusted
              items:
                $ref: "#/components/schemas/StockAdjustmentRow"
          required:
            - id
            - stock_adjustment_number
            - location_id
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 1
        stock_adjustment_number: SA-1
        stock_adjustment_date: "2021-10-06T11:47:13.846Z"
        location_id: 1
        reason: adjustment reason
        additional_info: adjustment additional info
        stock_adjustment_rows:
          - id: 1
            variant_id: 1
            quantity: 100
            cost_per_unit: 123.45
            batch_transactions:
              - batch_id: 1
                quantity: 50
              - batch_id: 2
                quantity: 50
          - id: 2
            variant_id: 2
            quantity: 150
            cost_per_unit: 234.56
            batch_transactions:
              - batch_id: 3
                quantity: 150
        created_at: "2021-10-06T11:47:13.846Z"
        updated_at: "2021-10-06T11:47:13.846Z"
        deleted_at: null
    StockAdjustmentListResponse:
      type: object
      description: List of stock adjustment records showing all manual inventory corrections and their current status
      properties:
        data:
          type: array
          description: Array of stock adjustment records with details and status information
          items:
            $ref: "#/components/schemas/StockAdjustment"
      example:
        data:
          - id: 1
            stock_adjustment_number: SA-1
            stock_adjustment_date: "2021-10-06T11:47:13.846Z"
            location_id: 1
            reason: adjustment reason
            additional_info: adjustment additional info
            stock_adjustment_rows:
              - id: 1
                variant_id: 1
                quantity: 100
                cost_per_unit: 123.45
                batch_transactions:
                  - batch_id: 1
                    quantity: 50
                  - batch_id: 2
                    quantity: 50
              - id: 2
                variant_id: 2
                quantity: 150
                cost_per_unit: 234.56
                batch_transactions:
                  - batch_id: 3
                    quantity: 150
            created_at: "2021-10-06T11:47:13.846Z"
            updated_at: "2021-10-06T11:47:13.846Z"
            deleted_at: null
    CreateStockAdjustmentRequest:
      description: Request payload for creating a new stock adjustment to correct inventory levels
      type: object
      additionalProperties: false
      required:
        - location_id
        - stock_adjustment_rows
      properties:
        stock_adjustment_number:
          type: string
          minLength: 1
          description: Human-readable reference number for tracking and audit purposes
        stock_adjustment_date:
          type: string
          format: date-time
          description: Date and time when the adjustment was performed
        location_id:
          type: integer
          description: ID of the location where the stock adjustment is performed
        reason:
          type: string
          description: Reason for the stock adjustment
        additional_info:
          type: string
          description: Optional notes or comments about the adjustment reason
        stock_adjustment_rows:
          type: array
          description: Line items specifying variants and quantities to adjust
          minItems: 1
          items:
            type: object
            additionalProperties: false
            required:
              - variant_id
              - quantity
            properties:
              variant_id:
                type: integer
                description: ID of the product or material variant being adjusted
              quantity:
                type: number
                description: Quantity to adjust (positive or negative)
              cost_per_unit:
                type: number
                description: >-
                  Cost per unit for this adjustment. Only allowed when quantity
                  is positive; for negative adjustments, the item's average cost
                  is used automatically and sending this field will result in a
                  422 validation error.
              batch_transactions:
                type: array
                description: Optional batch-specific adjustments for tracked inventory
                minItems: 1
                items:
                  $ref: "#/components/schemas/StockAdjustmentBatchTransaction"
              traceability:
                type: array
                description: >-
                  Unified batch/serial/bin allocations for the adjusted
                  quantity. Use a non-null `serial_number_id` per entry to
                  attach or remove specific serial-tracked units. Katana
                  requires a non-zero `quantity` on each entry here.
                items:
                  $ref: "#/components/schemas/TraceabilityRequest"
      example:
        stock_adjustment_number: SA-2024-003
        stock_adjustment_date: "2024-01-17T14:30:00.000Z"
        location_id: 1
        reason: Cycle count correction
        additional_info: Q1 2024 physical inventory
        stock_adjustment_rows:
          - variant_id: 501
            quantity: 100
            cost_per_unit: 123.45
          - variant_id: 502
            quantity: -25
    UpdateStockAdjustmentRequest:
      description: Request payload for updating an existing stock adjustment
      type: object
      additionalProperties: false
      properties:
        stock_adjustment_number:
          type: string
          minLength: 1
          description: Human-readable reference number for tracking and audit purposes
        stock_adjustment_date:
          type: string
          format: date-time
          description: Date and time when the adjustment was performed
        location_id:
          type: integer
          description: ID of the location where the stock adjustment is performed
        reason:
          type: string
          description: Reason for the stock adjustment
        additional_info:
          type: string
          description: Optional notes or comments about the adjustment reason
      example:
        stock_adjustment_number: SA-2024-003
        stock_adjustment_date: "2024-01-17T14:30:00.000Z"
        location_id: 1
        reason: Cycle count correction
        additional_info: Cycle count correction - updated with final counts
    StockTransfer:
      description: Inventory transfer record for moving stock between different warehouse locations or facilities
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the stock transfer
            stock_transfer_number:
              type: string
              description: Human-readable reference number for tracking the transfer
            source_location_id:
              type: integer
              description: ID of the source location where stock is being transferred from
            target_location_id:
              type: integer
              description: ID of the destination location where stock is being transferred to
            status:
              type: string
              description: Current status of the stock transfer workflow
            transfer_date:
              type: string
              format: date-time
              description: Date and time when the transfer was executed
            order_created_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date and time when the transfer order was created
            expected_arrival_date:
              type:
                - string
                - "null"
              format: date-time
              description: Expected arrival date for the transferred stock
            additional_info:
              type:
                - string
                - "null"
              description: Optional notes or comments about the transfer purpose
            stock_transfer_rows:
              type: array
              description: Line items detailing the products and quantities being transferred
              items:
                $ref: "#/components/schemas/StockTransferRow"
          required:
            - id
            - stock_transfer_number
            - source_location_id
            - target_location_id
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 1
        stock_transfer_number: ST-1
        source_location_id: 1
        target_location_id: 2
        transfer_date: "2021-10-06T11:47:13.846Z"
        order_created_date: "2021-10-01T11:47:13.846Z"
        expected_arrival_date: "2021-10-20T11:47:13.846Z"
        additional_info: transfer additional info
        stock_transfer_rows:
          - id: 1
            variant_id: 1
            quantity: 100
            cost_per_unit: 123.45
            batch_transactions:
              - batch_id: 1
                quantity: 50
              - batch_id: 2
                quantity: 50
            deleted_at: null
          - id: 2
            variant_id: 2
            quantity: 150
            cost_per_unit: 234.56
            batch_transactions:
              - batch_id: 3
                quantity: 150
            deleted_at: null
        created_at: "2021-10-06T11:47:13.846Z"
        updated_at: "2021-10-06T11:47:13.846Z"
        deleted_at: null
    StockTransferRow:
      description: Line item in a stock transfer showing the product variant and quantity being moved
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the stock transfer row
            variant_id:
              type: integer
              description: ID of the product or material variant being transferred
            quantity:
              type: number
              description: Quantity of the variant being transferred
            cost_per_unit:
              type: number
              description: Cost per unit for the transferred variant
            batch_transactions:
              type: array
              description: Batch transaction details for batch-tracked items
              items:
                type: object
                properties:
                  batch_id:
                    type:
                      - integer
                      - "null"
                    description: ID of the batch being transferred
                  quantity:
                    type: number
                    description: Quantity from this specific batch
                required:
                  - batch_id
                  - quantity
            deleted_at:
              type:
                - string
                - "null"
              format: date-time
              description: Nullable deletion timestamp for the row
          required:
            - variant_id
            - quantity
    StockTransferListResponse:
      type: object
      description: |
        List of stock transfer records showing all inventory movements between locations and their transfer status
      properties:
        data:
          type: array
          description: Array of stock transfer records with source, destination, and status details
          items:
            $ref: "#/components/schemas/StockTransfer"
      example:
        data:
          - id: 1
            stock_transfer_number: ST-1
            source_location_id: 1
            target_location_id: 2
            transfer_date: "2021-10-06T11:47:13.846Z"
            order_created_date: "2021-10-01T11:47:13.846Z"
            expected_arrival_date: "2021-10-20T11:47:13.846Z"
            additional_info: transfer additional info
            created_at: "2021-10-06T11:47:13.846Z"
            updated_at: "2021-10-06T11:47:13.846Z"
            deleted_at: null
    SalesOrderFulfillment:
      description:
        Shipping and delivery record for a sales order, tracking the physical fulfillment process including
        picking, packing, and shipment tracking
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the fulfillment record
            sales_order_id:
              type: integer
              description: ID of the sales order being fulfilled
            picked_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date and time when items were picked from inventory
            status:
              description: Current fulfillment status
              $ref: "#/components/schemas/SalesOrderFulfillmentStatus"
            invoice_status:
              description: Current invoice status of the fulfillment
              anyOf:
                - $ref: "#/components/schemas/SalesOrderFulfillmentInvoiceStatus"
                - type: "null"
            conversion_rate:
              type:
                - number
                - "null"
              description: Currency conversion rate applied to this fulfillment
            conversion_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date when the currency conversion rate was applied
            tracking_number:
              type:
                - string
                - "null"
              description: Carrier tracking number for shipment monitoring
            tracking_url:
              type:
                - string
                - "null"
              description: URL for online tracking of the shipment
            tracking_carrier:
              type:
                - string
                - "null"
              description: Shipping carrier name (e.g., UPS, FedEx, DHL)
            tracking_method:
              type:
                - string
                - "null"
              description: Shipping method used (e.g., ground, express)
            packer_id:
              type:
                - integer
                - "null"
              description: ID of the user who packed the fulfillment
            sales_order_fulfillment_rows:
              type: array
              description: Line items in this fulfillment with quantities and batch details
              items:
                type: object
                properties:
                  sales_order_row_id:
                    type: integer
                    description: ID of the sales order row being fulfilled
                  quantity:
                    type: number
                    description: Quantity fulfilled for this row
                  batch_transactions:
                    type: array
                    description: Batch allocations for this fulfillment row
                    items:
                      type: object
                      properties:
                        batch_id:
                          type:
                            - integer
                            - "null"
                          description: ID of the batch
                        quantity:
                          type: number
                          description: Quantity from this batch
                  serial_numbers:
                    type: array
                    description: Serial numbers allocated to this fulfillment row
                    items:
                      type: integer
          required:
            - id
            - sales_order_id
        - $ref: "#/components/schemas/UpdatableEntity"
      example:
        id: 1
        sales_order_id: 1
        picked_date: "2020-10-23T10:37:05.085Z"
        status: DELIVERED
        invoice_status: NOT_INVOICED
        conversion_rate: 2
        conversion_date: "2020-10-23T10:37:05.085Z"
        tracking_number: "12345678"
        tracking_url: https://tracking-number-url
        tracking_carrier: UPS
        tracking_method: ground
        packer_id: 1
        sales_order_fulfillment_rows:
          - sales_order_row_id: 1
            quantity: 2
            batch_transactions:
              - batch_id: 1
                quantity: 2
            serial_numbers:
              - 1
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
    PriceList:
      description:
        Customer-specific pricing configuration for flexible pricing management across different market segments
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the price list
            name:
              type: string
              description: Descriptive name for the price list (e.g., "Premium Customer Pricing", "Wholesale Rates")
            is_active:
              type: boolean
              description: Whether this price list is currently active
          required:
            - id
            - name
        - $ref: "#/components/schemas/UpdatableEntity"
      example:
        id: 1
        name: Wholesale price list
        is_active: false
        created_at: "2020-10-23T10:37:05.085Z"
        updated_at: "2020-10-23T10:37:05.085Z"
    CreatePriceListRequest:
      description:
        Request payload for creating a new price list with market-specific pricing configurations
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        name:
          type: string
          description: Descriptive name for the price list (e.g., "Premium Customer Pricing", "Wholesale Rates")
      example:
        name: Premium Customer Pricing
    CreatePriceListRowRequest:
      description:
        Request payload for adding product variants with specific pricing to a price list
      type: object
      additionalProperties: false
      required:
        - price_list_id
        - price_list_rows
      properties:
        price_list_id:
          type: integer
          description: ID of the price list to add the variant pricing to
        price_list_rows:
          type: array
          description: Array of price list row items to create
          items:
            type: object
            properties:
              variant_id:
                type: integer
                description: ID of the product variant
              adjustment_method:
                $ref: "#/components/schemas/PriceListAdjustmentMethod"
                description: Method for price adjustment
              amount:
                type: number
                description: Adjustment amount
      example:
        price_list_id: 1001
        price_list_rows:
          - variant_id: 201
            adjustment_method: fixed
            amount: 249.99
    CreatePriceListCustomerRequest:
      description: Request payload for assigning customers to a price list for custom pricing
      type: object
      additionalProperties: false
      required:
        - price_list_id
        - price_list_customers
      properties:
        price_list_id:
          type: integer
          description: ID of the price list
        price_list_customers:
          type: array
          description: Array of customers to assign to the price list
          items:
            type: object
            properties:
              customer_id:
                type: integer
                description: ID of the customer to assign
      example:
        price_list_id: 1002
        price_list_customers:
          - customer_id: 2002
    UpdatePriceListRequest:
      description: Request payload for updating an existing price list
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          description: Descriptive name for the price list
        is_active:
          type: boolean
          description: Whether the price list is active
      example:
        name: Premium Customer Pricing - Updated
        is_active: true
    UpdatePriceListRowRequest:
      description: Request payload for updating an existing price list row
      type: object
      additionalProperties: false
      properties:
        variant_id:
          type: integer
          description: ID of the product variant being priced
        adjustment_method:
          description: Method for price adjustment
          $ref: "#/components/schemas/PriceListAdjustmentMethod"
        amount:
          type: number
          description: Adjustment amount
      example:
        variant_id: 67890
        adjustment_method: fixed
        amount: 259.99
    UpdatePriceListCustomerRequest:
      description: Request payload for updating an existing price list customer assignment
      type: object
      additionalProperties: false
      required:
        - customer_id
      properties:
        customer_id:
          type: integer
          description: ID of the customer to assign to price list
      example:
        customer_id: 2003
    PriceListRow:
      description:
        Individual product variant pricing entry within a price list for customer-specific or market-specific pricing
        management
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the price list row entry
            price_list_id:
              type: integer
              description: ID of the price list this pricing entry belongs to
            variant_id:
              type: integer
              description: ID of the product variant this pricing applies to
            adjustment_method:
              description: Method used for price adjustment (fixed, percentage, markup)
              $ref: "#/components/schemas/PriceListAdjustmentMethod"
            amount:
              type: number
              description: Amount value for the price adjustment based on the adjustment method
          required:
            - id
            - price_list_id
            - variant_id
            - adjustment_method
            - amount
        - $ref: "#/components/schemas/UpdatableEntity"
      example:
        id: 5001
        price_list_id: 1001
        variant_id: 201
        adjustment_method: fixed
        amount: 249.99
        created_at: "2024-01-15T10:00:00Z"
        updated_at: "2024-01-15T10:00:00Z"
    PriceListCustomer:
      description: Association between a customer and a price list for custom pricing management
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the price list customer assignment
            price_list_id:
              type: integer
              description: ID of the price list being assigned to the customer
            customer_id:
              type: integer
              description: ID of the customer receiving the custom pricing
          required:
            - id
            - price_list_id
            - customer_id
        - $ref: "#/components/schemas/UpdatableEntity"
      example:
        id: 4001
        price_list_id: 1001
        customer_id: 2001
        created_at: "2024-01-15T10:00:00Z"
        updated_at: "2024-01-15T10:00:00Z"
    ProductOperationRow:
      description: Operation step assigned to a product's manufacturing process
      type: object
      properties:
        product_id:
          type: integer
          description: Product ID
        product_operation_row_id:
          type: integer
          description: Unique identifier for the product operation row
        product_variant_id:
          type: integer
          description: Product variant ID
        operation_id:
          type: integer
          description: Operation ID
        operation_name:
          type: string
          description: Name of the operation
        type:
          description: |
            Operation type defining how time and cost are calculated.
            Matches the enum used on manufacturing-order operation rows.
          $ref: "#/components/schemas/ManufacturingOperationType"
        resource_id:
          type:
            - integer
            - "null"
          description: Resource ID assigned to operation
        resource_name:
          type:
            - string
            - "null"
          description: Name of the assigned resource
        cost_per_hour:
          type:
            - number
            - "null"
          deprecated: true
          description: Cost per hour for this operation (deprecated — use ``cost_parameter`` instead)
        cost_parameter:
          type:
            - number
            - "null"
          description: |
            Cost calculation parameter. Numeric — Katana returns it as a
            JSON number (e.g. ``15``) or ``null`` when not configured.
        planned_cost_per_unit:
          type:
            - number
            - "null"
          description: Planned cost per unit
        planned_time_per_unit:
          type:
            - number
            - "null"
          deprecated: true
          description: Planned time per unit (deprecated — use ``planned_time_parameter`` instead)
        planned_time_parameter:
          type:
            - number
            - "null"
          description: |
            Time calculation parameter. Numeric — Katana returns it as a
            JSON number (e.g. ``7200``) or ``null`` when not configured.
        rank:
          type: integer
          description: Operation sequence rank
        group_boundary:
          type:
            - string
            - "null"
          description: Group boundary marker
        created_at:
          type: string
          format: date-time
          description: Timestamp when the row was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the row was last updated
      required:
        - product_operation_row_id
    BomRow:
      description: Bill of Materials row defining ingredient requirements for product manufacturing
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique UUID identifier for the BOM row
        product_variant_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the product variant this BOM row belongs to
        product_item_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the product item this BOM row belongs to
        ingredient_variant_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the ingredient variant used in this BOM row
        quantity:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 100000000000000000
          description: Required quantity of the ingredient variant
        notes:
          type:
            - string
            - "null"
          description: Additional notes for this BOM row
        rank:
          type: integer
          description: Sort rank for ordering BOM rows
        created_at:
          type: string
          format: date-time
          description: Timestamp when the BOM row was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the BOM row was last updated
      required:
        - id
        - product_variant_id
        - product_item_id
        - ingredient_variant_id
      example:
        id: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
        product_item_id: 1
        product_variant_id: 1
        ingredient_variant_id: 1
        quantity: 2
        notes: some notes
        rank: 10000
        created_at: "2021-04-05T12:00:00.000Z"
        updated_at: "2021-04-05T12:00:00.000Z"
    CreateBomRowRequest:
      type: object
      description: Request payload for creating a new BOM row
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        product_item_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the product item this BOM row belongs to
        product_variant_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the product variant this BOM row belongs to
        ingredient_variant_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the ingredient variant used in this BOM row
        quantity:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 100000000000000000
          description: Required quantity of the ingredient variant
        notes:
          type:
            - string
            - "null"
          description: Additional notes for this BOM row
      required:
        - product_item_id
        - product_variant_id
        - ingredient_variant_id

      example:
        product_item_id: 3001
        product_variant_id: 2001
        ingredient_variant_id: 2002
        quantity: 2.5
        notes: Handle with care - fragile component
    BatchCreateBomRowsRequest:
      type: object
      description: Request payload for creating multiple BOM rows in a single operation
      properties:
        data:
          type: array
          description: Array of BOM rows to create
          items:
            $ref: "#/components/schemas/CreateBomRowRequest"
      required:
        - data
      example:
        data:
          - product_item_id: 3001
            product_variant_id: 2001
            ingredient_variant_id: 2002
            quantity: 2.5
            notes: Primary component
          - product_item_id: 3001
            product_variant_id: 2001
            ingredient_variant_id: 2003
            quantity: 1.0
            notes: Secondary component
    UpdateBomRowRequest:
      type: object
      description: Request payload for updating an existing BOM row. Only provided fields will be updated.
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        ingredient_variant_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the ingredient variant used in this BOM row
        quantity:
          type:
            - number
            - "null"
          minimum: 0
          maximum: 100000000000000000
          description: Required quantity of the ingredient variant
        notes:
          type:
            - string
            - "null"
          description: Additional notes for this BOM row

      example:
        quantity: 3.0
        notes: Updated quantity based on new specifications
    BomRowListResponse:
      type: object
      description: Response containing a list of BOM rows
      properties:
        data:
          type: array
          description: Array of BOM row objects
          items:
            $ref: "#/components/schemas/BomRow"
      example:
        data:
          - id: "501a1234-5678-90ab-cdef-1234567890ab"
            product_variant_id: 2001
            product_item_id: 3001
            ingredient_variant_id: 2002
            quantity: 2.5
            notes: Handle with care - fragile component
            created_at: "2023-10-15T14:30:00Z"
            updated_at: "2023-10-16T09:15:00Z"
          - id: "502b1234-5678-90ab-cdef-1234567890ab"
            product_variant_id: 2001
            product_item_id: 3001
            ingredient_variant_id: 2003
            quantity: 1.0
            notes: Standard component
            created_at: "2023-10-15T14:31:00Z"
            updated_at: "2023-10-15T14:31:00Z"
    Recipe:
      type: object
      description: |
        Recipe row representing ingredient requirements for product manufacturing (deprecated in favor of BOM rows)
      deprecated: true
      properties:
        id:
          type: string
          description: Unique identifier for the recipe row
        recipe_row_id:
          type: string
          description: Recipe row UUID identifier
        product_id:
          type: integer
          description: ID of the product that uses this recipe
        product_item_id:
          type: integer
          description: ID of the product item
        product_variant_id:
          type: integer
          description: ID of the product variant this recipe belongs to
        ingredient_variant_id:
          type: integer
          description: ID of the ingredient variant used in this recipe
        quantity:
          type: number
          description: Required quantity of the ingredient
        notes:
          type:
            - string
            - "null"
          description: Additional notes for this recipe row
        rank:
          type: integer
          description: Display order rank for recipe rows
        created_at:
          type: string
          format: date-time
          description: Timestamp when the recipe was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the recipe was last updated
      required:
        - id
        - product_variant_id
        - ingredient_variant_id
        - quantity
      example:
        id: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
        recipe_row_id: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
        product_item_id: 1
        product_variant_id: 1
        ingredient_variant_id: 1
        quantity: 2
        notes: some notes
        rank: 10000
        created_at: "2021-04-05T12:00:00.000Z"
        updated_at: "2021-04-05T12:00:00.000Z"
    CreateRecipesRequest:
      type: object
      description: Request payload for creating recipe rows (deprecated in favor of BOM rows)
      deprecated: true
      additionalProperties: false
      required:
        - rows
      properties:
        keep_current_rows:
          type: boolean
          description: |-
            Existing ingredient lines are kept by default, and new lines will be added to existing
            product recipes. Set to false to delete all existing ingredient lines for related
            products and add the ingredients as new recipes.
        rows:
          type: array
          minItems: 1
          maxItems: 150
          description: Array of recipe rows to create
          items:
            type: object
            additionalProperties: false
            required:
              - ingredient_variant_id
              - product_variant_id
              - quantity
            properties:
              quantity:
                type: number
                maximum: 10000000000000000
                minimum: 0
                description: Required quantity of the ingredient
              ingredient_variant_id:
                type: integer
                maximum: 2147483647
                description: ID of the ingredient variant
              product_variant_id:
                type: number
                minimum: 0
                maximum: 2147483647
                description: ID of the product variant
              notes:
                type: string
                maxLength: 255
                minLength: 0
                description: Additional notes for this recipe row
      example:
        keep_current_rows: true
        rows:
          - ingredient_variant_id: 1001
            product_variant_id: 2001
            quantity: 2.5
            notes: Primary ingredient
    RecipeListResponse:
      type: object
      description: Response containing a list of recipe rows
      deprecated: true
      properties:
        data:
          type: array
          description: Array of recipe objects
          items:
            $ref: "#/components/schemas/Recipe"
      example:
        data:
          - id: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
            recipe_row_id: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
            product_item_id: 1
            product_variant_id: 1
            ingredient_variant_id: 1
            quantity: 2
            notes: some notes
            rank: 10000
            created_at: "2021-04-05T12:00:00.000Z"
            updated_at: "2021-04-05T12:00:00.000Z"
    Factory:
      type: object
      description: Factory configuration object (singleton resource without ID)
      properties:
        name:
          type: string
          description: Display name of the manufacturing facility
        address:
          type:
            - string
            - "null"
          description: Physical address of the manufacturing facility for shipping and logistics
        currency:
          type: string
          description: Default currency code (ISO 4217) used for financial transactions at this facility
        timezone:
          type: string
          description: Timezone identifier for the facility location used for scheduling and time tracking
        legal_address:
          type: object
          description: Legal address information
        legal_name:
          type: string
          description: Legal name of the company
        display_name:
          type: string
          description: Display name of the company
        base_currency_code:
          type: string
          description: Base currency code
        default_so_delivery_time:
          type:
            - string
            - "null"
          description: |-
            Default sales order delivery time. Note: Katana's upstream
            example shows an ISO-8601 datetime, but the live wire delivers
            either ``null`` or an opaque short string (e.g. ``"14"`` for
            days). ``format: date-time`` is intentionally omitted.
        default_po_lead_time:
          type:
            - string
            - "null"
          description: |-
            Default purchase order lead time. Same shape as
            ``default_so_delivery_time`` — wire delivers ``null`` or an
            opaque short string, not a datetime. ``format: date-time``
            intentionally omitted.
        default_manufacturing_location_id:
          type: integer
          description: Default manufacturing location ID
        default_purchases_location_id:
          type: integer
          description: Default purchases location ID
        default_sales_location_id:
          type: integer
          description: Default sales location ID
        inventory_closing_date:
          type:
            - string
            - "null"
          format: date-time
          description: Inventory closing date
      required:
        - display_name
        - base_currency_code
      example:
        legal_address:
          line_1: "Peetri 7"
          line_2: "Apartment 1"
          city: "Tallinn"
          state: "State"
          zip: "10411"
          country: "Estonia"
        legal_name: "Legal name"
        display_name: "Display name"
        base_currency_code: "USD"
        default_so_delivery_time: "2021-10-13T15:31:48.490Z"
        default_po_lead_time: "2021-10-13T15:31:48.490Z"
        default_manufacturing_location_id: 1
        default_purchases_location_id: 1
        default_sales_location_id: 1
        inventory_closing_date: "2022-01-28T23:59:59.000Z"
    OperatorListResponse:
      description: Response containing a list of operators
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Operator"
          description: Array of operator objects
    Operator:
      description: Manufacturing operator or worker assigned to specific production operations and work areas
      allOf:
        - type: object
          properties:
            id:
              type: integer
            operator_name:
              type: string
          required:
            - id
            - operator_name
        - $ref: "#/components/schemas/DeletableEntity"
    AssignedOperator:
      type: object
      description: Simplified operator reference used in manufacturing operation assignments
      properties:
        operator_id:
          type: integer
          description: Reference to the operator ID
        name:
          type: string
          description: Operator name for display purposes
        deleted_at:
          type:
            - string
            - "null"
          format: date-time
          description: Deletion timestamp if operator assignment was removed
      required:
        - operator_id
        - name
      example:
        operator_id: 1
        name: "Pack"
        deleted_at: null
    CustomFieldsCollection:
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the custom fields collection
            name:
              type: string
              description: Display name of the custom fields collection for management and organization
            resource_type:
              description: The type of business object this custom fields collection applies to
              $ref: "#/components/schemas/CustomFieldCollectionResourceType"
            custom_fields:
              type: array
              description: Array of custom field definitions with their types, validation rules, and configuration
              items:
                $ref: "#/components/schemas/CustomField"
          required:
            - id
            - name
        - $ref: "#/components/schemas/DeletableEntity"
      description:
        Collection of custom field definitions that can be applied to specific business objects for extended data
        capture
      example:
        id: 5
        name: Product Quality Specifications
        resource_type: product
        custom_fields:
          - id: 10
            name: quality_grade
            field_type: select
            label: Quality Grade
            required: true
            options:
              - A
              - B
              - C
          - id: 11
            name: certification_date
            field_type: date
            label: Certification Date
            required: false
        created_at: "2024-01-08T10:00:00Z"
        updated_at: "2024-01-12T15:30:00Z"
    CustomFieldValue:
      description: |
        A single custom field value in the **legacy** ``{field_name,
        field_value}`` shape used by Variant / Product / Material / Service
        resources. These fields are configured via the
        ``/custom_fields_collections`` surface and attached as an **array**
        of name/value pairs.

        This is distinct from — and must not be unified with — the newer
        sales-order custom-fields surface, where ``custom_fields`` is a
        **dict keyed by custom field definition ``id`` (UUID)** registered
        through ``/custom_field_definitions`` (see ``CustomFieldDefinition``
        and the ``custom_fields`` property on ``SalesOrder`` /
        ``SalesOrderRow``). The two surfaces coexist. Variant and service
        update requests also accept the UUID-keyed map when that feature
        is enabled for the account; this schema describes the legacy item.
      type: object
      additionalProperties: false
      required:
        - field_name
        - field_value
      properties:
        field_name:
          type: string
          maxLength: 40
          description: Name of the custom field (matches a configured field's ``name``)
        field_value:
          type: string
          description: Value to set for this custom field
      example:
        field_name: quality_grade
        field_value: A
    CustomField:
      description: Individual custom field definition with validation rules and configuration options
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the custom field
        name:
          type: string
          description: Internal name/key for the custom field
        field_type:
          type: string
          description: Type of the custom field (text, number, date, select, etc.)
        label:
          type: string
          description: Display label for the custom field in user interfaces
        required:
          type: boolean
          description: Whether this field is required when filling out the form
        options:
          type: array
          description: Available options for select/dropdown field types
          items:
            type: string
      required:
        - id
        - name
      example:
        id: 10
        name: quality_grade
        field_type: select
        label: Quality Grade
        required: true
        options:
          - A
          - B
          - C
    CustomFieldsCollectionListResponse:
      type: object
      description: List of custom field collections configured for extending business object data capture
      properties:
        data:
          type: array
          description: Array of custom field collections with their field definitions and configuration
          items:
            $ref: "#/components/schemas/CustomFieldsCollection"
      example:
        data:
          - id: 5
            name: Product Quality Specifications
            resource_type: product
            custom_fields:
              - id: 10
                name: quality_grade
                field_type: select
                label: Quality Grade
                required: true
                options:
                  - A
                  - B
                  - C
              - id: 11
                name: certification_date
                field_type: date
                label: Certification Date
                required: false
            created_at: "2024-01-08T10:00:00Z"
            updated_at: "2024-01-12T15:30:00Z"
          - id: 6
            name: Customer Account Details
            resource_type: customer
            custom_fields:
              - id: 12
                name: credit_limit
                field_type: number
                label: Credit Limit
                required: true
              - id: 13
                name: payment_terms
                field_type: select
                label: Payment Terms
                required: true
                options:
                  - Net 30
                  - Net 60
                  - COD
            created_at: "2024-01-10T11:00:00Z"
            updated_at: "2024-01-14T09:15:00Z"
    CustomFieldType:
      type: string
      enum:
        - shortText
        - number
        - singleSelect
        - date
        - boolean
        - url
      description: |
        Field input type for a ``CustomFieldDefinition`` — determines how
        Katana renders and validates the field's stored values, and what
        JSON type the value takes when set on a sales order. Immutable
        after creation.

        Value stored on the entity, by ``field_type``:

        - ``shortText`` — string
        - ``number`` — number
        - ``date`` — ``YYYY-MM-DD`` string
        - ``boolean`` — ``true`` / ``false``
        - ``url`` — string
        - ``singleSelect`` — the integer choice ``id`` (not the label).
          Requires ``options.choices``; the server assigns each choice an
          integer ``id``. Resolve labels client-side from
          ``options.choices`` (soft-deleted choices remain in the array).

        Note: a ``multiSelect`` type has been announced on the Katana
        roadmap but is **not yet live** — the API rejects it today, so it
        is intentionally absent from this enum. Add it here only once the
        live API accepts it.

    CustomFieldEntityType:
      type: string
      enum:
        - SalesOrder
        - SalesOrderRow
        - ProductVariant
        - MaterialVariant
        - ServiceVariant
        - PurchaseOrder
        - PurchaseOrderRow
        - OutsourcedPurchaseOrder
        - OutsourcedPurchaseOrderRow
        - ProductionOperation
        - RecipeBom
        - Supplier
        - Customer
      description: |-
        Entity the custom field applies to. Immutable after creation.
        - `SalesOrder` / `SalesOrderRow` — the field lives on a sales order, or on one of its rows.
        - `ProductVariant` / `MaterialVariant` / `ServiceVariant` — the field lives on an item. In Katana these are the Products, Materials, and Services an item can be. Values are held **per variant**, not on the product / material / service itself: a `ProductVariant` definition is set and read on each of a product's variants, and a product with one variant simply has one place to set it.
        - `PurchaseOrder` / `PurchaseOrderRow` / `OutsourcedPurchaseOrder` / `OutsourcedPurchaseOrderRow` — the field lives on a purchase order, standard or outsourced, or on one of its rows.
        - `ProductionOperation` — the field lives on a production operation.
        - `RecipeBom` — the field lives on a BOM row. The same definitions are used on manufacturing order recipe rows and outsourced purchase order recipe rows.
        - `Supplier` — the field lives on a supplier.
        - `Customer` — the field lives on a customer.

        Two groups each share a single pool of definitions, so a definition is accepted beyond the exact entity type it was created with:
        - The three variant entity types — a definition created with any one of them is accepted on any variant, whatever kind of item it belongs to.
        - Standard and outsourced purchase orders — `PurchaseOrder` and `OutsourcedPurchaseOrder` definitions are both accepted on any purchase order, and likewise `PurchaseOrderRow` / `OutsourcedPurchaseOrderRow` on any purchase order row.

        Katana's own UI still scopes each definition to the item type or kind of order it was created for, so pick the `entity_type` that matches where you want the field to appear.

        The variant entity types, the four purchase order entity types, `Customer`, and `ProductionOperation` are behind feature flags — contact support@katanamrp.com to enable. `ProductionOperation` additionally requires the Advanced Manufacturing or Manufacturing Management add-on.

    CustomFieldDefinition:
      description: |-
        A custom field definition registered through POST /custom_field_definitions. Values are keyed by its UUID in the entity custom_fields property. See CustomFieldEntityType for supported entities and account feature requirements. A factory may hold at most 50 definitions. field_type, entity_type, and source are immutable; label, description, and options may be updated.
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
          description: Server-assigned UUID identifier
        label:
          type: string
          maxLength: 255
          description: Display label shown in the Katana UI
        field_type:
          $ref: "#/components/schemas/CustomFieldType"
          description: Field input type. Immutable after creation.
        entity_type:
          $ref: "#/components/schemas/CustomFieldEntityType"
          description: Resource type the definition applies to. Immutable after creation.
        source:
          type: string
          maxLength: 255
          description: |
            Caller-provided identifier of the integration that owns the
            field (e.g. your application slug). Namespaces and audits
            definitions. Immutable after creation.
        description:
          type:
            - string
            - "null"
          description: Optional long-form description of the field's purpose
        options:
          description: |-
            Extra configuration for the definition. `choices` is only meaningful when `field_type` is `singleSelect`; `appearsOn` is only meaningful on a variant definition. Omit (or send `null`) when neither applies.
          anyOf:
            - $ref: "#/components/schemas/CustomFieldOptions"
            - type: "null"
        created_at:
          type: string
          format: date-time
          description: Timestamp when the definition was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the definition was last updated
        deleted_at:
          type:
            - string
            - "null"
          format: date-time
          description: |
            Soft-delete timestamp; ``null`` for a live definition. Deleting
            a definition (``DELETE /custom_field_definitions/{id}``) is a
            soft delete — its values are stripped from read responses but
            the definition is retained.
      required:
        - id
        - label
        - field_type
        - entity_type
        - source
      example:
        id: "0c8f1d6e-3c2a-4f5b-9d77-12ab34cd56ef"
        label: Channel
        field_type: shortText
        entity_type: SalesOrder
        source: your-integration
        description: Customer-facing sales channel classification
        options:
        created_at: "2026-05-14T10:00:00Z"
        updated_at: "2026-05-14T10:00:00Z"
        deleted_at: null
    CreateCustomFieldDefinitionRequest:
      description: Request payload for creating a new custom field definition.
      type: object
      additionalProperties: false
      required:
        - label
        - field_type
        - entity_type
        - source
      properties:
        label:
          type: string
          maxLength: 255
          description: Display label shown in the Katana UI
        field_type:
          $ref: "#/components/schemas/CustomFieldType"
          description: Field input type. Immutable after creation.
        entity_type:
          $ref: "#/components/schemas/CustomFieldEntityType"
          description: Resource type the definition applies to. Immutable after creation.
        source:
          type: string
          maxLength: 255
          description: Origin / namespace of the definition.
        description:
          type:
            - string
            - "null"
          description: Optional long-form description
        options:
          description: |-
            Extra configuration for the definition. `choices` is only meaningful when `field_type` is `singleSelect`; `appearsOn` is only meaningful on a variant definition. Omit (or send `null`) when neither applies. Choices are required for singleSelect; send labels only when creating choices.
          anyOf:
            - $ref: "#/components/schemas/CustomFieldOptionsCreate"
            - type: "null"
      example:
        label: Channel
        field_type: shortText
        entity_type: SalesOrder
        source: your-integration
        description: Customer-facing sales channel classification
    UpdateCustomFieldDefinitionRequest:
      description: |
        Request payload for updating an existing custom field definition.
        Only ``label``, ``description``, and ``options`` may be updated;
        ``field_type``, ``entity_type``, and ``source`` are immutable.
      type: object
      additionalProperties: false
      properties:
        label:
          type: string
          maxLength: 255
          description: Updated display label
        description:
          type:
            - string
            - "null"
          description: Updated long-form description
        options:
          description: |-
            Keys you omit keep their current value, so send only what you are changing. `null` clears the whole object (rejected on a `singleSelect`, which must always keep its choices).

            `choices` is only meaningful when the field is a `singleSelect`, and is the exception to the merge rule: send the **full** array, every existing choice included and identified by its server-assigned `id`. Omit a choice and it is removed from history — use `deleted: true` instead to soft-delete it and keep historical values resolvable. New choices are sent without an `id`.
          anyOf:
            - $ref: "#/components/schemas/CustomFieldOptions"
            - type: "null"
      example:
        label: Quality Grade (revised)
        description: Updated customer-facing quality classification
    CustomFieldDefinitionListResponse:
      description: List of custom field definitions
      type: object
      properties:
        data:
          type: array
          description: Array of custom field definitions
          items:
            $ref: "#/components/schemas/CustomFieldDefinition"
      example:
        data:
          - id: "0c8f1d6e-3c2a-4f5b-9d77-12ab34cd56ef"
            label: Channel
            field_type: shortText
            entity_type: SalesOrder
            source: your-integration
            description: Customer-facing sales channel classification
            options: null
            created_at: "2026-05-14T10:00:00Z"
            updated_at: "2026-05-14T10:00:00Z"
            deleted_at: null
    CustomFieldChoice:
      description: |
        A single ``singleSelect`` choice as it appears on read and update.
        The integer ``id`` is what gets stored on the entity; ``label`` is
        the human-readable text resolved client-side.
      type: object
      additionalProperties: false
      required:
        - label
      properties:
        id:
          type: integer
          description: |
            Server-assigned choice identifier. The value actually stored on
            a sales order for this field. Present on read; on
            ``PATCH /custom_field_definitions/{id}`` it must be supplied to
            identify an existing choice (omit it to create a new choice).
        label:
          type: string
          description: Human-readable label for the choice.
        deleted:
          type: boolean
          description: |
            Soft-delete marker. On update, set ``true`` to retire an
            existing choice while keeping it in the array so historical
            values referencing its ``id`` stay resolvable. Choices are
            never hard-deleted.
      example:
        id: 1
        label: Online
    CustomFieldChoiceCreate:
      description: |
        A single ``singleSelect`` choice as supplied on
        ``POST /custom_field_definitions``. Send only the ``label`` — the
        server assigns the integer ``id`` and returns it in the response.
      type: object
      additionalProperties: false
      required:
        - label
      properties:
        label:
          type: string
          description: Human-readable label for the choice.
      example:
        label: Online
    CustomFieldOptions:
      description: |-
        Keys you omit keep their current value, so send only what you are changing. `null` clears the whole object (rejected on a `singleSelect`, which must always keep its choices).

        `choices` is only meaningful when the field is a `singleSelect`, and is the exception to the merge rule: send the **full** array, every existing choice included and identified by its server-assigned `id`. Omit a choice and it is removed from history — use `deleted: true` instead to soft-delete it and keep historical values resolvable. New choices are sent without an `id`.
      type: object
      additionalProperties: false
      properties:
        choices:
          type: array
          description: |
            The allowed choices, each with its server-assigned integer
            ``id`` and ``label``. Soft-deleted choices remain present so
            historical values stay resolvable.
          items:
            $ref: "#/components/schemas/CustomFieldChoice"
        appearsOn:
          description: Replaces the current list of transactional entities this variant definition also applies to. Omit to leave it untouched. Removing a target stops the definition being a valid key on that entity, and values already snapshotted onto existing records of that type stop being returned — they are retained and reappear if the target is added back. Same validation as on create — see `POST /custom_field_definitions`.
          items:
            enum:
              - SalesOrderRow
              - PurchaseOrderRow
              - OutsourcedPurchaseOrderRow
              - ManufacturingOrder
            type: string
          type: array
          uniqueItems: true
      example:
        choices:
          - id: 1
            label: Online
          - id: 2
            label: Retail
          - id: 3
            label: Wholesale
    CustomFieldOptionsCreate:
      description: |-
        Extra configuration for the definition. `choices` is only meaningful when `field_type` is `singleSelect`; `appearsOn` is only meaningful on a variant definition. Omit (or send `null`) when neither applies.
      type: object
      additionalProperties: false
      properties:
        choices:
          type: array
          description: The choices to create, each identified by ``label`` only.
          items:
            $ref: "#/components/schemas/CustomFieldChoiceCreate"
        appearsOn:
          description: "Transactional entities this definition additionally applies to, on top of its own `entity_type`. Listing a target makes this definition's id a valid key in that entity's `custom_fields` — nothing is copied, and the target's `custom_fields` accepts its own definitions and linked-in ones alike.\n\nOnly variant definitions (`ProductVariant` / `MaterialVariant` / `ServiceVariant`) may target `SalesOrderRow`, `PurchaseOrderRow`, `OutsourcedPurchaseOrderRow`, and `ManufacturingOrder`; a `ProductionOperation` definition may target `ManufacturingOrder` only. Any other combination, a duplicate entry, or the definition's own `entity_type` is rejected with a 422.\n\nSeparately from this, a row or manufacturing order created against a variant takes a **snapshot** of that variant's current values for the fields that name it in `appearsOn`. The snapshot is editable on the record afterwards and is never re-synced, so later edits to the variant do not reach records that already exist.
            A value whose definition no longer applies to the entity — the target was dropped from `appearsOn`, or the definition was deleted — is retained but no longer returned on reads of that record.\n\nBehind a feature flag on the target side too — contact support@katanamrp.com to enable."
          items:
            enum:
              - SalesOrderRow
              - PurchaseOrderRow
              - OutsourcedPurchaseOrderRow
              - ManufacturingOrder
            type: string
          type: array
          uniqueItems: true
      example:
        choices:
          - label: Online
          - label: Retail
          - label: Wholesale
    Stocktake:
      description: Physical inventory count process for reconciling actual stock levels with system records
      allOf:
        - type: object
          properties:
            id:
              type: integer
            stocktake_number:
              type: string
              description: A string used to identify the stocktake
            location_id:
              type: integer
              description: The location where the stocktake is being performed
            status:
              description: Current status of the stocktake process
              $ref: "#/components/schemas/StocktakeStatus"
            stocktake_created_date:
              type: string
              format: date-time
              description: Date and time when the stocktake was created
            started_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date and time when the stocktake was started
            completed_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date and time when the stocktake was completed
            status_update_in_progress:
              type: boolean
              description: Whether a status update is currently in progress
            set_remaining_items_as_counted:
              type: boolean
              description: Whether remaining items should be set as counted
            stock_adjustment_id:
              type:
                - integer
                - "null"
              description: ID of the associated stock adjustment
            reason:
              type:
                - string
                - "null"
              description: A descriptive field for your own information to enable better identification
            additional_info:
              type:
                - string
                - "null"
              description: A string attached to the object to add any internal comments or links to external files
          required:
            - id
            - stocktake_number
            - location_id
            - status
        - $ref: "#/components/schemas/DeletableEntity"
    StocktakeRow:
      description: Individual item record within a stocktake showing system vs actual quantities and variance
      allOf:
        - type: object
          properties:
            id:
              type: integer
            stocktake_id:
              type: integer
              description: The stocktake process this row belongs to
            variant_id:
              type: integer
              description: The product variant being counted
            batch_id:
              type:
                - integer
                - "null"
              description: The batch identifier if the variant is batch-tracked
            in_stock_quantity:
              type:
                - number
                - "null"
              description: The quantity shown in the system before the stocktake
            counted_quantity:
              type:
                - number
                - "null"
              description: The actual quantity counted during the stocktake
            discrepancy_quantity:
              type:
                - number
                - "null"
              description: The difference between system and actual quantities
            notes:
              type:
                - string
                - "null"
              description: Notes about this stocktake row
          required:
            - id
            - stocktake_id
            - variant_id
        - $ref: "#/components/schemas/DeletableEntity"
    SerialNumberStockListResponse:
      description: Response containing a list of serial number stock items
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/SerialNumberStock"
          description: Array of serial number stock items
    SerialNumberStock:
      description: Current stock status and transaction history of individual serialized inventory items
      type: object
      properties:
        id:
          type: integer
          description: Serial number stock ID
        serial_number:
          type: string
          description: The actual serial number
        in_stock:
          type: boolean
          description: Whether the item is currently in stock
        transactions:
          type: array
          description: Transaction history for this serial number
          items:
            type: object
            properties:
              id:
                type: string
                description: Transaction ID
              resource_id:
                type: integer
                description: Resource ID associated with transaction
              resource_type:
                type: string
                description: Type of resource (ManufacturingOrder, etc.)
              transaction_date:
                type:
                  - string
                  - "null"
                format: date-time
                description: Date and time of transaction
              quantity_change:
                type: integer
                description: Quantity change in transaction
            required:
              - id
              - resource_id
              - resource_type
              - quantity_change
      required:
        - id
        - serial_number
        - in_stock
        - transactions
    SalesReturn:
      description: |
        Sales return record representing customer product returns with refund processing and inventory adjustments
      allOf:
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the sales return record
            customer_id:
              type: integer
              description: Unique identifier of the customer making the return
            sales_order_id:
              type:
                - integer
                - "null"
              description: Reference to the original sales order being returned (if applicable)
            order_no:
              type: string
              description: Unique return order number for tracking and reference
            return_location_id:
              type: integer
              description: Location where returned items will be received and processed
            status:
              description: Current processing status of the sales return
              $ref: "#/components/schemas/SalesReturnStatus"
            currency:
              type: string
              pattern: ^[A-Z]{3}$
              description: Currency code for refund amounts (ISO 4217 format)
            return_date:
              type:
                - string
                - "null"
              format: date-time
              description: Date when the return was processed and items received
            order_created_date:
              type: string
              format: date-time
              description: Date and time when the return request was created
            additional_info:
              type:
                - string
                - "null"
              description: Additional notes or comments about the return
            refund_status:
              oneOf:
                - $ref: "#/components/schemas/SalesReturnRefundStatus"
                - type: "null"
              description: Current status of the refund processing
            tracking_number:
              type:
                - string
                - "null"
              description: Tracking number for the return shipment
            tracking_number_url:
              type:
                - string
                - "null"
              description: URL to track the return shipment
            tracking_carrier:
              type:
                - string
                - "null"
              description: Carrier used for the return shipment
            tracking_method:
              type:
                - string
                - "null"
              description: Shipping method used for the return
            sales_return_rows:
              type: array
              description: Line items being returned with quantities and reasons
              items:
                $ref: "#/components/schemas/SalesReturnRow"
          required:
            - id
            - customer_id
            - order_no
            - return_location_id
            - status
        - $ref: "#/components/schemas/DeletableEntity"
      example:
        id: 3001
        customer_id: 1001
        sales_order_id: 2001
        order_no: SR-2023-001
        return_location_id: 1
        status: RETURNED_ALL
        currency: USD
        return_date: "2023-10-15T14:30:00Z"
        order_created_date: "2023-10-10T10:00:00Z"
        additional_info: Customer reported damaged items during shipping
        refund_status: REFUNDED
        sales_return_rows:
          - id: 3501
            sales_return_id: 3001
            variant_id: 2002
            quantity: "2.0"
            return_reason_id: 1
            notes: Packaging was damaged
            unit_price: 25.0
            total_price: 50.0
            created_at: "2023-10-15T14:00:00Z"
            updated_at: "2023-10-15T15:00:00Z"
        created_at: "2023-10-15T14:00:00Z"
        updated_at: "2023-10-15T15:00:00Z"
        deleted_at: null
    CreateSalesReturnRequest:
      description: Request payload for creating a new sales return to process customer product returns and refunds
      type: object
      additionalProperties: false
      required:
        - sales_order_id
        - return_location_id
      properties:
        sales_order_id:
          type: integer
          description: ID of the original sales order being returned
        order_created_date:
          type: string
          format: date-time
          description: Creation date of the return. If missing then current timestamp will be used.
        return_location_id:
          type: integer
          description: ID of the location where items are being returned to
        order_no:
          type: string
          description: Return order reference number
        additional_info:
          type: string
          description: Optional notes or comments about the return
        tracking_number:
          type:
            - string
            - "null"
          description: Tracking number for the return shipment
        tracking_number_url:
          type:
            - string
            - "null"
          description: URL to track the return shipment
        tracking_carrier:
          type:
            - string
            - "null"
          description: Carrier used for the return shipment
        tracking_method:
          type:
            - string
            - "null"
          description: Shipping method used for the return
      example:
        sales_order_id: 2001
        order_created_date: "2023-10-10T10:00:00Z"
        return_location_id: 1
        order_no: SR-2023-001
        additional_info: Customer reported damaged items during shipping
    UpdateSalesReturnRequest:
      description: Request payload for updating an existing sales return
      type: object
      additionalProperties: false
      properties:
        status:
          description: Status of the sales return
          $ref: "#/components/schemas/SalesReturnStatus"
        return_date:
          type: string
          format: date-time
          description: Date of the return. Updatable only when current return status is not RESTOCKED_ALL.
        order_created_date:
          type: string
          format: date-time
          description: Creation date of the return. Updatable only when current return status is not RESTOCKED_ALL.
        return_location_id:
          type: integer
          description: ID of the location where items are being returned to. Updatable only when current return status is not RESTOCKED_ALL.
        order_no:
          type: string
          description: Return order reference number. Updatable only when current return status is not RESTOCKED_ALL.
        additional_info:
          type:
            - string
            - "null"
          description: Additional information about the return. Updatable only when current return status is not RESTOCKED_ALL.
        tracking_number:
          type:
            - string
            - "null"
          description: Tracking number for the return shipment
        tracking_number_url:
          type:
            - string
            - "null"
          description: URL to track the return shipment
        tracking_carrier:
          type:
            - string
            - "null"
          description: Carrier used for the return shipment
        tracking_method:
          type:
            - string
            - "null"
          description: Shipping method used for the return
      example:
        status: RETURNED_ALL
        return_date: "2023-10-12T10:00:00Z"
        order_no: SR-2023-001
        return_location_id: 1
        additional_info: Customer reported damaged items during shipping
    SalesReturnRow:
      description: Individual line item within a sales return specifying returned product, quantity, and refund details
      allOf:
        - type: object
          properties:
            id:
              type: integer
            sales_return_id:
              type: integer
              description: The sales return this line item belongs to
            variant_id:
              type: integer
              description: The product variant being returned
            fulfillment_row_id:
              type: integer
              description: ID of the fulfillment row this return is associated with
            sales_order_row_id:
              type: integer
              description: ID of the sales order row this return is associated with
            quantity:
              type: string
              description: The quantity of the variant being returned (formatted as decimal string for precision)
            net_price_per_unit:
              type:
                - string
                - "null"
              description: Net price per unit for the returned item (formatted as decimal string for precision)
            reason_id:
              type:
                - integer
                - "null"
              description: ID of the return reason
            restock_location_id:
              type:
                - integer
                - "null"
              description: ID of the location where stock will be restocked
            batch_transactions:
              type: array
              description: Batch allocations for this return row
              items:
                type: object
                properties:
                  batch_id:
                    type: integer
                    description: ID of the batch
                  quantity:
                    type: number
                    description: Quantity returned to this batch
          required:
            - id
            - sales_return_id
            - variant_id
            - quantity
        - $ref: "#/components/schemas/UpdatableEntity"
    CreateSalesReturnRowRequest:
      description: Request payload for creating a new sales return row with product and quantity information
      type: object
      additionalProperties: false
      required:
        - sales_return_id
        - variant_id
        - fulfillment_row_id
        - quantity
      properties:
        sales_return_id:
          type: integer
          description: ID of the sales return this row belongs to
        variant_id:
          type: integer
          description: ID of the variant being returned
        fulfillment_row_id:
          type: integer
          description: ID of the fulfillment row this return is associated with
        quantity:
          type: number
          description: Quantity being returned
        restock_location_id:
          type: integer
          description: Restock location ID. If missing then default from sales order fulfillment row will be used.
        reason_id:
          type: integer
          description: ID of the return reason
    User:
      allOf:
        - $ref: "#/components/schemas/UpdatableEntity"
        - type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the user account
            firstName:
              type: string
              description: User's first name for display and communication
            lastName:
              type: string
              description: User's last name for display and communication
            email:
              type: string
              description: Email address used for login and system notifications
            role:
              type: string
              description: User's role determining system permissions and access levels
            status:
              type: string
              description: Current account status (active, inactive, suspended)
            last_login_at:
              type:
                - string
                - "null"
              format: date-time
              description: Timestamp of the user's most recent system login
          required:
            - id
            - firstName
            - lastName
            - email
      description: System user account with authentication credentials and role-based permissions
      example:
        id: 42
        firstName: Sarah
        lastName: Johnson
        email: sarah.johnson@company.com
        role: production_manager
        status: active
        last_login_at: "2024-01-15T14:30:00Z"
        created_at: "2024-01-10T09:00:00Z"
        updated_at: "2024-01-15T14:30:00Z"
    SalesOrderRowListResponse:
      description: |
        Response containing a list of sales order rows with pagination support for retrieving order line items
      type: object
      properties:
        data:
          type: array
          description: Array of sales order row line items with pricing and product details
          items:
            $ref: "#/components/schemas/SalesOrderRow"
      example:
        data:
          - id: 2501
            quantity: 2
            variant_id: 2101
            tax_rate_id: 301
            location_id: 1
            product_availability: IN_STOCK
            product_expected_date: null
            price_per_unit: "599.9900000000"
            price_per_unit_in_base_currency: 599.99
            total: 1199.98
            total_in_base_currency: 1199.98
            cogs_value: "400.0000000000"
            attributes:
              - key: engrave_text
                value: Johnson's Kitchen
            batch_transactions:
              - batch_id: 1801
                quantity: 2.0
            serial_numbers:
              - 10001
              - 10002
            linked_manufacturing_order_id: null
            conversion_rate: 1.0
            conversion_date: "2024-01-15T10:00:00Z"
            created_at: "2024-01-15T10:00:00Z"
            updated_at: "2024-01-15T10:00:00Z"
    SalesOrderAddressListResponse:
      description: Response containing a list of billing and shipping addresses associated with sales orders
      type: object
      properties:
        data:
          type: array
          description: Array of sales order addresses with complete contact and location information
          items:
            $ref: "#/components/schemas/SalesOrderAddress"
      example:
        data:
          - id: 1201
            sales_order_id: 2001
            entity_type: billing
            first_name: Sarah
            last_name: Johnson
            company: Johnson's Restaurant
            phone: +1-503-555-0123
            line_1: 123 Main Street
            line_2: Suite 4B
            city: Portland
            state: OR
            zip: "97201"
            country: US
            created_at: "2024-01-15T10:00:00Z"
            updated_at: "2024-01-15T10:00:00Z"
    SalesOrderFulfillmentListResponse:
      description: |
        Response containing a list of fulfillment records showing shipping and delivery status for sales orders
      type: object
      properties:
        data:
          type: array
          description: Array of fulfillment records with tracking and delivery information
          items:
            $ref: "#/components/schemas/SalesOrderFulfillment"
      example:
        data:
          - id: 1
            sales_order_id: 1
            picked_date: "2020-10-23T10:37:05.085Z"
            status: DELIVERED
            invoice_status: NOT_INVOICED
            conversion_rate: 2
            conversion_date: "2020-10-23T10:37:05.085Z"
            tracking_number: "12345678"
            tracking_url: https://tracking-number-url
            tracking_carrier: UPS
            tracking_method: ground
            packer_id: 1
            sales_order_fulfillment_rows:
              - sales_order_row_id: 1
                quantity: 2
                batch_transactions:
                  - batch_id: 1
                    quantity: 2
                serial_numbers:
                  - 1
            created_at: "2020-10-23T10:37:05.085Z"
            updated_at: "2020-10-23T10:37:05.085Z"
    CustomerAddressListResponse:
      description: Response containing a list of customer addresses with complete contact information
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CustomerAddress"
          description: Array of customer address entities
      example:
        data:
          - id: 3001
            customer_id: 2001
            entity_type: billing
            default: true
            first_name: Sarah
            last_name: Johnson
            company: Kitchen Pro Restaurants Ltd
            phone: +1-555-0123
            line_1: 123 Restaurant Row
            line_2: Suite 200
            city: Chicago
            state: IL
            zip: "60601"
            country: US
            created_at: "2024-01-10T09:15:00Z"
            updated_at: "2024-01-10T09:15:00Z"
          - id: 3002
            customer_id: 2001
            entity_type: shipping
            default: true
            first_name: David
            last_name: Kim
            company: Kitchen Pro Restaurants Ltd
            phone: +1-555-0126
            line_1: 456 Delivery Avenue
            line_2: Loading Dock B
            city: Chicago
            state: IL
            zip: "60602"
            country: US
            created_at: "2024-01-10T09:20:00Z"
            updated_at: "2024-01-10T09:20:00Z"
    CreateCustomerAddressRequest:
      description: Request payload for creating a new customer address with complete contact and location information
      type: object
      properties:
        customer_id:
          type: integer
          description: ID of the customer this address belongs to
        entity_type:
          description: Whether this address is the shipping or billing address for the customer
          $ref: "#/components/schemas/AddressEntityType"
        first_name:
          type:
            - string
            - "null"
          description: First name for the contact person at this address
        last_name:
          type:
            - string
            - "null"
          description: Last name for the contact person at this address
        company:
          type:
            - string
            - "null"
          description: Company name for business addresses
        phone:
          type:
            - string
            - "null"
          description: Phone number for this address location
        line_1:
          type:
            - string
            - "null"
          description: Primary address line (street address, building number)
        line_2:
          type:
            - string
            - "null"
          description: Secondary address line (apartment, suite, floor)
        city:
          type:
            - string
            - "null"
          description: City or locality name
        state:
          type:
            - string
            - "null"
          description: State, province, or region
        zip:
          type:
            - string
            - "null"
          description: Postal code or ZIP code
        country:
          type:
            - string
            - "null"
          description: Country name or country code
      required:
        - customer_id
        - entity_type
      example:
        customer_id: 2003
        entity_type: shipping
        first_name: Maria
        last_name: Garcia
        company: Cafe Central
        phone: +1-555-0127
        line_1: 789 Main Street
        line_2: Unit 5
        city: San Francisco
        state: CA
        zip: "94102"
        country: US
    PriceListListResponse:
      description:
        Response containing a paginated list of price lists configured for customer-specific and market-specific
        pricing management
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PriceList"
          description: Array of price list objects
      example:
        data:
          - id: 1001
            name: Premium Customer Pricing
            currency: USD
            is_default: false
            markup_percentage: 25.0
            start_date: "2024-01-01T00:00:00Z"
            end_date: "2024-12-31T23:59:59Z"
            created_at: "2024-01-01T10:00:00Z"
            updated_at: "2024-01-15T14:30:00Z"
            deleted_at: null
          - id: 1002
            name: Wholesale Rates
            currency: USD
            is_default: true
            markup_percentage: 15.0
            start_date: null
            end_date: null
            created_at: "2024-01-01T10:05:00Z"
            updated_at: "2024-01-01T10:05:00Z"
            deleted_at: null
    PriceListRowListResponse:
      description: |
        Response containing a paginated list of price list rows showing variant-specific pricing within price lists
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PriceListRow"
          description: Array of price list row objects containing variant pricing
      example:
        data:
          - id: 5001
            price_list_id: 1001
            variant_id: 201
            adjustment_method: fixed
            amount: 249.99
            price: 249.99
            currency: USD
            created_at: "2024-01-15T10:00:00Z"
            updated_at: "2024-01-15T10:00:00Z"
          - id: 5002
            price_list_id: 1001
            variant_id: 202
            adjustment_method: percentage
            amount: 10.0
            price: 69.99
            currency: USD
            created_at: "2024-01-15T10:05:00Z"
            updated_at: "2024-01-15T10:05:00Z"
    PriceListCustomerListResponse:
      description: Response containing a list of price list customer assignments
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PriceListCustomer"
          description: Array of price list customer assignment entities
      example:
        data:
          - id: 4001
            price_list_id: 1001
            customer_id: 2001
            created_at: "2024-01-15T10:00:00Z"
            updated_at: "2024-01-15T10:00:00Z"
          - id: 4002
            price_list_id: 1002
            customer_id: 2002
            created_at: "2024-01-16T11:30:00Z"
            updated_at: "2024-01-16T11:30:00Z"
    StocktakeListResponse:
      type: object
      description: List of stocktake records showing all physical inventory count sessions and their completion status
      properties:
        data:
          type: array
          description: Array of stocktake records with count session details and status information
          items:
            $ref: "#/components/schemas/Stocktake"
      example:
        data:
          - id: 4001
            stocktake_number: STK-2024-001
            reference_no: STK-2024-001
            location_id: 1
            status: COMPLETED
            count_date: "2024-01-15T09:00:00.000Z"
            notes: Monthly physical inventory count
            created_at: "2024-01-15T09:00:00.000Z"
            updated_at: "2024-01-15T17:30:00.000Z"
          - id: 4002
            stocktake_number: STK-2024-002
            reference_no: STK-2024-002
            location_id: 2
            status: IN_PROGRESS
            count_date: "2024-01-16T10:00:00.000Z"
            notes: Spot check for high-value items
            created_at: "2024-01-16T10:00:00.000Z"
            updated_at: "2024-01-16T12:00:00.000Z"
    StocktakeRowListResponse:
      type: object
      description: |
        List of individual stocktake row records showing counted quantities for each variant in a stocktake session
      properties:
        data:
          type: array
          description: Array of stocktake row records with variant counts and variance details
          items:
            $ref: "#/components/schemas/StocktakeRow"
      example:
        data:
          - id: 4101
            stocktake_id: 4001
            variant_id: 3001
            expected_quantity: 150.0
            counted_quantity: 147.0
            variance: -3.0
            notes: Minor count difference noted
            created_at: "2024-01-15T09:30:00.000Z"
            updated_at: "2024-01-15T09:30:00.000Z"
          - id: 4102
            stocktake_id: 4001
            variant_id: 3002
            expected_quantity: 75.0
            counted_quantity: 75.0
            variance: 0.0
            notes: Count matches expected
            created_at: "2024-01-15T10:15:00.000Z"
            updated_at: "2024-01-15T10:15:00.000Z"
    CreateStocktakeRequest:
      description: Request payload for creating a new stocktake to perform physical inventory counting
      type: object
      additionalProperties: false
      required:
        - stocktake_number
        - location_id
      properties:
        stocktake_number:
          type: string
          description: A string used to identify the stocktake
        location_id:
          type: integer
          description: The ID of the stocktake location
        reason:
          type: string
          description: A descriptive field for your own information to enable better identification
        additional_info:
          type: string
          description: Additional notes or information about the stocktake
        created_date:
          type: string
          format: date-time
          description: Date when the stocktake was created
        set_remaining_items_as_counted:
          type: boolean
          description: Whether to set remaining uncounted items as counted
        stocktake_rows:
          type: array
          description: Array of stocktake row items
          items:
            type: object
            properties:
              variant_id:
                type: integer
                description: ID of the variant to count
              batch_id:
                type: integer
                description: ID of the batch
              counted_quantity:
                type: number
                description: Counted quantity
      example:
        stocktake_number: STK-2024-003
        location_id: 1
        reason: Quarterly inventory count
        additional_info: Annual audit
    UpdateStocktakeRequest:
      description: Request payload for updating an existing stocktake
      type: object
      additionalProperties: false
      properties:
        stocktake_number:
          type: string
          description: A string used to identify the stocktake
        location_id:
          type: integer
          description: The ID of the stocktake location
        reason:
          type: string
          description: A descriptive field for your own information to enable better identification
        status:
          description: Status of the stocktake
          $ref: "#/components/schemas/StocktakeStatus"
        additional_info:
          type: string
          description: Additional notes or information about the stocktake
        created_date:
          type: string
          format: date-time
          description: Date when the stocktake was created
        completed_date:
          type: string
          format: date-time
          description: Date when the stocktake was completed
        set_remaining_items_as_counted:
          type: boolean
          description: Whether to set remaining uncounted items as counted
      example:
        stocktake_number: STK-2024-003
        location_id: 1
        reason: Quarterly inventory count - updated
        status: IN_PROGRESS
    CreateStocktakeRowRequest:
      description: Request payload for creating stocktake rows for counting specific variants
      type: object
      additionalProperties: false
      required:
        - stocktake_id
      properties:
        stocktake_id:
          type: integer
          description: ID of the stocktake this row belongs to
        stocktake_rows:
          type: array
          maxItems: 250
          description: Array of stocktake rows to create
          items:
            type: object
            additionalProperties: false
            required:
              - variant_id
            properties:
              variant_id:
                type: integer
                description: ID of the variant being counted
              batch_id:
                type:
                  - integer
                  - "null"
                description: ID of the specific batch being counted (required for batch-trackable items)
              notes:
                type:
                  - string
                  - "null"
                maxLength: 540
                description: Optional notes about the count
              counted_quantity:
                type:
                  - number
                  - "null"
                minimum: 0
                description: The actual quantity counted during the stocktake
      example:
        stocktake_id: 4001
        stocktake_rows:
          - variant_id: 3001
            counted_quantity: 147.0
            notes: Initial count
    UpdateStocktakeRowRequest:
      description: Request payload for updating an existing stocktake row
      type: object
      additionalProperties: false
      properties:
        variant_id:
          type: integer
          description: ID of the variant being counted
        batch_id:
          type:
            - integer
            - "null"
          description: ID of the specific batch being counted (required for batch-trackable items)
        bin_location_id:
          type:
            - integer
            - "null"
          description: ID of the bin location being counted (bin-tracked locations), or null.
        notes:
          type:
            - string
            - "null"
          maxLength: 540
          description: Optional notes about the count
        counted_quantity:
          type:
            - number
            - "null"
          minimum: 0
          description: The actual quantity counted during the stocktake
      example:
        variant_id: 3001
        batch_id: 501
        counted_quantity: 148.0
        notes: Recount confirmed minor variance
    SalesReturnListResponse:
      description: Response containing a list of sales returns with customer refund and return processing information
      type: object
      properties:
        data:
          type: array
          description: List of sales return records
          items:
            $ref: "#/components/schemas/SalesReturn"
      example:
        data:
          - id: 3001
            customer_id: 1001
            sales_order_id: 2001
            order_no: SR-2023-001
            return_location_id: 1
            status: RETURNED_ALL
            currency: USD
            return_date: "2023-10-15T14:30:00Z"
            order_created_date: "2023-10-10T10:00:00Z"
            additional_info: Customer reported damaged items
            refund_status: REFUNDED
    SalesReturnRowListResponse:
      description: Response containing a list of sales return row items with product return details and quantities
      type: object
      properties:
        data:
          type: array
          description: List of sales return row items
          items:
            $ref: "#/components/schemas/SalesReturnRow"
      example:
        data:
          - id: 3501
            sales_return_id: 3001
            variant_id: 2002
            quantity: "2.0"
            return_reason_id: 1
            notes: Packaging was damaged
            unit_price: 25.0
            total_price: 50.0
    UserInfo:
      type: object
      description: Information about the currently authenticated user
      properties:
        id:
          type: integer
          description: Unique identifier for the user account
        firstName:
          type: string
          description: User's first name
        lastName:
          type: string
          description: User's last name
        email:
          type: string
          description: Email address used for login and notifications
      required:
        - id
        - firstName
        - lastName
        - email
      example:
        id: 42
        firstName: Jane
        lastName: Doe
        email: jane.doe@example.com
    UserListResponse:
      type: object
      description: List of system users with their account information and role assignments
      properties:
        data:
          type: array
          description: Array of user accounts with authentication and permission details
          items:
            $ref: "#/components/schemas/User"
      example:
        data:
          - id: 42
            firstName: Sarah
            lastName: Johnson
            email: sarah.johnson@company.com
            role: production_manager
            status: active
            last_login_at: "2024-01-15T14:30:00Z"
            created_at: "2024-01-10T09:00:00Z"
            updated_at: "2024-01-15T14:30:00Z"
          - id: 43
            firstName: Mike
            lastName: Chen
            email: mike.chen@company.com
            role: inventory_coordinator
            status: active
            last_login_at: "2024-01-15T10:15:00Z"
            created_at: "2024-01-08T11:00:00Z"
            updated_at: "2024-01-15T10:15:00Z"
    OutsourcedPurchaseOrderRecipeRowListResponse:
      description: |
        Response containing a list of outsourced purchase order recipe rows for externally manufactured products
      type: object
      properties:
        data:
          type: array
          description: List of outsourced purchase order recipe row records
          items:
            $ref: "#/components/schemas/OutsourcedPurchaseOrderRecipeRow"
      example:
        data:
          - id: 6001
            material_id: 1
            purchase_order_id: 1001
            purchase_order_row_id: 1001
            variant_id: 2002
            ingredient_variant_id: 2002
            planned_quantity_per_unit: 2.5
            ingredient_availability: IN_STOCK
            ingredient_expected_date: "2023-10-15T08:00:00Z"
            notes: Supplier will handle assembly
    OutsourcedPurchaseOrderRecipeRow:
      description: Recipe ingredient row for outsourced purchase orders defining material requirements and availability
      allOf:
        - type: object
          properties:
            id:
              type: integer
            purchase_order_id:
              type: integer
              description: The purchase order this recipe row belongs to
            purchase_order_row_id:
              type: integer
              description: The purchase order row this recipe ingredient is linked to
            ingredient_variant_id:
              type: integer
              description: The variant of the ingredient material required
            planned_quantity_per_unit:
              type:
                - string
                - number
              description: >-
                Quantity per unit: a decimal string on create and a JSON number on read
            ingredient_availability:
              description: Current availability status of this ingredient
              $ref: "#/components/schemas/OutsourcedRecipeIngredientAvailability"
            ingredient_expected_date:
              type:
                - string
                - "null"
              format: date-time
              description: Expected date when this ingredient will be available
            notes:
              type:
                - string
                - "null"
              description: Additional notes about this ingredient requirement
            batch_transactions:
              type: array
              items:
                type: object
                properties:
                  batch_id:
                    type:
                      - integer
                      - "null"
                  quantity:
                    type: number
              description: Batch allocation transactions for this ingredient
            cost:
              type:
                - number
                - "null"
              description: Cost associated with this ingredient
          required:
            - purchase_order_row_id
            - ingredient_variant_id
            - planned_quantity_per_unit
        - $ref: "#/components/schemas/DeletableEntity"
    ProductOperationRerankRequest:
      description:
        Request payload for reordering product operations within a manufacturing workflow to optimize production
        sequence
      type: object
      required:
        - rank_product_operation_id
      properties:
        rank_product_operation_id:
          type: integer
          description: ID of the product operation to be reordered
        preceding_product_operation_id:
          type: integer
          description: ID of the operation that should precede the operation being moved
        should_group:
          type: boolean
          description: Whether operations should be grouped together in the sequence
      example:
        rank_product_operation_id: 501
        preceding_product_operation_id: 499
        should_group: true
    ProductOperationRerank:
      description: Response confirming the success of a product operation reordering request
      type: object
      properties:
        message:
          type: string
          description: Status message about the reordering operation
        success:
          type: boolean
          description: Whether the reordering operation was successful
      example:
        message: Product operation successfully reordered
        success: true
    SalesOrderAccountingMetadataListResponse:
      description: |
        Response containing a list of accounting metadata records linking sales orders to external accounting systems
      type: object
      properties:
        data:
          type: array
          description: Array of accounting metadata records with integration and invoice information
          items:
            $ref: "#/components/schemas/SalesOrderAccountingMetadata"
      example:
        data:
          - id: 2901
            sales_order_id: 2001
            fulfillment_id: 2701
            invoice_id: INV-2024-001
            integration_type: xero
            created_at: "2024-01-20T17:00:00Z"
    SalesOrderAccountingMetadata:
      description: |
        Accounting integration metadata linking sales orders to external accounting systems and invoice records
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the accounting metadata record
        sales_order_id:
          type: integer
          description: ID of the sales order linked to accounting system
        fulfillment_id:
          type: integer
          description: ID of the fulfillment record associated with this accounting entry
        invoice_id:
          type: string
          description: Invoice identifier in the external accounting system
        integration_type:
          description: Type of accounting system integration used
          $ref: "#/components/schemas/AccountingIntegrationType"
        created_at:
          type: string
          format: date-time
          description: Date and time when the accounting metadata was created
      required:
        - id
        - sales_order_id
        - invoice_id
        - integration_type
        - created_at
        - fulfillment_id
      example:
        id: 2901
        sales_order_id: 2001
        fulfillment_id: 2701
        invoice_id: INV-2024-001
        integration_type: xero
        created_at: "2024-01-20T17:00:00Z"
    SalesOrderShippingFeeListResponse:
      description: Response containing a list of shipping fees associated with sales orders
      type: object
      properties:
        data:
          type: array
          description: Array of shipping fee records with costs and tax information
          items:
            $ref: "#/components/schemas/SalesOrderShippingFee"
      example:
        data:
          - id: 2801
            sales_order_id: 2001
            amount: "25.99"
            tax_rate_id: 301
            description: UPS Ground Shipping
    SalesOrderShippingFee:
      description: Shipping fee record associated with a sales order, tracking shipping costs and applicable taxes
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the shipping fee record
        sales_order_id:
          type: integer
          description: ID of the sales order this shipping fee applies to
        amount:
          type:
            - string
            - number
          description: |
            Shipping fee amount in the order currency. Creation returns a
            JSON number; list, detail, and update responses return decimal
            strings. Preserve the wire representation in either case.
        tax_rate_id:
          type: integer
          description: ID of the tax rate applied to the shipping fee
        description:
          type:
            - string
            - "null"
          description: Description of the shipping service or fee type
      required:
        - id
        - sales_order_id
        - amount
      example:
        id: 2801
        sales_order_id: 2001
        amount: "25.99"
        tax_rate_id: 301
        description: UPS Ground Shipping
    CreateSalesOrderShippingFeeRequest:
      description: Request payload for adding a shipping fee to an existing sales order
      type: object
      additionalProperties: false
      required:
        - sales_order_id
        - amount
      properties:
        sales_order_id:
          type: integer
          description: ID of the sales order to add shipping fee to
        amount:
          type: string
          description: |
            Shipping fee amount in the order currency. Sent as a string to
            preserve exact decimal precision (Katana's wire format).
        description:
          type: string
          description: Description of the shipping service or fee type
        tax_rate_id:
          type: integer
          description: ID of the tax rate to apply to the shipping fee
      example:
        sales_order_id: 2001
        amount: "25.99"
        description: |-
          Express Shipping - Next Day Delivery
        tax_rate_id: 301
    BatchTransactionRequest:
      description: Batch allocation transaction for tracking inventory lots
      type: object
      additionalProperties: false
      required:
        - batch_id
        - quantity
      properties:
        batch_id:
          type: integer
          description: Batch ID
        quantity:
          type: number
          description: Quantity
    UpdateCustomerAddressRequest:
      description: Request payload for updating an existing customer address
      type: object
      properties:
        first_name:
          type:
            - string
            - "null"
          description: Updated first name for the contact person at this address
        last_name:
          type:
            - string
            - "null"
          description: Updated last name for the contact person at this address
        company:
          type:
            - string
            - "null"
          description: Updated company name for business addresses
        phone:
          type:
            - string
            - "null"
          description: Updated phone number for this address location
        line_1:
          type:
            - string
            - "null"
          description: Updated primary address line (street address, building number)
        line_2:
          type:
            - string
            - "null"
          description: Updated secondary address line (apartment, suite, floor)
        city:
          type:
            - string
            - "null"
          description: Updated city or locality name
        state:
          type:
            - string
            - "null"
          description: Updated state, province, or region
        zip:
          type:
            - string
            - "null"
          description: Updated postal code or ZIP code
        country:
          type:
            - string
            - "null"
          description: Updated country name or country code
    CreateInventoryReorderPointRequest:
      description: Request payload for creating a new inventory reorder point
      type: object
      additionalProperties: false
      required:
        - variant_id
        - location_id
        - value
      properties:
        variant_id:
          type: integer
          description: Product variant ID
        location_id:
          type: integer
          description: Location ID
        value:
          type: number
          description: Minimum stock level that triggers reorder
          minimum: 0
    CreateInventorySafetyStockLevelRequest:
      description: Request payload for setting an inventory safety stock level (create or update)
      type: object
      additionalProperties: false
      required:
        - variant_id
        - location_id
        - value
      properties:
        variant_id:
          type: integer
          description: Product variant ID
        location_id:
          type: integer
          description: Location ID
        value:
          type: number
          description: Minimum quantity to maintain as safety stock buffer
          minimum: 0
    CreateOutsourcedPurchaseOrderRecipeRowRequest:
      description: Request payload for creating a new outsourced purchase order recipe row
      type: object
      additionalProperties: false
      required:
        - purchase_order_row_id
        - ingredient_variant_id
        - planned_quantity_per_unit
      properties:
        purchase_order_row_id:
          type: integer
          description: Purchase order row ID
        ingredient_variant_id:
          type: integer
          description: Ingredient variant ID
        planned_quantity_per_unit:
          type: number
          description: Planned quantity per unit of production
          minimum: 0
        notes:
          type: string
          description: Additional notes about this ingredient requirement
        batch_transactions:
          type: array
          description: Batch allocation transactions for this ingredient
          items:
            $ref: "#/components/schemas/BatchTransactionRequest"
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            supported definitions depend on the account.
    UpdateOutsourcedPurchaseOrderRecipeRowRequest:
      description: Request payload for updating an outsourced purchase order recipe row
      type: object
      additionalProperties: false
      properties:
        ingredient_variant_id:
          type: integer
          description: Ingredient variant ID. Updatable only when received_date is null.
        planned_quantity_per_unit:
          type: number
          description: Planned quantity per unit. Updatable only when received_date is null.
          minimum: 0
        notes:
          type: string
          description: Additional notes about this ingredient requirement
        batch_transactions:
          type: array
          description: Batch allocation transactions for this ingredient
          items:
            $ref: "#/components/schemas/BatchTransactionRequest"
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            supported definitions depend on the account.
    CreateProductOperationRowItem:
      description: A single product operation row item in a bulk create request
      type: object
      additionalProperties: false
      required:
        - product_variant_id
      properties:
        product_variant_id:
          type: integer
          minimum: 1
          maximum: 2147483647
          description: ID of the product variant that this operation row applies to
        operation_id:
          description: If operation ID is used to map the operation, then operation_name is ignored.
          type: integer
          minimum: 1
          maximum: 2147483647
        operation_name:
          description: |-
            If operation name is used to map the operation then,
            we match to the existing operations by name. If a match is not found, a new one is created.
          type: string
        resource_id:
          description: If resource ID is used to map the resource, then resource_name is ignored.
          type: integer
          minimum: 1
          maximum: 2147483647
        resource_name:
          description: |-
            If resource name is used to map the resource then we match to the existing resources by name.
            If a match is not found, a new one is created.
          type: string
        type:
          description: |-
            Different operation types allows you to use different cost
            calculations depending on the type of product operation
            Process: The process operation type is best for when products
            are individually built and time is the main driver of cost.
            Setup: The setup operation type is best for setting up a
            machine for production where the production quantity doesn't
            affect cost.
            Per unit: The per unit operation type is best when cost of
            time isn't a factor, but only the quantity of product made.
            Fixed cost: The fixed cost operation type is useful for adding
            the expected extra costs that go into producing a product.
          allOf:
            - $ref: "#/components/schemas/ProductOperationType"
          default: process
        cost_parameter:
          type: number
          description: |-
            The expected cost of an operation, either total or per hour/unit of product (based on type).
            Total cost of the operation on a manufacturing order is calculated as follows:
            process: cost = cost_parameter x planned_time_parameter (in hours) x product quantity
            setup: cost = cost_parameter x planned_time_parameter (in
            hours)
            perUnit: cost = cost_parameter x product quantity
            fixed: cost = cost_parameter
          maximum: 1000000000000000000
          minimum: 0
        cost_per_hour:
          type: number
          deprecated: true
          description: |-
            (This field is deprecated in favor of cost_parameter) The expected cost of an
            operation, either total or per hour/unit of product (based on type). Total cost
            of the operation on a manufacturing order is calculated as follows:
            process: cost = cost_parameter x planned_time_parameter (in hours) x product quantity
            setup: cost = cost_parameter x planned_time_parameter (in
            hours)
            perUnit: cost = cost_parameter x product quantity
            fixed: cost = cost_parameter
          maximum: 1000000000000000000
          minimum: 0
        planned_time_parameter:
          type: integer
          description:
            The planned duration of an operation, in seconds, to either manufacture one unit of a
            product or complete a manufacturing order (based on type).
          maximum: 2147483647
          minimum: 0
        planned_time_per_unit:
          type: integer
          deprecated: true
          description:
            (This field is deprecated in favor of planned_time_parameter)
            The planned duration of an operation, in seconds, to either
            manufacture one unit of a product or complete a manufacturing
            order (based on type).
          maximum: 2147483647
          minimum: 0
    CreateProductOperationRowsRequest:
      description: Request payload for creating product operation rows in bulk
      type: object
      additionalProperties: false
      required:
        - rows
      properties:
        keep_current_rows:
          type: boolean
          description: |-
            Existing production operation lines are kept by default,
            and new lines will be added after the existing product operations.
            Set to false to delete all existing product operation lines for related products.
        rows:
          type: array
          minItems: 1
          maxItems: 150
          description: List of product operation rows to create in this bulk request (max 150 per call)
          items:
            $ref: "#/components/schemas/CreateProductOperationRowItem"
    UpdateProductOperationRowRequest:
      description: Request payload for updating a product operation row
      type: object
      additionalProperties: false
      properties:
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: >-
            Custom field values keyed by definition ID. Accepts an object or
            null, not the legacy field_name/field_value array. Availability and
            allowed definitions depend on the account's custom-field configuration.
        operation_id:
          type: integer
          description: ID of the operation
        operation_name:
          type: string
          description: Name of the operation
        type:
          description: Type of operation defining how time and cost are calculated
          $ref: "#/components/schemas/ManufacturingOperationType"
        resource_id:
          type: integer
          description: ID of the resource performing the operation
        resource_name:
          type: string
          description: Name of the resource
        planned_time_parameter:
          type: number
          description: Parameter for calculating planned time
        planned_time_per_unit:
          type: number
          description: Planned time per unit
        cost_parameter:
          type: number
          description: Parameter for calculating cost
        cost_per_hour:
          type: number
          description: Hourly cost rate
    UpdateRecipeRowRequest:
      description: Request payload for updating a recipe row
      type: object
      additionalProperties: false
      properties:
        ingredient_variant_id:
          type: integer
          description: ID of the ingredient variant
        quantity:
          type: number
          description: Ingredient quantity required
          minimum: 0
        notes:
          type: string
          description: Additional notes about the recipe row
    SalesOrderFulfillmentRowRequest:
      description: A fulfillment row item specifying which order row and quantity to fulfill
      type: object
      properties:
        sales_order_row_id:
          type: integer
          description: Sales order row ID
        quantity:
          type: number
          description: Quantity to fulfill
        serial_numbers:
          type: array
          description: Serial number IDs allocated to this fulfillment row. Required
            when the row's variant is serial-tracked; the count must equal `quantity`.
          items:
            type: integer
        traceability:
          type: array
          description: >-
            Unified batch/serial/bin allocations for the fulfilled quantity.
            The current way to attach serial-tracked units — an alternative to
            the flat `serial_numbers` array that also carries batch and bin
            context per allocation.
          items:
            $ref: "#/components/schemas/TraceabilityRequest"
    CreateSalesOrderFulfillmentRequest:
      description: Request payload for creating a new sales order fulfillment
      type: object
      additionalProperties: false
      required:
        - sales_order_id
        - status
        - sales_order_fulfillment_rows
      properties:
        sales_order_id:
          type: integer
          description: Sales order ID
        picked_date:
          type: string
          format: date-time
          description: Date when items were picked
        status:
          description: Fulfillment status
          $ref: "#/components/schemas/SalesOrderFulfillmentStatus"
        conversion_rate:
          type: number
          description: Currency conversion rate
        conversion_date:
          type: string
          format: date-time
          description: Date of currency conversion
        tracking_number:
          type: string
          maxLength: 256
          description: Shipment tracking number
        tracking_url:
          type: string
          maxLength: 2048
          description: URL for tracking the shipment
        tracking_carrier:
          type: string
          description: Shipping carrier name
        tracking_method:
          type: string
          description: Shipping method used
        sales_order_fulfillment_rows:
          type: array
          description: Fulfillment row items
          items:
            $ref: "#/components/schemas/SalesOrderFulfillmentRowRequest"
    UpdateSalesOrderFulfillmentRequest:
      description: Request payload for updating a sales order fulfillment
      type: object
      additionalProperties: false
      properties:
        picked_date:
          type: string
          format: date-time
          description: Date when items were picked
        status:
          description: Fulfillment status
          $ref: "#/components/schemas/SalesOrderFulfillmentStatus"
        conversion_rate:
          type: number
          description: Currency conversion rate
        packer_id:
          type: integer
          description: ID of the packer who packed the order
        conversion_date:
          type: string
          format: date-time
          description: Date of currency conversion
        tracking_number:
          type: string
          maxLength: 256
          description: Shipment tracking number
        tracking_url:
          type: string
          maxLength: 2048
          description: URL for tracking the shipment
        tracking_carrier:
          type: string
          description: Shipping carrier name
        tracking_method:
          type: string
          description: Shipping method used
    UpdateSalesOrderShippingFeeRequest:
      description: Request payload for updating a sales order shipping fee
      type: object
      additionalProperties: false
      required:
        - amount
      properties:
        description:
          type: string
          description: Shipping fee description
        amount:
          type: string
          description: |
            Shipping fee amount. Sent as a string to preserve exact decimal
            precision (Katana's wire format).
        tax_rate_id:
          type: integer
          description: ID of the tax rate to apply to the shipping fee
    UpdateSalesOrderRequest:
      description: Request payload for updating a sales order
      type: object
      additionalProperties: false
      properties:
        order_no:
          type: string
          description: Updatable only when sales order status is NOT_SHIPPED or PENDING.
          minLength: 1
        customer_id:
          type: integer
          description: Updatable only when sales order status is NOT_SHIPPED or PENDING.
          maximum: 2147483647
        order_created_date:
          type: string
          format: date-time
          description: Date when the order was originally created
        delivery_date:
          type: string
          format: date-time
          description: Updatable in all sales order statuses except DELIVERED.
        picked_date:
          type: string
          format: date-time
          description: |
            Sales-order-level pick date. Updatable only when sales order status
            is ``NOT_SHIPPED`` or ``PENDING``.

            **Cascading update:** patching this field rewrites ``picked_date``
            on **every** linked fulfillment to match. For per-fulfillment pick
            dates, patch
            ``/sales_order_fulfillments/{id}`` directly instead.
        location_id:
          type: integer
          description: Updatable only when sales order status is NOT_SHIPPED or PENDING.
          maximum: 2147483647
        status:
          description:
            When the status is omitted, NOT_SHIPPED is used as default. Use PENDING when you want to create
            sales order quotes.
          $ref: "#/components/schemas/UpdateSalesOrderStatus"
        currency:
          type: string
          description: |-
            E.g. USD, EUR. All currently active currency codes in ISO 4217 format. Updatable only when sales
            order status is NOT_SHIPPED or PENDING.
        conversion_rate:
          type: number
          description:
            Updatable only when sales order status is PACKED or DELIVERED, otherwise it will fail with
            422.
        conversion_date:
          type: string
          description:
            Updatable only when sales order status is PACKED or DELIVERED, otherwise it will fail with
            422.
        additional_info:
          type:
            - string
            - "null"
          description: Additional notes or instructions for the sales order
        customer_ref:
          type:
            - string
            - "null"
          description: Customer's reference number or purchase order number
          maxLength: 255
        tracking_number:
          type:
            - string
            - "null"
          description: Shipping carrier tracking number for package tracking
          maxLength: 256
        tracking_number_url:
          type:
            - string
            - "null"
          description: URL link to track the shipment on carrier website
          maxLength: 2048
        custom_fields:
          type:
            - object
            - "null"
          additionalProperties: true
          description: |
            Custom field values for the sales order, keyed by the
            definition ``id`` (UUID) — the ``id`` returned by
            ``GET /custom_field_definitions``, not the field label. Each
            value matches the definition's ``field_type``: string for
            ``shortText`` / ``url``, number for ``number``, boolean for
            ``boolean``, a ``YYYY-MM-DD`` string for ``date``, or the
            integer choice ``id`` for ``singleSelect``.

            On ``PATCH`` the object is **merged** with the existing values,
            not replaced:

            - omit the ``custom_fields`` key — existing values unchanged;
            - ``{"<id>": value}`` — that key is set / overwritten, all
              other keys kept;
            - ``null`` — all custom field values on the order are cleared.

            Keys are tenant-specific, so the schema declares
            ``additionalProperties: true`` rather than enumerating them.
    UpdateSalesReturnRowRequest:
      description: Request payload for updating a sales return row
      type: object
      additionalProperties: false
      properties:
        quantity:
          type: number
          description: Quantity being returned. Updatable only when current return status is NOT_RETURNED.
        restock_location_id:
          type: integer
          description: Restock location ID. Updatable only when current return status is NOT_RETURNED or RETURNED.
        reason_id:
          type: integer
          description: Reason ID. Updatable only when current return status is NOT_RETURNED.
        batch_transactions:
          type: array
          description: Batch transactions. Updatable only when current return status is NOT_RETURNED or RETURNED.
          minItems: 1
          items:
            $ref: "#/components/schemas/BatchTransactionRequest"
    CreateSerialNumbersRequest:
      description: >-
        Attach existing serial-number strings to a resource. Only resource_id is required by the
        gateway. Omitting resource_type is accepted as a no-op (204 No Content);
        supply resource_type and serial_numbers to attempt an attachment (#830,
        #983). Unknown strings abort with 422; this endpoint did not mint new
        strings in current live probes.
      type: object
      additionalProperties: false
      required:
        - resource_id
      properties:
        resource_type:
          description: Resource type
          $ref: "#/components/schemas/CreateSerialNumberResourceType"
        resource_id:
          type: integer
          description: Resource ID
        serial_numbers:
          type: array
          description: List of existing serial-number strings to attach
          items:
            type: string
    DeleteSerialNumbersRequest:
      description: |
        Request payload for deleting serial numbers from a resource. The
        delete is scoped to a single resource (``resource_type`` +
        ``resource_id``) and a list of serial-number IDs.
      type: object
      additionalProperties: false
      required:
        - resource_type
        - resource_id
        - ids
      properties:
        resource_type:
          description: Resource type the serial numbers belong to
          $ref: "#/components/schemas/SerialNumberResourceType"
        resource_id:
          type: integer
          description: Resource ID the serial numbers belong to
        ids:
          type: array
          minItems: 1
          description: Serial number IDs to delete
          items:
            type: integer
      example:
        resource_type: ManufacturingOrder
        resource_id: 3001
        ids:
          - 1001
          - 1002
    StockTransferRowRequest:
      description: A stock transfer row item specifying which variant and quantity to transfer
      type: object
      properties:
        variant_id:
          type: integer
          description: Product variant ID
        quantity:
          type: string
          description: |
            Quantity to transfer, as a fixed-precision decimal string
            (e.g. ``"1.0000000000"``).
        traceability:
          type: array
          description: >-
            Unified batch/serial/bin allocations for the transferred quantity.
            Use a non-null `serial_number_id` per entry to move specific
            serial-tracked units between locations.
          items:
            $ref: "#/components/schemas/TraceabilityRequest"
    CreateStockTransferRequest:
      description: Request payload for creating a new stock transfer
      type: object
      additionalProperties: false
      required:
        - source_location_id
        - target_location_id
        - stock_transfer_rows
      properties:
        stock_transfer_number:
          type: string
          minLength: 1
          description: Unique stock transfer number for tracking
        source_location_id:
          type: integer
          description: Source location ID where items are transferred from
        target_location_id:
          type: integer
          description: Destination location ID where items are transferred to
        transfer_date:
          type: string
          format: date-time
          description: Date when the transfer was initiated
        order_created_date:
          type: string
          format: date-time
          description: Date when the transfer order was created
        expected_arrival_date:
          type: string
          format: date-time
          description: Expected arrival date at destination
        additional_info:
          type: string
          description: Additional notes or information about the transfer
        stock_transfer_rows:
          type: array
          description: Line items being transferred
          items:
            $ref: "#/components/schemas/StockTransferRowRequest"
    UpdateStockTransferRequest:
      description: Request payload for updating a stock transfer
      type: object
      additionalProperties: false
      properties:
        stock_transfer_number:
          type: string
          description: Updated stock transfer number
        transfer_date:
          type: string
          format: date-time
          description: Updated transfer date
        order_created_date:
          type: string
          format: date-time
          description: Updated order creation date
        expected_arrival_date:
          type: string
          format: date-time
          description: Updated expected arrival date
        additional_info:
          type: string
          description: Updated additional notes or information
    UpdateStockTransferStatusRequest:
      description: Request payload for updating a stock transfer status
      type: object
      additionalProperties: false
      properties:
        status:
          description: New status for the stock transfer
          $ref: "#/components/schemas/StockTransferStatus"
    LocationListResponse:
      description: Response containing a list of locations
      type: object
      properties:
        data:
          type: array
          description: Array of locations returned by this page of the list response
          items:
            $ref: "#/components/schemas/Location"
    ProductOperationRowListResponse:
      description: Response containing a list of product operation rows
      type: object
      properties:
        data:
          type: array
          description: Array of product operation rows returned by this page of the list response
          items:
            $ref: "#/components/schemas/ProductOperationRow"
    ReturnableItem:
      description: An item from a sales order that is eligible for return
      type: object
      required:
        - variant_id
        - fulfillment_row_id
        - available_for_return_quantity
        - net_price_per_unit
        - location_id
        - quantity_sold
      properties:
        variant_id:
          type: integer
          description: Product variant ID
        fulfillment_row_id:
          type: integer
          description: Fulfillment row ID
        available_for_return_quantity:
          type: string
          description: Quantity available for return
        net_price_per_unit:
          type: string
          description: Net price per unit
        location_id:
          type: integer
          description: Location ID
        quantity_sold:
          type: string
          description: Total quantity sold
    UnassignedBatchTransaction:
      description: A batch transaction not yet assigned to a sales return row
      type: object
      properties:
        id:
          type: integer
          description: Batch transaction ID
        batch_id:
          type: integer
          description: Batch ID
        quantity:
          type: number
          description: Transaction quantity
        status:
          type: string
          description: Transaction status
    UnassignedBatchTransactionListResponse:
      description: Response containing a list of unassigned batch transactions
      type: object
      properties:
        data:
          type: array
          description: Array of unassigned batch transactions returned by this page of the list response
          items:
            $ref: "#/components/schemas/UnassignedBatchTransaction"
    SalesReturnReason:
      description: A reason for returning items from a sales order
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          description: Return reason ID
        name:
          type: string
          description: Return reason name

paths:
  /additional_costs:
    get:
      summary: List all additional costs
      tags:
        - Additional costs
      description: Returns a list of additional costs you've previously created.
      operationId: getAdditionalCosts
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List all additional costs
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AdditionalCostListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /batches:
    post:
      summary: Create a batch
      tags:
        - Batch
      description: Creates a batch object.
      operationId: createBatch
      requestBody:
        description: New batch values
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Batch"
      responses:
        "200":
          description: Batch stock created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /batch_stocks:
    get:
      summary: List current batch stock
      tags:
        - Batch
      description: |-
        Returns a list for current batch stock. The inventory is returned in sorted order, based on location_id ASC,
        variant_id ASC, and batch_id DESC.
      operationId: getBatchStock
      parameters:
        - $ref: "#/components/parameters/batch_id"
        - $ref: "#/components/parameters/batch_number"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/variant_id"
        - $ref: "#/components/parameters/batch_barcode"
        - $ref: "#/components/parameters/batch_created_at_min"
        - $ref: "#/components/parameters/batch_created_at_max"
        - $ref: "#/components/parameters/include_empty"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List batch stock
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchStockListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /batch_stocks/{id}:
    patch:
      summary: Update batch details
      tags:
        - Batch
      description: |-
        Updates the specified batch details by setting the values of the parameters passed. Any parameters not provided
        will be left unchanged.
      operationId: updateBatchStock
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Batch stock fields to be updated with new values
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BatchStockUpdate"
      responses:
        "200":
          description: Batch stock updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BatchResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_inventory:
    get:
      summary: List bin inventory levels
      tags:
        - Storage bin
      description: |-
        Returns per-bin inventory levels at the chosen granularity. `granularity=VARIANT` (default) returns
        one row per (location, variant, bin); `BATCH` and `SERIAL_NUMBER` break rows down further by the
        matching traceability axis. Each row carries three decimal-string quantities: `quantity_in_stock`,
        `quantity_committed`, and `quantity_expected`.

        A null `bin_location_id`, `batch_id`, or `serial_number_id` denotes stock whose traceability on that
        axis has not been set (unassigned bin, unbatched stock, untraced serial). Pass `?<param>=null` to
        target those rows. Bin inventory levels are computed asynchronously and are eventually consistent.
      operationId: getBinInventory
      parameters:
        - name: granularity
          in: query
          required: false
          description: Row granularity. Defaults to `VARIANT`.
          schema:
            $ref: "#/components/schemas/BinInventoryGranularity"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/variant_id"
        - name: bin_location_id
          in: query
          required: false
          description: Filter by bin location ID. Pass `null` to target stock with no bin assignment.
          schema:
            type: string
            pattern: "^(\\d+|null)$"
        - name: batch_id
          in: query
          required: false
          description: Filter by batch ID. Pass `null` to target unbatched stock.
          schema:
            type: string
            pattern: "^(\\d+|null)$"
        - name: serial_number_id
          in: query
          required: false
          description: Filter by serial number ID. Pass `null` to target untraced serials.
          schema:
            type: string
            pattern: "^(\\d+|null)$"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: Per-bin inventory levels.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinInventoryListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_locations:
    get:
      summary: List all storage bins
      tags:
        - Storage bin
      description: |-
        Returns a list of storage bins you've previously created. The storage bins are returned in sorted order, with
        the most recent storage bin appearing first.
      operationId: getAllStorageBins
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/bin_name"
      responses:
        "200":
          description: |-
            List of storage bins. Unlike most Katana list endpoints, this one
            returns a bare JSON array on the wire rather than a `{ "data": [...] }`
            envelope (verified against the live API, 2026-06-03). See `/user_info`
            for the only other documented bare-array exception.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/StorageBinResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a storage bin
      tags:
        - Storage bin
      description: Creates a new storage bin at the specified location.
      operationId: createStorageBin
      requestBody:
        description: Storage bin details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StorageBinCreate"
      responses:
        "200":
          description: Storage bin created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorageBinResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_locations/{id}:
    patch:
      summary: Update a storage bin
      tags:
        - Storage bin
      description: |-
        Updates the specified storage bin by setting the values of the parameters passed. Any parameters not provided
        will be left unchanged.
      operationId: updateDefaultStorageBin
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Storage bin fields to be updated with new values
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StorageBinUpdate"
      responses:
        "200":
          description: Storage bin updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorageBinResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a storage bin
      tags:
        - Storage bin
      description: Deletes a storage bin by id.
      operationId: deleteStorageBin
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_transfers:
    get:
      summary: List all bin transfers
      tags:
        - Bin transfer
      description: Returns a list of bin transfers.
      operationId: getAllBinTransfers
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/include_deleted"
        - name: bin_transfer_number
          in: query
          required: false
          description: Filter by bin transfer number.
          schema:
            type: string
        - $ref: "#/components/parameters/location_id"
        - name: status
          in: query
          required: false
          description: Filter by bin transfer status.
          schema:
            $ref: "#/components/schemas/BinTransferStatus"
      responses:
        "200":
          description: List of bin transfers.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransferListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a bin transfer
      tags:
        - Bin transfer
      description: |-
        Creates a bin transfer, optionally with rows and per-row traceability in one
        call. Bin transfers move stock between bin locations within a single location.
        New transfers start in `CREATED`; status changes go through the status endpoint.
      operationId: createBinTransfer
      requestBody:
        description: Bin transfer details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBinTransferRequest"
      responses:
        "200":
          description: Bin transfer created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransfer"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_transfers/{id}:
    get:
      summary: Get a bin transfer
      tags:
        - Bin transfer
      description: Returns a single bin transfer by id.
      operationId: getBinTransfer
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Bin transfer details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransfer"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a bin transfer
      tags:
        - Bin transfer
      description: Updates a bin transfer's header fields.
      operationId: updateBinTransfer
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Bin transfer update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateBinTransferRequest"
      responses:
        "200":
          description: Bin transfer updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransfer"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a bin transfer
      tags:
        - Bin transfer
      description: Deletes a bin transfer.
      operationId: deleteBinTransfer
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_transfers/{id}/status:
    patch:
      summary: Update bin transfer status
      tags:
        - Bin transfer
      description: Updates the status of a bin transfer.
      operationId: updateBinTransferStatus
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Status update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateBinTransferStatusRequest"
      responses:
        "200":
          description: Bin transfer status updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransfer"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_transfer_rows:
    get:
      summary: List all bin transfer rows
      tags:
        - Bin transfer
      description: Returns a list of bin transfer rows.
      operationId: getAllBinTransferRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/include_deleted"
        - name: bin_transfer_id
          in: query
          required: false
          description: Filter by parent bin transfer ID.
          schema:
            type: integer
        - $ref: "#/components/parameters/variant_id"
        - name: source_bin_location_id
          in: query
          required: false
          description: Filter by source bin location ID.
          schema:
            type: integer
        - name: target_bin_location_id
          in: query
          required: false
          description: Filter by target bin location ID.
          schema:
            type: integer
      responses:
        "200":
          description: List of bin transfer rows.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransferRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a bin transfer row
      tags:
        - Bin transfer
      description: Adds a row to an existing bin transfer.
      operationId: createBinTransferRow
      requestBody:
        description: Bin transfer row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBinTransferRowRequest"
      responses:
        "200":
          description: Bin transfer row created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransferRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bin_transfer_rows/{id}:
    get:
      summary: Get a bin transfer row
      tags:
        - Bin transfer
      description: Returns a single bin transfer row by id.
      operationId: getBinTransferRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Bin transfer row details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransferRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a bin transfer row
      tags:
        - Bin transfer
      description: Updates a bin transfer row.
      operationId: updateBinTransferRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Bin transfer row update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateBinTransferRowRequest"
      responses:
        "200":
          description: Bin transfer row updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BinTransferRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a bin transfer row
      tags:
        - Bin transfer
      description: Deletes a bin transfer row.
      operationId: deleteBinTransferRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /inventory:
    get:
      summary: List current inventory
      tags:
        - Inventory
      description: |-
        Returns a list for current inventory. The inventory is returned in sorted order, with the oldest locations
        appearing first.
      operationId: getAllInventoryPoint
      parameters:
        - $ref: "#/components/parameters/location_id"
        - name: variant_id
          in: query
          required: false
          description: Filter by one or more variant IDs.
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/include_archived"
        - $ref: "#/components/parameters/extend_inventory"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List all inventories.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InventoryListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /inventory_movements:
    get:
      summary: List all inventory movements
      tags:
        - Inventory movements
      description: |-
        Returns a list of inventory movements created by your Katana resources. The inventory movements are returned in
        sorted order, with the most recent movements appearing first.
      operationId: getAllInventoryMovements
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/variant_ids"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/inventory_movement_resource_type"
        - $ref: "#/components/parameters/resource_id"
        - $ref: "#/components/parameters/caused_by_order_no"
        - $ref: "#/components/parameters/caused_by_resource_id"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List all inventory movements
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InventoryMovementListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /inventory_signals:
    get:
      summary: List inventory replenishment signals
      tags:
        - Inventory
      description: |-
        Returns a list of inventory replenishment signals, one per variant. Signals are account-wide, summed
          across all locations.

          Only variants with demand in the selected demand window have a row, so a variant_id filter can return fewer rows
          than ids requested. A missing row means no recent demand, not a missing variant - use /inventory for a
          full listing.
      operationId: getAllInventorySignals
      parameters:
        - name: demand_window
          in: query
          required: false
          description: Number of days of demand history used to calculate replenishment signals.
          schema:
            type: integer
            enum: [7, 30, 60, 90]
            default: 30
        - name: variant_id
          in: query
          required: false
          description: Filters signals by valid variant ids. A variant with no demand in the selected
            window has no row, so the response can contain fewer rows than ids requested.
          schema:
            type: array
            items:
              type: integer
        - name: stock_risk
          in: query
          required: false
          description: Filters signals by risk level - 0 low, 1 high, 2 critical, 3 stockout. Any
            other value is a 400.
          schema:
            type: integer
            enum:
              - 0
              - 1
              - 2
              - 3
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List all inventory replenishment signals
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InventorySignalListResponse"
              example:
                data:
                  - variant_id: 1
                    reorder_point: "49.00000000000000000000"
                    days_of_stock_left: 12
                    stock_risk: 1
                    in_stock: "42.00000000000000000000"
                    committed: "0.00000000000000000000"
                    safety_stock_breach_at: "2026-08-24T00:00:00.000Z"
                    expected_before_safety_stock_breach: "30.00000000000000000000"
                    safety_stock: "0.00000000000000000000"
                    lead_time_used: 14
                    lead_time_source: sku
                    demand_calculated_at: "2026-08-12T07:00:00.000Z"
                    avg_daily_demand: "3.50000000000000000000"
                    demand_window: 30
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /inventory_safety_stock_levels:
    post:
      summary: Create or update the safety stock level
      tags:
        - Inventory
      description: Create or update an item's safety stock level within a certain location and variant combination.
      operationId: createInventorySafetyStockLevel
      requestBody:
        description: Safety stock level details to set (create or update).
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateInventorySafetyStockLevelRequest"
      responses:
        "200":
          description: The created or updated inventory safety stock level.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InventorySafetyStockLevel"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /locations:
    get:
      summary: List all locations
      tags:
        - Location
      description: |-
        Returns a list of locations you've previously created. The locations are returned in sorted order, with the most
        recent locations appearing first.
      operationId: getAllLocations
      parameters:
        - $ref: "#/components/parameters/is_primary"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/legal_name"
        - $ref: "#/components/parameters/address_id"
        - $ref: "#/components/parameters/sales_allowed"
        - $ref: "#/components/parameters/manufacturing_allowed"
        - $ref: "#/components/parameters/purchases_allowed"
        - $ref: "#/components/parameters/rank"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List all locations
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LocationListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /locations/{id}:
    get:
      summary: Retrieve a location
      tags:
        - Location
      description: Retrieves the details of an existing location based on ID.
      operationId: getLocation
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Location
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Location"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_orders/search:
    post:
      summary: Search manufacturing orders
      tags:
        - Manufacturing order
      description: |
        Searches manufacturing orders using a structured filter body with nested
        logical operators (``and`` / ``or``) and per-field comparators.
        Only the fields in the filter schema may appear; unknown fields
        return 422. Custom field values are addressable via
        ``custom_fields.<uuid>`` nested paths. Returns the same shape as
        ``GET /manufacturing_orders`` — a paginated list of records.
      operationId: searchManufacturingOrders
      requestBody:
        description: Structured search body. See the schema for the field allowlist, operators, and caps.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ManufacturingOrderSearchRequest"
      responses:
        "200":
          description: Matching manufacturing orders
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderListResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_orders:
    post:
      summary: Create a manufacturing order
      tags:
        - Manufacturing order
      description: |-
        Creates a new manufacturing order object. Manufacturing order recipe and
          operation rows are created automatically based on the product recipe and operations.
      operationId: createManufacturingOrder
      requestBody:
        description: new manufacturing order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateManufacturingOrderRequest"
      responses:
        "200":
          description: New manufacturing order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrder"
              example:
                id: 21400
                status: NOT_STARTED
                order_no: SO-2 / 1
                variant_id: 1418016
                planned_quantity: 1
                actual_quantity: null
                location_id: 2327
                order_created_date: "2021-09-01T07:49:29.000Z"
                production_deadline_date: "2021-10-18T08:00:00.000Z"
                additional_info: ""
                is_linked_to_sales_order: true
                ingredient_availability: IN_STOCK
                total_cost: 0
                total_actual_time: 0
                total_planned_time: 18000
                sales_order_id: 1
                sales_order_row_id: 1
                sales_order_delivery_deadline: "2021-09-01T07:49:29.813Z"
                material_cost: 10
                created_at: "2021-09-01T07:49:29.813Z"
                updated_at: "2021-10-15T14:05:47.625Z"
                subassemblies_cost: 10
                operations_cost: 10
                deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all manufacturing orders
      tags:
        - Manufacturing order
      description: |-
        Returns a list of manufacturing orders you've previously created.
          The manufacturing orders are returned in sorted order, with the most recent manufacturing orders appearing
          first.
      operationId: getAllManufacturingOrders
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/manufacturing_order_status"
        - $ref: "#/components/parameters/order_no"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/is_linked_to_sales_order"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List all manufacturing orders
          headers:
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderListResponse"
              example:
                data:
                  - id: 21400
                    status: NOT_STARTED
                    order_no: SO-2 / 1
                    variant_id: 1418016
                    planned_quantity: 1
                    actual_quantity: null
                    location_id: 2327
                    order_created_date: "2021-09-01T07:49:29.000Z"
                    production_deadline_date: "2021-10-18T08:00:00.000Z"
                    additional_info: ""
                    is_linked_to_sales_order: true
                    ingredient_availability: IN_STOCK
                    total_cost: 0
                    total_actual_time: 0
                    total_planned_time: 18000
                    sales_order_id: 1
                    sales_order_row_id: 1
                    sales_order_delivery_deadline: "2021-09-01T07:49:29.813Z"
                    material_cost: 10
                    created_at: "2021-09-01T07:49:29.813Z"
                    updated_at: "2021-10-15T14:05:47.625Z"
                    subassemblies_cost: 10
                    operations_cost: 10
                    deleted_at: null
                    serial_numbers:
                      - id: 1
                        transaction_id: eb4da756-0842-4495-9118-f8135f681234
                        serial_number: SN1
                        resource_type: Production
                        resource_id: 2
                        transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_orders/{id}:
    get:
      summary: Retrieve a manufacturing order
      tags:
        - Manufacturing order
      description: Retrieves the details of an existing manufacturing order based on ID.
      operationId: getManufacturingOrder
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Manufacturing order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrder"
              example:
                id: 21400
                status: NOT_STARTED
                order_no: SO-2 / 1
                variant_id: 1418016
                planned_quantity: 1
                actual_quantity: null
                location_id: 2327
                order_created_date: "2021-09-01T07:49:29.000Z"
                production_deadline_date: "2021-10-18T08:00:00.000Z"
                additional_info: ""
                is_linked_to_sales_order: true
                ingredient_availability: IN_STOCK
                total_cost: 0
                total_actual_time: 0
                total_planned_time: 18000
                sales_order_id: 1
                sales_order_row_id: 1
                sales_order_delivery_deadline: "2021-09-01T07:49:29.813Z"
                material_cost: 10
                created_at: "2021-09-01T07:49:29.813Z"
                updated_at: "2021-10-15T14:05:47.625Z"
                subassemblies_cost: 10
                operations_cost: 10
                deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a manufacturing order
      tags:
        - Manufacturing order
      description: |-
        Updates the specified manufacturing order by setting the values of the parameters passed.
          Any parameters not provided will be left unchanged.
      operationId: updateManufacturingOrder
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: manufacturing order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateManufacturingOrderRequest"
      responses:
        "200":
          description: New manufacturing order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrder"
              example:
                id: 21400
                status: NOT_STARTED
                order_no: SO-2 / 1
                variant_id: 1418016
                planned_quantity: 1
                actual_quantity: null
                location_id: 2327
                order_created_date: "2021-09-01T07:49:29.000Z"
                production_deadline_date: "2021-10-18T08:00:00.000Z"
                additional_info: ""
                is_linked_to_sales_order: true
                ingredient_availability: IN_STOCK
                total_cost: 0
                total_actual_time: 0
                total_planned_time: 18000
                sales_order_id: 1
                sales_order_row_id: 1
                sales_order_delivery_deadline: "2021-09-01T07:49:29.813Z"
                material_cost: 10
                created_at: "2021-09-01T07:49:29.813Z"
                updated_at: "2021-10-15T14:05:47.625Z"
                subassemblies_cost: 10
                operations_cost: 10
                deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a manufacturing order
      tags:
        - Manufacturing order
      description: Deletes a single manufacturing order by id.
      operationId: deleteManufacturingOrder
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "412":
          $ref: "#/components/responses/PreconditionFailedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_make_to_order:
    post:
      summary: Create a make-to-order manufacturing order
      tags:
        - Manufacturing order
      description: Creates a new manufacturing order object that is linked to a specific sales order row.
      operationId: makeToOrderManufacturingOrder
      requestBody:
        description: new manufacturing order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MakeToOrderManufacturingOrderRequest"
      responses:
        "200":
          description: New linked manufacturing order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrder"
              example:
                id: 21400
                status: NOT_STARTED
                order_no: SO-2 / 1
                variant_id: 1418016
                planned_quantity: 1
                actual_quantity: null
                location_id: 2327
                order_created_date: "2021-09-01T07:49:29.000Z"
                production_deadline_date: "2021-10-18T08:00:00.000Z"
                additional_info: ""
                is_linked_to_sales_order: true
                ingredient_availability: IN_STOCK
                total_cost: 0
                total_actual_time: 0
                total_planned_time: 18000
                sales_order_id: 1
                sales_order_row_id: 1
                sales_order_delivery_deadline: "2021-09-01T07:49:29.813Z"
                material_cost: 10
                created_at: "2021-09-01T07:49:29.813Z"
                updated_at: "2021-10-15T14:05:47.625Z"
                subassemblies_cost: 10
                operations_cost: 10
                deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_rerank:
    post:
      summary: Change a manufacturing order's rank
      tags:
        - Manufacturing order
      description: |-
        Moves one or more manufacturing orders to an exact place in the production schedule.

        The manufacturing orders in `order_ids` are placed as one consecutive block, in the order given, at the place set in `place`. The first id ends up highest in the schedule. All other manufacturing orders keep their order relative to each other.

        `before_id` places them directly above that manufacturing order, and `after_id` directly below it. Sending the same request again changes nothing, so a request can be retried safely.

        Only open manufacturing orders can be reranked.

        Manufacturing orders linked to the same sales order always stay together. Listing one of them moves all of them, placed where the first of them is listed and keeping their order among themselves, and the response includes all of them, so it can list more than 250 ids. When `before_id` or `after_id` is a manufacturing order linked to a sales order, the orders are placed above or below all manufacturing orders of that sales order.

        To rerank more than 250 manufacturing orders, send them in batches: the first batch with `place.position` set to `top`, each next batch with `place.after_id` set to the last id in the previous response's `order_ids`. Keep manufacturing orders linked to the same sales order in the same batch.

        Manufacturing order lists show the new order shortly after the request returns.

        The request returns 422 when any of the manufacturing orders, including the one in `before_id` or `after_id`, doesn't exist or is not open, or when `before_id` or `after_id` is one of `order_ids` or is linked to the same sales order as one of them.
      operationId: rerankManufacturingOrder
      requestBody:
        description: manufacturing order rerank details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RerankManufacturingOrderRequest"
      responses:
        "204":
          description: Manufacturing order reranked successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
        '200':
          description: Manufacturing orders reranked
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RerankOrdersResponse'
              example:
                order_ids:
                  - 101
                  - 102
  /manufacturing_order_unlink:
    post:
      summary: Unlink a manufacturing order from sales order row
      tags:
        - Manufacturing order
      description: Unlinks the manufacturing order from a particular sales order row.
      operationId: unlinkManufacturingOrder
      requestBody:
        description: new manufacturing order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UnlinkManufacturingOrderRequest"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_productions:
    post:
      summary: Create a manufacturing order production
      tags:
        - Manufacturing order production
      description: Creates a new manufacturing order production object.
      operationId: createManufacturingOrderProduction
      requestBody:
        description: new manufacturing order production details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateManufacturingOrderProductionRequest"
      responses:
        "200":
          description: New manufacturing order production
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderProduction"
              example:
                id: 21300
                manufacturing_order_id: 21400
                quantity: 2
                production_date: "2023-02-10T10:06:13.047Z"
                created_at: "2023-02-10T10:06:14.425Z"
                updated_at: "2023-02-10T10:06:15.094Z"
                deleted_at: null
                ingredients:
                  - id: 252
                    location_id: 321
                    variant_id: 24764
                    manufacturing_order_id: 21400
                    manufacturing_order_recipe_row_id: 20300
                    production_id: 21300
                    quantity: 4
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 1
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:15.070Z"
                    deleted_at: null
                operations:
                  - id: 61
                    location_id: 321
                    manufacturing_order_id: 21300
                    manufacturing_order_operation_id: 20400
                    production_id: 21300
                    time: 18000
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 50
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:14.435Z"
                    deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all manufacturing orders
      tags:
        - Manufacturing order
      description: |-
        Returns a list of manufacturing orders you've previously created.
          The manufacturing orders are returned in sorted order, with the most recent manufacturing orders appearing
          first.
      operationId: getAllManufacturingOrderProductions
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/manufacturing_order_ids"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List all manufacturing order productions
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderProductionListResponse"
              example:
                data:
                  - id: 21300
                    manufacturing_order_id: 21400
                    quantity: 2
                    production_date: "2023-02-10T10:06:13.047Z"
                    created_at: "2023-02-10T10:06:14.425Z"
                    updated_at: "2023-02-10T10:06:15.094Z"
                    deleted_at: null
                    ingredients:
                      - id: 252
                        location_id: 321
                        variant_id: 24764
                        manufacturing_order_id: 21400
                        manufacturing_order_recipe_row_id: 20300
                        production_id: 21300
                        quantity: 4
                        production_date: "2023-02-10T10:06:13.047Z"
                        cost: 1
                        created_at: "2023-02-10T10:06:14.435Z"
                        updated_at: "2023-02-10T10:06:15.070Z"
                        deleted_at: null
                    operations:
                      - id: 61
                        location_id: 321
                        manufacturing_order_id: 21300
                        manufacturing_order_operation_id: 20400
                        production_id: 21300
                        time: 18000
                        production_date: "2023-02-10T10:06:13.047Z"
                        cost: 50
                        created_at: "2023-02-10T10:06:14.435Z"
                        updated_at: "2023-02-10T10:06:14.435Z"
                        deleted_at: null
                    serial_numbers:
                      - id: 1
                        transaction_id: eb4da756-0842-4495-9118-f8135f681234
                        serial_number: SN1
                        resource_type: Production
                        resource_id: 2
                        transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_productions/{id}:
    get:
      summary: Retrieve a manufacturing order production
      tags:
        - Manufacturing order production
      description: Retrieves the details of an existing manufacturing order production based on ID.
      operationId: getManufacturingOrderProduction
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Manufacturing order production
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderProduction"
              example:
                id: 21300
                manufacturing_order_id: 21400
                quantity: 2
                production_date: "2023-02-10T10:06:13.047Z"
                created_at: "2023-02-10T10:06:14.425Z"
                updated_at: "2023-02-10T10:06:15.094Z"
                deleted_at: null
                ingredients:
                  - id: 252
                    location_id: 321
                    variant_id: 24764
                    manufacturing_order_id: 21400
                    manufacturing_order_recipe_row_id: 20300
                    production_id: 21300
                    quantity: 4
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 1
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:15.070Z"
                    deleted_at: null
                operations:
                  - id: 61
                    location_id: 321
                    manufacturing_order_id: 21300
                    manufacturing_order_operation_id: 20400
                    production_id: 21300
                    time: 18000
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 50
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:14.435Z"
                    deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a manufacturing order production
      tags:
        - Manufacturing order production
      description: |-
        Updates the specified manufacturing order production by setting the values of the parameters passed.
          Any parameters not provided will be left unchanged.
      operationId: updateManufacturingOrderProduction
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: manufacturing order production details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateManufacturingOrderProductionRequest"
      responses:
        "200":
          description: Updated manufacturing order production
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderProduction"
              example:
                id: 21300
                manufacturing_order_id: 21400
                quantity: 2
                production_date: "2023-02-10T10:06:13.047Z"
                created_at: "2023-02-10T10:06:14.425Z"
                updated_at: "2023-02-10T10:06:15.094Z"
                deleted_at: null
                ingredients:
                  - id: 252
                    location_id: 321
                    variant_id: 24764
                    manufacturing_order_id: 21400
                    manufacturing_order_recipe_row_id: 20300
                    production_id: 21300
                    quantity: 4
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 1
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:15.070Z"
                    deleted_at: null
                operations:
                  - id: 61
                    location_id: 321
                    manufacturing_order_id: 21300
                    manufacturing_order_operation_id: 20400
                    production_id: 21300
                    time: 18000
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 50
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:14.435Z"
                    deleted_at: null
                serial_numbers:
                  - id: 1
                    transaction_id: eb4da756-0842-4495-9118-f8135f681234
                    serial_number: SN1
                    resource_type: Production
                    resource_id: 2
                    transaction_date: "2023-02-10T10:06:14.435Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a manufacturing order production
      tags:
        - Manufacturing order production
      description: Deletes a single manufacturing order production by id.
      operationId: deleteManufacturingOrderProduction
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_production_ingredients:
    get:
      summary: List all manufacturing order production ingredients
      tags:
        - Manufacturing order production ingredient
      description: |-
        Returns a list of ingredient consumption records across manufacturing order productions.
          Each record ties a consumed ingredient variant to the production batch and recipe row it was used for.
      operationId: getAllManufacturingOrderProductionIngredients
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/manufacturing_order_ids"
        - $ref: "#/components/parameters/production_ids"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List all manufacturing order production ingredients
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderProductionIngredientListResponse"
              example:
                data:
                  - id: 252
                    location_id: 321
                    variant_id: 24764
                    manufacturing_order_id: 21400
                    manufacturing_order_recipe_row_id: 20300
                    production_id: 21300
                    quantity: 4
                    production_date: "2023-02-10T10:06:13.047Z"
                    cost: 1
                    created_at: "2023-02-10T10:06:14.435Z"
                    updated_at: "2023-02-10T10:06:15.070Z"
                    deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_production_ingredients/{id}:
    patch:
      summary: Update a manufacturing order production ingredient
      tags:
        - Manufacturing order production ingredient
      description: |-
        Updates the specified manufacturing order production ingredient by setting the values of the parameters passed.
          Any parameters not provided will be left unchanged. Manufacturing order production ingredient cannot be
          updated when
          the manufacturing order status is DONE.
      operationId: updateManufacturingOrderProductionIngredient
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: manufacturing order production ingredient details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateManufacturingOrderProductionIngredientRequest"
      responses:
        "200":
          description: Updated manufacturing order production ingredient
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderProductionIngredientResponse"
              example:
                id: 252
                location_id: 321
                variant_id: 24001
                manufacturing_order_id: 21400
                manufacturing_order_recipe_row_id: 20300
                production_id: 21300
                quantity: 4
                production_date: "2023-02-10T10:06:13.047Z"
                cost: 1
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_operation_rows:
    post:
      summary: Create a manufacturing order operation row
      tags:
        - Manufacturing order operation
      description: |-
        Add an operation row to an existing manufacturing order. Operation rows cannot be added when the
          manufacturing order status is DONE.
      operationId: createManufacturingOrderOperationRow
      requestBody:
        description: new manufacturing order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateManufacturingOrderOperationRowRequest"
      responses:
        "200":
          description: New manufacturing order operation row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderOperationRow"
              example:
                id: 1
                status: IN_PROGRESS
                type: process
                rank: 1
                manufacturing_order_id: 1
                operation_id: 1
                operation_name: Pack
                resource_id: 1
                resource_name: Table
                assigned_operators:
                  - operator_id: 1
                    name: Pack
                    deleted_at: null
                completed_by_operators: []
                active_operator_id: 1
                planned_time_per_unit: "1"
                planned_time_parameter: "1"
                total_actual_time: "1"
                planned_cost_per_unit: "1"
                total_actual_cost: "1"
                cost_per_hour: "1"
                cost_parameter: "1"
                group_boundary: 1000
                is_status_actionable: true
                completed_at: "2020-10-23T10:37:05.085Z"
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all manufacturing order operation rows
      tags:
        - Manufacturing order operation
      description: |-
        Returns a list of manufacturing order operation rows you've previously created.
          The manufacturing order operation rows are returned in sorted order,
           with the most recent manufacturing order operation rows appearing first.
      operationId: getAllManufacturingOrderOperationRows
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/mo_operation_row_status"
        - $ref: "#/components/parameters/manufacturing_order_id"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List all manufacturing order operation rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderOperationRowListResponse"
              example:
                data:
                  - id: 1
                    status: IN_PROGRESS
                    type: process
                    rank: 1
                    manufacturing_order_id: 1
                    operation_id: 1
                    operation_name: Pack
                    resource_id: 1
                    resource_name: Table
                    assigned_operators:
                      - operator_id: 1
                        name: Pack
                        deleted_at: null
                    completed_by_operators: []
                    active_operator_id: 1
                    planned_time_per_unit: "1"
                    planned_time_parameter: "1"
                    total_actual_time: "1"
                    planned_cost_per_unit: "1"
                    total_actual_cost: "1"
                    cost_per_hour: "1"
                    cost_parameter: "1"
                    group_boundary: 1000
                    is_status_actionable: true
                    completed_at: "2020-10-23T10:37:05.085Z"
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_operation_rows/{id}:
    get:
      summary: Retrieve a manufacturing order operation row
      tags:
        - Manufacturing order operation
      description: Retrieves the details of an existing manufacturing order operation row.
      operationId: getManufacturingOrderOperationRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Manufacturing order operation row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderOperationRow"
              example:
                id: 1
                status: IN_PROGRESS
                type: process
                rank: 1
                manufacturing_order_id: 1
                operation_id: 1
                operation_name: Pack
                resource_id: 1
                resource_name: Table
                assigned_operators:
                  - operator_id: 1
                    name: Pack
                    deleted_at: null
                completed_by_operators: []
                active_operator_id: 1
                planned_time_per_unit: "1"
                planned_time_parameter: "1"
                total_actual_time: "1"
                planned_cost_per_unit: "1"
                total_actual_cost: "1"
                cost_per_hour: "1"
                cost_parameter: "1"
                group_boundary: 1000
                is_status_actionable: true
                completed_at: "2020-10-23T10:37:05.085Z"
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a manufacturing order operation row
      tags:
        - Manufacturing order operation
      description: |-
        Updates the specified manufacturing order operation row by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged. Only completed_by_operators and total_actual_time can be
            updated when the manufacturing order status is DONE
      operationId: updateManufacturingOrderOperationRow
      requestBody:
        description: manufacturing order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateManufacturingOrderOperationRowRequest"
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: New manufacturing order operation row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderOperationRow"
              example:
                id: 1
                status: IN_PROGRESS
                type: process
                rank: 1
                manufacturing_order_id: 1
                operation_id: 1
                operation_name: Pack
                resource_id: 1
                resource_name: Table
                assigned_operators:
                  - operator_id: 1
                    name: Pack
                    deleted_at: null
                completed_by_operators: []
                active_operator_id: 1
                planned_time_per_unit: "1"
                planned_time_parameter: "1"
                total_actual_time: "1"
                planned_cost_per_unit: "1"
                total_actual_cost: "1"
                cost_per_hour: "1"
                cost_parameter: "1"
                group_boundary: 1000
                is_status_actionable: true
                completed_at: "2020-10-23T10:37:05.085Z"
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a manufacturing order operation row
      tags:
        - Manufacturing order operation
      description: Deletes a single manufacturing order operation row by id.
      operationId: deleteManufacturingOrderOperationRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_recipe_rows:
    post:
      summary: Create a manufacturing order recipe row
      tags:
        - Manufacturing order recipe
      description: |-
        Add a recipe row to an existing manufacturing order.
          Recipe rows cannot be added when the manufacturing order status is DONE.
      operationId: createManufacturingOrderRecipeRows
      requestBody:
        description: new manufacturing order recipe details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateManufacturingOrderRecipeRowRequest"
      responses:
        "200":
          description: New manufacturin order operation row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderRecipeRow"
              example:
                id: 1
                manufacturing_order_id: 1
                variant_id: 1
                notes: Pay close attention to this
                planned_quantity_per_unit: "1.2000000000"
                total_actual_quantity: "12.0000000000"
                ingredient_availability: IN_STOCK
                ingredient_expected_date: "2021-03-18T12:33:39.957Z"
                batch_transactions:
                  - batch_id: 11
                    quantity: 7.4
                  - batch_id: 12
                    quantity: 4.6
                cost: "50.4000000000"
                created_at: "2021-02-18T12:33:39.957Z"
                updated_at: "2021-02-18T12:33:39.957Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all manufacturing order recipe rows
      tags:
        - Manufacturing order recipe
      description: |-
        Returns a list of manufacturing order recipe rows you've previously created. The manufacturing order
          recipe rows are returned in sorted order, with the most recent manufacturing order recipe rows appearing
          first.
      operationId: getAllManufacturingOrderRecipeRows
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/manufacturing_order_id"
        - $ref: "#/components/parameters/variant_id"
        - $ref: "#/components/parameters/ingredient_availability"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List all manufacturing order recipe rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderRecipeRowListResponse"
              example:
                data:
                  - id: 1
                    manufacturing_order_id: 1
                    variant_id: 1
                    notes: Pay close attention to this
                    planned_quantity_per_unit: "1.2000000000"
                    total_actual_quantity: "12.0000000000"
                    ingredient_availability: IN_STOCK
                    ingredient_expected_date: "2021-03-18T12:33:39.957Z"
                    batch_transactions:
                      - batch_id: 11
                        quantity: 7.4
                      - batch_id: 12
                        quantity: 4.6
                    cost: "50.4000000000"
                    created_at: "2021-02-18T12:33:39.957Z"
                    updated_at: "2021-02-18T12:33:39.957Z"
                    deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /manufacturing_order_recipe_rows/{id}:
    get:
      summary: Retrieve a manufacturing order recipe row
      tags:
        - Manufacturing order recipe
      description: Retrieves the details of an existing manufacturing order recipe row.
      operationId: getManufacturingOrderRecipeRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Manufacturing order recipe rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderRecipeRow"
              example:
                id: 1
                manufacturing_order_id: 1
                variant_id: 1
                notes: Pay close attention to this
                planned_quantity_per_unit: "1.2000000000"
                total_actual_quantity: "12.0000000000"
                ingredient_availability: IN_STOCK
                ingredient_expected_date: "2021-03-18T12:33:39.957Z"
                batch_transactions:
                  - batch_id: 11
                    quantity: 7.4
                  - batch_id: 12
                    quantity: 4.6
                cost: "50.4000000000"
                created_at: "2021-02-18T12:33:39.957Z"
                updated_at: "2021-02-18T12:33:39.957Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a manufacturing order recipe row
      tags:
        - Manufacturing order recipe
      description: |-
        Updates the specified manufacturing order recipe row by setting the values of the parameters passed.
          Any parameters not provided will be left unchanged. Recipe rows cannot be updated when
          the manufacturing order status is DONE.
      operationId: updateManufacturingOrderRecipeRows
      requestBody:
        description: manufacturing order recipe details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateManufacturingOrderRecipeRowRequest"
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: New manufacturin order operation row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ManufacturingOrderRecipeRow"
              example:
                id: 1
                manufacturing_order_id: 1
                variant_id: 1
                notes: Pay close attention to this
                planned_quantity_per_unit: "1.2000000000"
                total_actual_quantity: "12.0000000000"
                ingredient_availability: IN_STOCK
                ingredient_expected_date: "2021-03-18T12:33:39.957Z"
                batch_transactions:
                  - batch_id: 11
                    quantity: 7.4
                  - batch_id: 12
                    quantity: 4.6
                cost: "50.4000000000"
                created_at: "2021-02-18T12:33:39.957Z"
                updated_at: "2021-02-18T12:33:39.957Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a manufacturing order recipe row
      tags:
        - Manufacturing order recipe
      description: Deletes a single manufacturing order recipe row by id.
      operationId: deleteManufacturingOrderRecipeRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /materials:
    post:
      summary: Create a material
      tags:
        - Material
      description: Creates a material object.
      operationId: createMaterial
      requestBody:
        description: new material details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateMaterialRequest"
      parameters:
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: New material created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Material"
              example:
                id: 1
                name: Kyber Crystal
                uom: pcs
                category_name: Lightsaber components
                default_supplier_id: 1
                type: material
                purchase_uom: null
                purchase_uom_conversion_rate: null
                batch_tracked: false
                is_sellable: false
                variants:
                  - id: 1
                    sku: KC
                    sales_price: null
                    purchase_price: 45
                    type: material
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    lead_time: 1
                    minimum_order_quantity: 3
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    internal_barcode: internalcode
                    registered_barcode: registeredcode
                    supplier_item_codes:
                      - code
                    custom_fields:
                      - field_name: Power level
                        field_value: Strong
                configs:
                  - id: 1
                    name: Type
                    values:
                      - Standard
                      - Double-bladed
                additional_info: additional info
                custom_field_collection_id: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all materials
      tags:
        - Material
      description: |-
        Returns a list of materials you've previously created. The materials are returned in sorted order,
            with the most recent materials appearing first.
      operationId: getAllMaterials
      parameters:
        - $ref: "#/components/parameters/category_name"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/uom"
        - $ref: "#/components/parameters/default_supplier_id"
        - $ref: "#/components/parameters/is_sellable"
        - $ref: "#/components/parameters/batch_tracked"
        - $ref: "#/components/parameters/purchase_uom"
        - $ref: "#/components/parameters/purchase_uom_conversion_rate"
        - $ref: "#/components/parameters/extend_material"
        - $ref: "#/components/parameters/include_archived"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: List all materials
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MaterialListResponse"
              example:
                data:
                  - id: 1
                    name: Kyber Crystal
                    uom: pcs
                    category_name: Lightsaber components
                    default_supplier_id: 1
                    type: material
                    purchase_uom: null
                    purchase_uom_conversion_rate: null
                    batch_tracked: false
                    is_sellable: false
                    archived_at: "2020-10-20T10:37:05.085Z"
                    variants:
                      - id: 1
                        product_id: null
                        material_id: 1
                        sku: KC
                        sales_price: null
                        purchase_price: 45
                        config_attributes:
                          - config_name: Type
                            config_value: Standard
                        type: material
                        deleted_at: null
                        internal_barcode: internalcode
                        registered_barcode: registeredcode
                        supplier_item_codes:
                          - code
                        lead_time: 1
                        minimum_order_quantity: 3
                        custom_fields:
                          - field_name: Power level
                            field_value: Strong
                        updated_at: "2020-10-23T10:37:05.085Z"
                        created_at: "2020-10-23T10:37:05.085Z"
                    configs:
                      - id: 1
                        name: Type
                        values:
                          - Standard
                          - Double-bladed
                    additional_info: additional info
                    custom_field_collection_id: 1
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    supplier:
                      id: 1
                      name: Luke Skywalker
                      email: luke.skywalker@example.com
                      comment:
                        "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n\
                        \              greatest Jedi the galaxy has ever known."
                      currency: UAH
                      created_at: "2020-10-23T10:37:05.085Z"
                      updated_at: "2020-10-23T10:37:05.085Z"
                      deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /materials/{id}:
    get:
      summary: Retrieve a material
      tags:
        - Material
      description: Retrieves the details of an existing material based on ID.
      operationId: getMaterial
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/extend_material"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: Details of an existing material
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Material"
              example:
                id: 1
                name: Kyber Crystal
                uom: pcs
                category_name: Lightsaber components
                default_supplier_id: 1
                type: material
                purchase_uom: null
                purchase_uom_conversion_rate: null
                batch_tracked: false
                is_sellable: false
                archived_at: "2020-10-20T10:37:05.085Z"
                variants:
                  - id: 1
                    product_id: null
                    material_id: 1
                    sku: KC
                    sales_price: null
                    purchase_price: 45
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    type: material
                    deleted_at: null
                    internal_barcode: internalcode
                    registered_barcode: registeredcode
                    supplier_item_codes:
                      - code
                    lead_time: 1
                    minimum_order_quantity: 3
                    custom_fields:
                      - field_name: Power level
                        field_value: Strong
                    updated_at: "2020-10-23T10:37:05.085Z"
                    created_at: "2020-10-23T10:37:05.085Z"
                configs:
                  - id: 1
                    name: Type
                    values:
                      - Standard
                      - Double-bladed
                additional_info: additional info
                custom_field_collection_id: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                supplier:
                  id: 1
                  name: Luke Skywalker
                  email: luke.skywalker@example.com
                  comment:
                    "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n \
                    \             greatest Jedi the galaxy has ever known."
                  currency: UAH
                  created_at: "2020-10-23T10:37:05.085Z"
                  updated_at: "2020-10-23T10:37:05.085Z"
                  deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a material
      tags:
        - Material
      description: |-
        Updates the specified material by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updateMaterial
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/custom_fields_format"
      requestBody:
        description: Material details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateMaterialRequest"
      responses:
        "200":
          description: Material updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Material"
              example:
                id: 1
                name: Kyber Crystal
                uom: pcs
                category_name: Lightsaber components
                default_supplier_id: 1
                type: material
                purchase_uom: null
                purchase_uom_conversion_rate: null
                batch_tracked: false
                is_sellable: false
                archived_at: "2020-10-20T10:37:05.085Z"
                variants:
                  - id: 1
                    sku: KC
                    sales_price: null
                    purchase_price: 45
                    type: material
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    lead_time: 1
                    minimum_order_quantity: 3
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    internal_barcode: internalcode
                    registered_barcode: registeredcode
                    supplier_item_codes:
                      - code
                    custom_fields:
                      - field_name: Power level
                        field_value: Strong
                configs:
                  - id: 1
                    name: Type
                    values:
                      - Standard
                      - Double-bladed
                additional_info: additional info
                custom_field_collection_id: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a material
      tags:
        - Material
      description: Deletes a material by id.
      operationId: deleteMaterial
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /negative_stock:
    get:
      summary: List all variants with negative stock
      tags:
        - Inventory
      description: |-
        Returns a list of variants with negative stock balance.
          Each variant has a date of the latest stock movement that resulted in negative stock balance.
      operationId: getAllNegativeStock
      parameters:
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/variant_id"
        - name: latest_negative_stock_date_max
          required: false
          description: Filters negative stock by a latest negative stock date max
          schema:
            type: string
          in: query
        - name: latest_negative_stock_date_min
          required: false
          description: Filters negative stock by a latest negative stock date min
          schema:
            type: string
          in: query
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/sku"
        - $ref: "#/components/parameters/category"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List all variants with negative stock
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NegativeStockListResponse"
              example:
                data:
                  - variant_id: 1
                    location_id: 1
                    latest_negative_stock_date: "2022-03-31T12:07:00.000Z"
                    name: Emitter Matrix
                    sku: EM
                    category: Lightsaber component
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /products:
    post:
      summary: Create a product
      tags:
        - Product
      description: Creates a product object.
      operationId: createProduct
      requestBody:
        description: new product details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProductRequest"
      parameters:
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: New product created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Product"
              example:
                id: 1
                name: Standard-hilt lightsaber
                uom: pcs
                category_name: lightsaber
                is_sellable: true
                is_producible: true
                default_supplier_id: 1
                is_purchasable: true
                is_auto_assembly: true
                type: product
                purchase_uom: pcs
                purchase_uom_conversion_rate: "1"
                batch_tracked: true
                serial_tracked: false
                operations_in_sequence: false
                variants:
                  - id: 1
                    sku: EM
                    sales_price: 40
                    purchase_price: 0
                    type: product
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    lead_time: 1
                    minimum_order_quantity: 3
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    internal_barcode: internalcode
                    registered_barcode: registeredcode
                    supplier_item_codes:
                      - code
                    custom_fields:
                      - field_name: Power level
                        field_value: Strong
                configs:
                  - id: 1
                    name: Type
                    values:
                      - Standard
                      - Double-bladed
                    product_id: 1
                additional_info: additional info
                custom_field_collection_id: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all products
      tags:
        - Product
      description: |-
        Returns a list of products you've previously created. The products are returned in sorted order,
            with the most recent products appearing first.
      operationId: getAllProducts
      parameters:
        - $ref: "#/components/parameters/category_name"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/uom"
        - $ref: "#/components/parameters/is_sellable"
        - $ref: "#/components/parameters/is_producible"
        - $ref: "#/components/parameters/is_purchasable"
        - $ref: "#/components/parameters/is_auto_assembly"
        - $ref: "#/components/parameters/default_supplier_id"
        - $ref: "#/components/parameters/batch_tracked"
        - $ref: "#/components/parameters/serial_tracked"
        - $ref: "#/components/parameters/operations_in_sequence"
        - $ref: "#/components/parameters/purchase_uom"
        - $ref: "#/components/parameters/purchase_uom_conversion_rate"
        - $ref: "#/components/parameters/extend_product"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/include_archived"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: List all products
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductListResponse"
              example:
                data:
                  - id: 1
                    name: Standard-hilt lightsaber
                    uom: pcs
                    category_name: lightsaber
                    is_producible: true
                    default_supplier_id: 1
                    is_sellable: true
                    is_purchasable: true
                    is_auto_assembly: true
                    type: product
                    purchase_uom: pcs
                    purchase_uom_conversion_rate: "1"
                    batch_tracked: true
                    operations_in_sequence: false
                    serial_tracked: false
                    archived_at: "2020-10-20T10:37:05.085Z"
                    variants:
                      - id: 1
                        sku: EM
                        sales_price: 40
                        purchase_price: 0
                        type: product
                        created_at: "2020-10-23T10:37:05.085Z"
                        updated_at: "2020-10-23T10:37:05.085Z"
                        lead_time: 1
                        minimum_order_quantity: 3
                        config_attributes:
                          - config_name: Type
                            config_value: Standard
                        internal_barcode: internalcode
                        registered_barcode: registeredcode
                        supplier_item_codes:
                          - code
                        custom_fields:
                          - field_name: Power level
                            field_value: Strong
                        configs:
                          - id: 1
                            name: Type
                            values:
                              - Standard
                              - Double-bladed
                        product_id: 1
                    additional_info: additional info
                    custom_field_collection_id: 1
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    supplier:
                      id: 1
                      name: Luke Skywalker
                      email: luke.skywalker@example.com
                      comment:
                        "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n\
                        \              greatest Jedi the galaxy has ever known."
                      currency: UAH
                      created_at: "2020-10-23T10:37:05.085Z"
                      updated_at: "2020-10-23T10:37:05.085Z"
                      deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /products/{id}:
    get:
      summary: Retrieve a product
      tags:
        - Product
      description: Retrieves the details of an existing product based on ID.
      operationId: getProduct
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/extend_product"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: Details of an existing product
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Product"
              example:
                id: 1
                name: Standard-hilt lightsaber
                uom: pcs
                category_name: lightsaber
                is_producible: true
                default_supplier_id: 1
                is_sellable: true
                is_purchasable: true
                is_auto_assembly: true
                type: product
                purchase_uom: pcs
                purchase_uom_conversion_rate: "1"
                batch_tracked: false
                operations_in_sequence: false
                archived_at: "2020-10-20T10:37:05.085Z"
                variants:
                  - id: 1
                    sku: EM
                    sales_price: 40
                    purchase_price: 0
                    type: product
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    lead_time: 1
                    minimum_order_quantity: 3
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    internal_barcode: internalcode
                    registered_barcode: registeredcode
                    supplier_item_codes:
                      - code
                    custom_fields:
                      - field_name: Power level
                        field_value: Strong
                configs:
                  - id: 1
                    name: Type
                    values:
                      - Standard
                      - Double-bladed
                    product_id: 1
                additional_info: additional info
                custom_field_collection_id: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                supplier:
                  id: 1
                  name: Luke Skywalker
                  email: luke.skywalker@example.com
                  comment:
                    "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n \
                    \             greatest Jedi the galaxy has ever known."
                  currency: UAH
                  created_at: "2020-10-23T10:37:05.085Z"
                  updated_at: "2020-10-23T10:37:05.085Z"
                  deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a product
      tags:
        - Product
      description: |-
        Updates the specified product by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updateProduct
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/custom_fields_format"
      requestBody:
        description: product details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateProductRequest"
      responses:
        "200":
          description: Product updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Product"
              example:
                id: 1
                name: Standard-hilt lightsaber
                uom: pcs
                category_name: lightsaber
                is_sellable: true
                is_producible: true
                default_supplier_id: 1
                is_purchasable: true
                is_auto_assembly: true
                type: product
                purchase_uom: pcs
                purchase_uom_conversion_rate: "1"
                batch_tracked: true
                serial_tracked: false
                operations_in_sequence: false
                archived_at: "2020-10-20T10:37:05.085Z"
                variants:
                  - id: 1
                    sku: EM
                    sales_price: 40
                    purchase_price: 0
                    type: product
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    lead_time: 1
                    minimum_order_quantity: 3
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    internal_barcode: internalcode
                    registered_barcode: registeredcode
                    supplier_item_codes:
                      - code
                    custom_fields:
                      - field_name: Power level
                        field_value: Strong
                configs:
                  - id: 1
                    name: Type
                    values:
                      - Standard
                      - Double-bladed
                    product_id: 1
                additional_info: additional info
                custom_field_collection_id: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a product
      tags:
        - Product
      description: Deletes a product by id.
      operationId: deleteProduct
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Product deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_orders/search:
    post:
      summary: Search purchase orders
      tags:
        - Purchase order
      description: |
        Searches purchase orders using a structured filter body with nested
        logical operators (``and`` / ``or``) and per-field comparators.
        Only the fields in the filter schema may appear; unknown fields
        return 422. Custom field values are addressable via
        ``custom_fields.<uuid>`` nested paths. Returns the same shape as
        ``GET /purchase_orders`` — a paginated list of records.
      operationId: searchPurchaseOrders
      requestBody:
        description: Structured search body. See the schema for the field allowlist, operators, and caps.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PurchaseOrderSearchRequest"
      responses:
        "200":
          description: Matching purchase orders
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderListResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_orders:
    post:
      summary: Create a purchase order
      tags:
        - Purchase order
      description: Creates a new purchase order object.
      operationId: createPurchaseOrder
      requestBody:
        description: new purchase order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePurchaseOrderRequest"
      responses:
        "200":
          description: New purchase order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrder"
              example:
                id: 1
                status: NOT_RECEIVED
                billing_status: NOT_BILLED
                last_document_status: NOT_SENT
                order_no: PO-1
                entity_type: regular
                default_group_id: 9
                supplier_id: 1
                currency: USD
                expected_arrival_date: "2021-10-13T15:31:48.490Z"
                order_created_date: "2021-10-13T15:31:48.490Z"
                additional_info: Please unpack
                location_id: 1
                tracking_location_id: null
                total: 1
                total_in_base_currency: 1
                created_at: "2021-02-03T13:13:07.110Z"
                updated_at: "2021-02-03T13:13:07.110Z"
                deleted_at: null
                purchase_order_rows:
                  - id: 1
                    quantity: 1
                    variant_id: 1
                    tax_rate_id: 1
                    price_per_unit: 1.5
                    purchase_uom_conversion_rate: 1.1
                    purchase_uom: cm
                    created_at: "2021-02-03T13:13:07.121Z"
                    updated_at: "2021-02-03T13:13:07.121Z"
                    deleted_at: null
                    currency: USD
                    conversion_rate: null
                    conversion_date: null
                    received_date: "2021-02-03T13:13:07.000Z"
                    purchase_order_id: 1
                    total: 1
                    total_in_base_currency: 1
                    landed_cost: 45.0
                    group_id: 11
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all purchase orders
      tags:
        - Purchase order
      description: |-
        Returns a list of purchase orders you've previously created. The purchase orders are returned in sorted
            order, with the most recent purchase orders appearing first.
      operationId: findPurchaseOrders
      parameters:
        - $ref: "#/components/parameters/last_document_status"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/order_no"
        - $ref: "#/components/parameters/entity_type"
        - $ref: "#/components/parameters/po_status"
        - $ref: "#/components/parameters/billing_status"
        - $ref: "#/components/parameters/currency"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/tracking_location_id"
        - $ref: "#/components/parameters/supplier_id"
        - $ref: "#/components/parameters/extend_purchase_order"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List all purchase orders
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderListResponse"
              example:
                data:
                  - id: 1
                    status: NOT_RECEIVED
                    order_no: PO-1
                    entity_type: regular
                    default_group_id: 9
                    supplier_id: 1
                    currency: USD
                    expected_arrival_date: "2021-10-13T15:31:48.490Z"
                    order_created_date: "2021-10-13T15:31:48.490Z"
                    additional_info: Please unpack
                    location_id: 1
                    tracking_location_id: null
                    total: 1
                    total_in_base_currency: 1
                    created_at: "2021-10-13T15:31:48.490Z"
                    updated_at: "2021-10-13T15:31:48.490Z"
                    deleted_at: null
                    billing_status: BILLED
                    last_document_status: SENDING
                    purchase_order_rows:
                      - id: 1
                        quantity: 1
                        variant_id: 1
                        tax_rate_id: 1
                        price_per_unit: 1.5
                        purchase_uom: cm
                        created_at: "2021-10-13T15:31:48.490Z"
                        updated_at: "2021-10-13T15:31:48.490Z"
                        deleted_at: null
                        currency: USD
                        conversion_rate: 1
                        total: 1
                        total_in_base_currency: 1
                        conversion_date: "2021-10-13T15:31:48.490Z"
                        received_date: "2021-10-13T15:31:48.490Z"
                        batch_transactions:
                          - quantity: 1
                            batch_id: 1
                        purchase_order_id: 1
                        purchase_uom_conversion_rate: 1.1
                        landed_cost: 45.0
                        group_id: 11
                    supplier:
                      id: 1
                      name: Luke Skywalker
                      email: luke.skywalker@example.com
                      comment:
                        "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n\
                        \              greatest Jedi the galaxy has ever known."
                      currency: UAH
                      created_at: "2020-10-23T10:37:05.085Z"
                      updated_at: "2020-10-23T10:37:05.085Z"
                      deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_orders/{id}:
    get:
      summary: Retrieve a purchase order
      tags:
        - Purchase order
      description: Retrieves the details of an existing purchase order based on ID
      operationId: getPurchaseOrder
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/extend_purchase_order"
      responses:
        "200":
          description: Purchase order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrder"
              example:
                id: 1
                status: NOT_RECEIVED
                order_no: PO-1
                entity_type: regular
                default_group_id: 9
                supplier_id: 1
                currency: USD
                expected_arrival_date: "2021-10-13T15:31:48.490Z"
                order_created_date: "2021-10-13T15:31:48.490Z"
                additional_info: Please unpack
                location_id: 1
                tracking_location_id: null
                total: 1
                total_in_base_currency: 1
                created_at: "2021-10-13T15:31:48.490Z"
                updated_at: "2021-10-13T15:31:48.490Z"
                deleted_at: null
                billing_status: BILLED
                last_document_status: SENDING
                purchase_order_rows:
                  - id: 1
                    quantity: 1
                    variant_id: 1
                    tax_rate_id: 1
                    price_per_unit: 1.5
                    purchase_uom: cm
                    created_at: "2021-10-13T15:31:48.490Z"
                    updated_at: "2021-10-13T15:31:48.490Z"
                    deleted_at: null
                    currency: USD
                    conversion_rate: 1
                    total: 1
                    total_in_base_currency: 1
                    conversion_date: "2021-10-13T15:31:48.490Z"
                    received_date: "2021-10-13T15:31:48.490Z"
                    batch_transactions:
                      - quantity: 1
                        batch_id: 1
                    purchase_order_id: 1
                    purchase_uom_conversion_rate: 1.1
                    landed_cost: 45.0
                    group_id: 11
                supplier:
                  id: 1
                  name: Luke Skywalker
                  email: luke.skywalker@example.com
                  comment:
                    "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n \
                    \             greatest Jedi the galaxy has ever known."
                  currency: UAH
                  created_at: "2020-10-23T10:37:05.085Z"
                  updated_at: "2020-10-23T10:37:05.085Z"
                  deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a purchase order
      tags:
        - Purchase order
      description: |-
        Updates the specified purchase order by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updatePurchaseOrder
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        required: true
        description: Purchase order fields to be updated with new values
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePurchaseOrderRequest"
      responses:
        "200":
          description: Purchase order updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrder"
              example:
                id: 1
                status: NOT_RECEIVED
                billing_status: NOT_BILLED
                last_document_status: NOT_SENT
                order_no: PO-1
                entity_type: regular
                default_group_id: 9
                supplier_id: 1
                currency: USD
                expected_arrival_date: "2021-10-13T15:31:48.490Z"
                order_created_date: "2021-10-13T15:31:48.490Z"
                additional_info: Please unpack
                location_id: 1
                tracking_location_id: null
                total: 1
                total_in_base_currency: 1
                created_at: "2021-02-03T13:13:07.110Z"
                updated_at: "2021-02-03T13:13:07.110Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete purchase order
      tags:
        - Purchase order
      description: Deletes a single purchase order by id.
      operationId: deletePurchaseOrder
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Purchase order deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "412":
          $ref: "#/components/responses/PreconditionFailedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /po_additional_cost_rows:
    post:
      summary: Create a purchase order additional cost row
      tags:
        - Purchase order additional cost row
      description: Add a purchase order additional cost row to an existing group.
      operationId: createPoAdditionalCostRow
      requestBody:
        description: new purchase order additional cost row
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePurchaseOrderAdditionalCostRowRequest"
      responses:
        "200":
          description: New purchase order additional cost row created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderAdditionalCostRow"
              example:
                id: 1
                additional_cost_id: 11
                group_id: 21
                name: Shipping
                distribution_method: BY_VALUE
                tax_rate_id: 31
                tax_rate: 20
                price: 100
                price_in_base: 110
                currency: EUR
                currency_conversion_rate: 1.1
                currency_conversion_rate_fix_date: "2023-10-01T10:37:05.085Z"
                updated_at: "2023-10-01T10:37:05.085Z"
                created_at: "2023-10-21T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all purchase order additional cost rows
      tags:
        - Purchase order additional cost row
      description: Returns a list of purchase order additional cost rows you've previously created.
      operationId: getPurchaseOrderAdditionalCostRows
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/group_id"
        - $ref: "#/components/parameters/additional_cost_id"
        - $ref: "#/components/parameters/tax_rate_id"
        - $ref: "#/components/parameters/currency"
        - $ref: "#/components/parameters/distribution_method"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List all purchase order additional cost rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderAdditionalCostRowListResponse"
              example:
                data:
                  - id: 1
                    additional_cost_id: 11
                    group_id: 21
                    name: Shipping
                    distribution_method: BY_VALUE
                    tax_rate_id: 31
                    tax_rate: 20
                    price: 100
                    price_in_base: 110
                    currency: EUR
                    currency_conversion_rate: 1.1
                    currency_conversion_rate_fix_date: "2023-10-01T10:37:05.085Z"
                    updated_at: "2023-10-01T10:37:05.085Z"
                    created_at: "2023-10-21T10:37:05.085Z"
                    deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /po_additional_cost_rows/{id}:
    get:
      summary: Retrieve a purchase order additional cost row
      tags:
        - Purchase order additional cost row
      description: Retrieves the details of an existing purchase order additional cost row based on ID
      operationId: getPoAdditionalCostRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: A purchase order additional cost row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderAdditionalCostRow"
              example:
                id: 1
                additional_cost_id: 11
                group_id: 21
                name: Shipping
                distribution_method: BY_VALUE
                tax_rate_id: 31
                tax_rate: 20
                price: 100
                price_in_base: 110
                currency: EUR
                currency_conversion_rate: 1.1
                currency_conversion_rate_fix_date: "2023-10-01T10:37:05.085Z"
                updated_at: "2023-10-01T10:37:05.085Z"
                created_at: "2023-10-21T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a purchase order additional cost row
      tags:
        - Purchase order additional cost row
      description: |-
        Updates the specified purchase order additional cost row by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updateAdditionalCostRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Purchase order additional cost row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePurchaseOrderAdditionalCostRowRequest"
      responses:
        "200":
          description: Purchase order additional cost row updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderAdditionalCostRow"
              example:
                id: 1
                additional_cost_id: 11
                group_id: 21
                name: Shipping
                distribution_method: BY_VALUE
                tax_rate_id: 31
                tax_rate: 20
                price: 100
                price_in_base: 110
                currency: EUR
                currency_conversion_rate: 1.1
                currency_conversion_rate_fix_date: "2023-10-01T10:37:05.085Z"
                updated_at: "2023-10-01T10:37:05.085Z"
                created_at: "2023-10-21T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a purchase order additional cost row
      tags:
        - Purchase order additional cost row
      description: Deletes a purchase order additional cost row by id.
      operationId: deletePoAdditionalCost
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Purchase order additional cost row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_order_receive:
    post:
      summary: Receive a purchase order
      tags:
        - Purchase order
      description: |-
        If you receive the items on the purchase order, you can mark the purchase order as received.
            This will update the existing purchase order rows quantities to the quantities left unreceived and
            create a new rows with the received quantities and dates. If you want to mark all rows as received and
            the order doesn't contain batch tracked items, you can use PATCH /purchase_orders/id endpoint.
            Reverting the receive must also be done through that endpoint.

        Each call records one receipt group: all rows received in the call share one `group_id`, whatever
        their `received_date`. A partial quantity splits the row; the received part becomes a new row and the
        original row keeps the open remainder. Reverting the order
        (PATCH /purchase_orders/{id} with status NOT_RECEIVED) undoes all receipt groups at once; a single
        group cannot be reverted.
      operationId: receivePurchaseOrder
      requestBody:
        description: receive purchase order rows details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PurchaseOrderReceiveRequest"
      responses:
        "204":
          description: Receive purchase order rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_order_rows:
    post:
      summary: Create a purchase order row
      tags:
        - Purchase order row
      description: |-
        Creates a new purchase order row object. Returns 422 when the order status is RECEIVED. The new
        row joins the order's `default_group_id`.
      operationId: createPurchaseOrderRow
      requestBody:
        description: new purchase order row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePurchaseOrderRowRequest"
      responses:
        "200":
          description: New purchase order row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderRow"
              example:
                id: 1
                quantity: 1
                variant_id: 1
                tax_rate_id: 1
                price_per_unit: 1.5
                purchase_uom_conversion_rate: 1.1
                purchase_uom: cm
                created_at: "2021-02-03T13:13:07.121Z"
                updated_at: "2021-02-03T13:13:07.121Z"
                deleted_at: null
                currency: USD
                conversion_rate: null
                conversion_date: null
                received_date: "2021-02-03T13:13:07.000Z"
                arrival_date: "2021-02-02T13:13:07.000Z"
                purchase_order_id: 268123
                total: 1
                total_in_base_currency: 1
                landed_cost: 45.5
                group_id: 11
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all purchase order rows
      tags:
        - Purchase order row
      description: |-
        Returns a list of purchase order rows you've previously created.
          The purchase order rows are returned in sorted order, with the most recent rows appearing first.
      operationId: getAllPurchaseOrderRows
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/purchase_order_id"
        - $ref: "#/components/parameters/variant_id"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/tax_rate_id"
        - $ref: "#/components/parameters/group_id"
        - $ref: "#/components/parameters/purchase_uom"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of purchase order rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderRowListResponse"
              example:
                data:
                  - id: 1
                    quantity: 1
                    variant_id: 1
                    tax_rate_id: 1
                    price_per_unit: 1.5
                    price_per_unit_in_base_currency: 1.5
                    purchase_uom_conversion_rate: 1.1
                    purchase_uom: cm
                    total: 1
                    total_in_base_currency: 1
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    deleted_at: null
                    currency: USD
                    conversion_rate: 1.1
                    conversion_date: "2022-06-20T10:37:05.085Z"
                    received_date: "2022-06-20T10:37:05.085Z"
                    arrival_date: "2022-06-19T10:37:05.085Z"
                    purchase_order_id: 1
                    landed_cost: 45.5
                    group_id: 11
                    batch_transactions:
                      - batch_id: 1
                        quantity: 10
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_order_rows/{id}:
    get:
      summary: Retrieve a purchase order row
      tags:
        - Purchase order row
      description: Retrieves the details of an existing purchase order row based on ID
      operationId: getPurchaseOrderRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: A purchase order row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderRow"
              example:
                id: 1
                quantity: 1
                variant_id: 1
                tax_rate_id: 1
                price_per_unit: 1.5
                price_per_unit_in_base_currency: 1.5
                purchase_uom_conversion_rate: 1.1
                purchase_uom: cm
                total: 1
                total_in_base_currency: 1
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                deleted_at: null
                currency: USD
                conversion_rate: 1
                conversion_date: "2022-06-20T10:37:05.085Z"
                received_date: "2022-06-20T10:37:05.085Z"
                arrival_date: "2022-06-19T10:37:05.085Z"
                purchase_order_id: 1
                landed_cost: 45.5
                group_id: 11
                batch_transactions:
                  - batch_id: 1
                    quantity: 10
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a purchase order row
      tags:
        - Purchase order row
      description: |-
        Updates the specified purchase order row by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updatePurchaseOrderRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: updated purchase order row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePurchaseOrderRowRequest"
      responses:
        "200":
          description: Updated purchase order row
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderRow"
              example:
                id: 1
                quantity: 1
                variant_id: 1
                tax_rate_id: 1
                price_per_unit: 1.5
                purchase_uom_conversion_rate: 1.1
                purchase_uom: cm
                created_at: "2021-02-03T13:13:07.121Z"
                updated_at: "2021-02-03T13:13:07.121Z"
                deleted_at: null
                currency: USD
                conversion_rate: null
                conversion_date: null
                received_date: "2021-02-03T13:13:07.000Z"
                arrival_date: "2021-02-02T13:13:07.000Z"
                purchase_order_id: 268123
                total: 1
                total_in_base_currency: 1
                landed_cost: 45.5
                group_id: 11
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete purchase order row
      tags:
        - Purchase order row
      description: Deletes a single purchase order row by id.
      operationId: deletePurchaseOrderRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Purchase order row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /purchase_order_accounting_metadata:
    get:
      summary: List all purchase order accounting metadata
      tags:
        - Purchase order accounting metadata
      description: Returns a list of purchase order accounting metadata entries.
      operationId: getAllPurchaseOrderAccountingMetadata
      parameters:
        - $ref: "#/components/parameters/purchase_order_id"
        - $ref: "#/components/parameters/received_items_group_id"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List all purchase order accounting metadata entries
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PurchaseOrderAccountingMetadataListResponse"
              example:
                data:
                  - createdAt: "2023-04-17T13:38:07.024Z"
                    id: 35
                    purchase_order_id: 311
                    integrationType: quickBooks
                    purchaseOrderId: 311
                    porReceivedGroupId: 2000037
                    billId: "1082"
                  - createdAt: "2023-04-17T13:38:07.024Z"
                    id: 36
                    purchase_order_id: 312
                    integrationType: quickBooks
                    purchaseOrderId: 312
                    porReceivedGroupId: 2000038
                    billId: "1083"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /suppliers:
    post:
      summary: Create a supplier
      tags:
        - Supplier
      description: Creates a new supplier object.
      operationId: createSupplier
      requestBody:
        description: new supplier details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSupplierRequest"
      responses:
        "200":
          description: New supplier created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Supplier"
              example:
                id: 1
                name: Luke Skywalker
                email: luke.skywalker@example.com
                phone: "123456"
                currency: USD
                comment:
                  "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n   \
                  \           greatest Jedi the galaxy has ever known."
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                default_address_id: 1
                addresses:
                  - id: 1
                    supplier_id: 12345
                    line_1: Line 1
                    line_2: Line 2
                    city: City
                    state: State
                    zip: Zip
                    country: Country
                    updated_at: "2020-10-23T10:37:05.085Z"
                    created_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all suppliers
      tags:
        - Supplier
      description: |-
        Returns a list of suppliers you've previously created. The suppliers are returned in sorted order,
            with the most recent suppliers appearing first.
      operationId: getAllSuppliers
      parameters:
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/email"
        - $ref: "#/components/parameters/phone"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of suppliers
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierListResponse"
              example:
                data:
                  - id: 1
                    name: Luke Skywalker
                    email: luke.skywalker@example.com
                    phone: "123456"
                    comment:
                      "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n\
                      \              greatest Jedi the galaxy has ever known."
                    currency: UAH
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    deleted_at: null
                    default_address_id: 1
                    addresses:
                      - id: 1
                        supplier_id: 12345
                        line_1: Line 1
                        line_2: Line 2
                        city: City
                        state: State
                        zip: Zip
                        country: Country
                        updated_at: "2020-10-23T10:37:05.085Z"
                        created_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /suppliers/{id}:
    patch:
      summary: Update a supplier
      tags:
        - Supplier
      description: |-
        Updates the specified supplier by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updateSupplier
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Supplier details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSupplierRequest"
      responses:
        "200":
          description: Supplier updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Supplier"
              example:
                id: 1
                name: Luke Skywalker
                email: luke.skywalker@example.com
                phone: "123456"
                comment:
                  "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the\n   \
                  \           greatest Jedi the galaxy has ever known."
                currency: UAH
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a supplier
      tags:
        - Supplier
      description: Deletes a supplier by id.
      operationId: deleteSupplier
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Supplier deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /supplier_addresses:
    get:
      summary: List all supplier addresses
      tags:
        - Supplier address
      description: |-
        Returns a list of supplier addresses you've previously created.
           The supplier addresses are returned in sorted order, with the most recent supplier addresses appearing first.
      operationId: getSupplierAddresses
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/supplier_ids"
        - $ref: "#/components/parameters/line_1"
        - $ref: "#/components/parameters/line_2"
        - $ref: "#/components/parameters/city"
        - $ref: "#/components/parameters/state"
        - $ref: "#/components/parameters/zip"
        - $ref: "#/components/parameters/country"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List all supplier addresses
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierAddressListResponse"
              example:
                data:
                  - id: 2
                    supplier_id: 12345
                    line_1: Line 1
                    line_2: Line 2
                    city: City
                    state: State
                    zip: Zip
                    country: Country
                    updated_at: "2020-10-23T10:37:05.085Z"
                    created_at: "2020-10-23T10:37:05.085Z"
                    deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a supplier address
      tags:
        - Supplier address
      description: |-
        Add an address to an existing supplier. If the new address is the first one, it is assigned as
          the default. (A Supplier can have only one address for now)
      operationId: createSupplierAddress
      requestBody:
        description: new supplier address
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSupplierAddressRequest"
      responses:
        "200":
          description: New supplier address created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierAddress"
              example:
                id: 2
                supplier_id: 12345
                line_1: Line 1
                line_2: Line 2
                city: City
                state: State
                zip: Zip
                country: Country
                updated_at: "2020-10-23T10:37:05.085Z"
                created_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /supplier_addresses/{id}:
    patch:
      summary: Update a supplier address
      tags:
        - Supplier address
      description: |-
        Updates the specified supplier address by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updateSupplierAddress
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Supplier address details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSupplierAddressRequest"
      responses:
        "200":
          description: Supplier address updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SupplierAddress"
              example:
                id: 2
                supplier_id: 12345
                line_1: Line 1
                line_2: Line 2
                city: City
                state: State
                zip: Zip
                country: Country
                updated_at: "2020-10-23T10:37:05.085Z"
                created_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a supplier address
      tags:
        - Supplier address
      description: Deletes a supplier address by id.
      operationId: deleteSupplierAddress
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Supplier address deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /tax_rates:
    post:
      summary: Create a tax rate
      tags:
        - Tax rate
      description: Creates a new tax rate object.
      operationId: createTaxRate
      requestBody:
        description: new tax rate details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTaxRateRequest"
      responses:
        "200":
          description: New tax rate created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxRate"
              example:
                id: 1
                name: 15% VAT
                rate: 15
                is_default_sales: true
                is_default_purchases: true
                display_name: 15% VAT
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all tax rates
      tags:
        - Tax rate
      description: |-
        Returns a list of tax rate you've previously created.
            The tax rate are returned in sorted order, with the most recent tax rate appearing first.
      operationId: getAllTaxRates
      parameters:
        - $ref: "#/components/parameters/rate"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/is_default_sales"
        - $ref: "#/components/parameters/is_default_purchases"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of tax rates
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxRateListResponse"
              example:
                data:
                  - id: 1
                    name: 15% VAT
                    rate: 15
                    is_default_sales: true
                    is_default_purchases: true
                    display_name: 15% VAT
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /variants/search:
    post:
      summary: Search variants
      tags:
        - Variant
      description: |
        Searches variants using a structured filter body with nested
        logical operators (``and`` / ``or``) and per-field comparators.
        Only the fields in the filter schema may appear; unknown fields
        return 422. Custom field values are addressable via
        ``custom_fields.<uuid>`` nested paths. Returns the same shape as
        ``GET /variants`` — a paginated list of records.
      operationId: searchVariants
      requestBody:
        description: Structured search body. See the schema for the field allowlist, operators, and caps.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VariantSearchRequest"
      parameters:
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: Matching variants
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantListResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /variants:
    post:
      summary: Create a variant
      tags:
        - Variant
      description: |-
        Creates a new variant object. Note that you can create variants for both products and materials.
            In order for Katana to know which one you are creating,
            you have to specify either product_id or material_id, not both.
      operationId: createVariant
      requestBody:
        description: new variant details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateVariantRequest"
      parameters:
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: New variant created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Variant"
              example:
                id: 1
                sku: EM
                sales_price: 40
                material_id: null
                purchase_price: 0
                type: product
                internal_barcode: "0315"
                registered_barcode: "0785223088"
                supplier_item_codes:
                  - "978-0785223085"
                  - "0785223088"
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                lead_time: 1
                minimum_order_quantity: 3
                config_attributes:
                  - config_name: Type
                    config_value: Standard
                custom_fields:
                  - field_name: Power level
                    field_value: Strong
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all variants
      tags:
        - Variant
      description: |-
        Returns a list of variants you've previously created. The variants are returned in sorted order,
            with the most recent variants appearing first.
      operationId: getAllVariants
      parameters:
        - $ref: "#/components/parameters/variant_type"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/product_id"
        - $ref: "#/components/parameters/material_id"
        - $ref: "#/components/parameters/sku_list"
        - $ref: "#/components/parameters/sales_price"
        - $ref: "#/components/parameters/purchase_price"
        - $ref: "#/components/parameters/internal_barcode"
        - $ref: "#/components/parameters/registered_barcode"
        - $ref: "#/components/parameters/supplier_item_codes"
        - $ref: "#/components/parameters/abc_classification"
        - $ref: "#/components/parameters/extend_variant"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/include_archived"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: List all product variants
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantListResponse"
              example:
                data:
                  - id: 1
                    sku: EM
                    sales_price: 40
                    material_id: null
                    purchase_price: 0
                    type: product
                    created_at: "2020-10-23T10:37:05.085Z"
                    updated_at: "2020-10-23T10:37:05.085Z"
                    deleted_at: null
                    internal_barcode: "0316"
                    registered_barcode: "0785223088"
                    supplier_item_codes:
                      - "978-0785223085"
                      - "0785223088"
                    config_attributes:
                      - config_name: Type
                        config_value: Standard
                    product_or_material:
                      id: 1
                      name: Standard-hilt lightsaber
                      uom: pcs
                      category_name: lightsaber
                      is_producible: true
                      default_supplier_id: 1
                      is_purchasable: true
                      type: product
                      purchase_uom: pcs
                      purchase_uom_conversion_rate: "1"
                      batch_tracked: false
                      variants:
                        - id: 1
                          sku: EM
                          sales_price: 40
                          purchase_price: 0
                          type: product
                          created_at: "2020-10-23T10:37:05.085Z"
                          updated_at: "2020-10-23T10:37:05.085Z"
                          lead_time: 1
                          minimum_order_quantity: 3
                          config_attributes:
                            - config_name: Type
                              config_value: Standard
                          internal_barcode: internalcode
                          registered_barcode: registeredcode
                          supplier_item_codes:
                            - code
                          custom_fields:
                            - field_name: Power level
                              field_value: Strong
                      configs:
                        - id: 1
                          product_id: 1
                          name: Type
                          values:
                            - Standard
                            - Double-bladed
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /variants/{id}:
    get:
      summary: Retrieve a variant
      tags:
        - Variant
      description: Retrieves the details of an existing variant based on ID.
      operationId: getVariant
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/extend_variant"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: Details of an existing variant
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariantResponse"
              example:
                id: 1
                sku: EM
                sales_price: 40
                material_id: null
                purchase_price: 0
                type: product
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                deleted_at: null
                internal_barcode: "0316"
                registered_barcode: "0785223088"
                supplier_item_codes:
                  - "978-0785223085"
                  - "0785223088"
                config_attributes:
                  - config_name: Type
                    config_value: Standard
                product_or_material:
                  id: 1
                  name: Standard-hilt lightsaber
                  uom: pcs
                  category_name: lightsaber
                  is_producible: true
                  default_supplier_id: 1
                  is_purchasable: true
                  type: product
                  purchase_uom: pcs
                  purchase_uom_conversion_rate: "1"
                  batch_tracked: false
                  variants:
                    - id: 1
                      sku: EM
                      sales_price: 40
                      purchase_price: 0
                      type: product
                      created_at: "2020-10-23T10:37:05.085Z"
                      updated_at: "2020-10-23T10:37:05.085Z"
                      lead_time: 1
                      minimum_order_quantity: 3
                      config_attributes:
                        - config_name: Type
                          config_value: Standard
                      internal_barcode: internalcode
                      registered_barcode: registeredcode
                      supplier_item_codes:
                        - code
                      custom_fields:
                        - field_name: Power level
                          field_value: Strong
                  configs:
                    - id: 1
                      name: Type
                      values:
                        - Standard
                        - Double-bladed
                      product_id: 1
                  additional_info: additional info
                  created_at: "2020-10-23T10:37:05.085Z"
                  updated_at: "2020-10-23T10:37:05.085Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a variant
      tags:
        - Variant
      description: |-
        Updates the specified variant by setting the values of the parameters passed.
            Any parameters not provided will be left unchanged.
      operationId: updateVariant
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/custom_fields_format"
      requestBody:
        description: Variant details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateVariantRequest"
      responses:
        "200":
          description: Variant updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Variant"
              example:
                id: 1
                sku: EM
                sales_price: 40
                material_id: null
                purchase_price: 0
                type: product
                internal_barcode: "0315"
                registered_barcode: "0785223088"
                supplier_item_codes:
                  - "978-0785223085"
                  - "0785223088"
                created_at: "2020-10-23T10:37:05.085Z"
                updated_at: "2020-10-23T10:37:05.085Z"
                lead_time: 1
                minimum_order_quantity: 3
                config_attributes:
                  - config_name: Type
                    config_value: Standard
                custom_fields:
                  - field_name: Power level
                    field_value: Strong
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a variant
      tags:
        - Variant
      description: Deletes a variant by id.
      operationId: deleteVariant
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Variant deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /variant_bin_locations:
    post:
      summary: Link variant default storage bins
      tags:
        - Variant default storage bin
      description: |-
        Bulk operation for linking variants with the default storage bins.
        In case the default storage bin doesn't yet exist, it will be created and linked to the variant.
        This endpoint can also be used for changing existing links of the variants to different storage bins.

        The request body is always an array, even when linking a single variant.
      operationId: linkVariantDefaultStorageBins
      requestBody:
        description: Linked variant default storage bin details
        required: true
        content:
          application/json:
            schema:
              type: array
              minItems: 1
              items:
                $ref: "#/components/schemas/VariantDefaultStorageBinLink"
      responses:
        "200":
          description: Linked variant default storage bin order
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/VariantDefaultStorageBinLinkResponse"
              example:
                - id: 12345
                  bin_name: Bin-2
                  variant_id: 11234
                  storage_bin_id: 3456
                  created_at: "2020-10-23T10:37:05.085Z"
                  updated_at: "2020-10-23T10:37:05.085Z"
                  deleted_at: null
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /unlink_variant_bin_locations:
    post:
      summary: Unlink variant default storage bins
      tags:
        - Variant default storage bin
      description: |-
        Bulk operation for unlinking variants from the default storage bins available in a specific location.
          The endpoint accepts up to 500 variant bin location objects.
      operationId: unlinkVariantDefaultStorageBins
      requestBody:
        description: Unlinked variant default storage bin details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UnlinkVariantBinLocationListRequest"
      responses:
        "204":
          description: Variant default storage bins were succesfully unlinked.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /webhooks:
    post:
      summary: Create a webhook
      tags:
        - Webhook
      description: Creates a new webhook object.
      operationId: createWebhook
      requestBody:
        description: new webhook details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateWebhookRequest"
      responses:
        "200":
          description: |-
            New webhook created successfully. The response includes a secret token
            that will be used to generate the X-Sha2-Signature header for webhook
            event verification. When events are sent to your webhook endpoint,
            they will include X-Sha2-Signature and potentially X-Katana-Retry-Num headers.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Sha2-Signature:
              $ref: "#/components/headers/X-Sha2-Signature"
            X-Katana-Retry-Num:
              $ref: "#/components/headers/X-Katana-Retry-Num"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Webhook"
              example:
                id: 1
                url: https://katanamrp.com
                token: 73f82127d57a2cea
                enabled: true
                description: Webhook description
                subscribed_events:
                  - sales_order.created
                created_at: "2021-01-28T04:58:40.492Z"
                updated_at: "2021-01-28T04:58:40.493Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    get:
      summary: List all webhooks
      tags:
        - Webhook
      description: |-
        Returns a list of webhooks you've previously created. The entries are returned in a sorted order,
            with the most recent ones appearing first.
      operationId: getAllWebhooks
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/url"
        - $ref: "#/components/parameters/enabled"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List all webhooks
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookListResponse"
              example:
                data:
                  - id: 1
                    url: https://katanamrp.com
                    token: 73f82127d57a2cea
                    enabled: true
                    description: Webhook description
                    subscribed_events:
                      - sales_order.created
                    created_at: "2021-01-28T04:58:40.492Z"
                    updated_at: "2021-01-28T04:58:40.493Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /webhooks/{id}:
    get:
      summary: Retrieve a webhook
      tags:
        - Webhook
      description: Retrieves the details of an existing webhook based on ID
      operationId: getWebhook
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Webhook
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Webhook"
              example:
                id: 1
                url: https://katanamrp.com
                token: 73f82127d57a2cea
                enabled: true
                description: Webhook description
                subscribed_events:
                  - sales_order.created
                created_at: "2021-01-28T04:58:40.492Z"
                updated_at: "2021-01-28T04:58:40.493Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a webhook
      tags:
        - Webhook
      description: |-
        Updates the specified webhook by setting the values of the parameters passed.
          Any parameters not provided will be left unchanged.
      operationId: updateWebhook
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: webhook fields to be updated with new values
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateWebhookRequest"
      responses:
        "200":
          description: Webhook updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Webhook"
              example:
                id: 1
                url: https://katanamrp.com
                token: 73f82127d57a2cea
                enabled: true
                description: Webhook description
                subscribed_events:
                  - sales_order.created
                created_at: "2021-01-28T04:58:40.492Z"
                updated_at: "2021-01-28T04:58:40.493Z"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete webhook
      tags:
        - Webhook
      description: Deletes a single webhook by id.
      operationId: deleteWebhook
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Webhook deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /webhook_logs_export:
    post:
      summary: Export webhook logs
      tags:
        - Webhook logs
      description: |-
        Use the endpoint to export your webhook logs and troubleshoot any issues.
              Webhook logs are filtered by the provided parameters and exported into a CSV file.
              The response contains an URL to the CSV file.
      operationId: exportWebhookLogs
      requestBody:
        description: webhook logs filters
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookLogsExportRequest"
      responses:
        "200":
          description: New webhook created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookLogsExport"
              example:
                url: https://katana-storage.com/your-file
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_returns:
    get:
      summary: List all sales returns
      tags:
        - Sales return
      description: |-
        Returns a list of sales returns you've previously created. The sales returns are returned in sorted order, with
        the most recent sales return appearing first.
      operationId: getAllSalesReturns
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/sales_return_status"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/sales_return_order_no"
        - $ref: "#/components/parameters/sales_return_location_id"
        - $ref: "#/components/parameters/refund_status"
        - $ref: "#/components/parameters/order_return_date_min"
        - $ref: "#/components/parameters/order_return_date_max"
        - $ref: "#/components/parameters/order_created_date_min"
        - $ref: "#/components/parameters/order_created_date_max"
      responses:
        "200":
          description: List of sales returns
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturnListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales return
      tags:
        - Sales return
      description: Creates a new sales return object.
      operationId: createSalesReturn
      requestBody:
        description: Sales return details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesReturnRequest"
            example:
              sales_order_id: 67890
              return_location_id: 1
              order_no: RET-001
              order_created_date: "2023-10-10T10:00:00Z"
              additional_info: Items damaged during shipping
      responses:
        "200":
          description: Sales return created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturn"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_returns/{id}:
    get:
      summary: Retrieve a sales return
      tags:
        - Sales return
      description: Retrieves a sales return by ID.
      operationId: getSalesReturn
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Sales return details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturn"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a sales return
      tags:
        - Sales return
      description: |-
        Updates the specified sales return by setting the values of the parameters passed. Any parameters not provided
        will be left unchanged.
      operationId: updateSalesReturn
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Sales return details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesReturnRequest"
      responses:
        "200":
          description: Sales return updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturn"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales return
      tags:
        - Sales return
      description: Deletes a sales return by ID.
      operationId: deleteSalesReturn
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Sales return deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_return_rows:
    get:
      summary: List all sales return rows
      tags:
        - Sales return row
      description: |-
        Returns a list of sales return rows you've previously created. The sales return rows are returned in sorted
        order, with the most recent sales return row appearing first.
      operationId: getAllSalesReturnRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - name: sales_return_id
          in: query
          description: Filter by sales return ID
          schema:
            type: integer
        - $ref: "#/components/parameters/variant_id"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/restock_location_id"
        - $ref: "#/components/parameters/reason_id"
        - $ref: "#/components/parameters/sales_order_row_id"
      responses:
        "200":
          description: List of sales return rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturnRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales return row
      tags:
        - Sales return row
      description: Creates a new sales return row.
      operationId: createSalesReturnRow
      requestBody:
        description: Sales return row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesReturnRowRequest"
      responses:
        "200":
          description: Sales return row created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturnRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_return_rows/{id}:
    get:
      summary: Retrieve a sales return row
      tags:
        - Sales return row
      description: Retrieves a sales return row by ID.
      operationId: getSalesReturnRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Sales return row details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturnRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a sales return row
      tags:
        - Sales return row
      description: Updates a sales return row.
      operationId: updateSalesReturnRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Sales return row update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesReturnRowRequest"
      responses:
        "200":
          description: Sales return row updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesReturnRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales return row
      tags:
        - Sales return row
      description: Deletes a sales return row.
      operationId: deleteSalesReturnRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Sales return row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_return_rows/{id}/unassigned_batch_transactions:
    get:
      summary: Get unassigned batch transactions for a sales return row
      tags:
        - Sales return row
      description: Retrieves unassigned batch transactions associated with a sales return row.
      operationId: getSalesReturnRowUnassignedBatchTransactions
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: List of unassigned batch transactions
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnassignedBatchTransactionListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_returns/return_reasons:
    get:
      summary: Get sales return reasons
      tags:
        - Sales return
      description: Retrieves the list of available return reasons for sales returns.
      operationId: getSalesReturnReasons
      responses:
        "200":
          description: List of return reasons
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/SalesReturnReason"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /recipes:
    get:
      summary: Get all recipes
      tags:
        - Recipe
      description: Returns a list of all recipe rows. The recipes endpoint is deprecated in favor of BOM rows.
      operationId: getAllRecipes
      deprecated: true
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/ingredient_variant_id"
        - name: product_variant_ids
          in: query
          description: Filters recipes by an array of product variant IDs.
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/product_id"
        - name: recipe_row_id
          in: query
          description: Filter by recipe row ID (UUID).
          schema:
            type: string
      responses:
        "200":
          description: List of recipe rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Total-Records:
              description: Total number of records
              schema:
                type: number
            X-Total-Pages:
              description: Total number of pages
              schema:
                type: number
            X-Offset:
              description: Current offset
              schema:
                type: number
            X-Page:
              description: Current page number
              schema:
                type: number
            X-First-Page:
              description: Whether this is the first page
              schema:
                type: boolean
            X-Last-Page:
              description: Whether this is the last page
              schema:
                type: boolean
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecipeListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create recipes
      tags:
        - Recipe
      description: |-
        Create one or many new recipe rows for a product. The endpoint accepts up to 150 recipe rows and processes them
        in bulk. This endpoint is deprecated in favor of BOM rows.
      operationId: createRecipes
      deprecated: true
      requestBody:
        description: Recipe creation details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateRecipesRequest"
      responses:
        "204":
          description: Recipe rows created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /recipes/{id}:
    delete:
      summary: Delete a recipe
      tags:
        - Recipe
      description: Deletes all recipe rows for a product by ID. This endpoint is deprecated in favor of BOM rows.
      operationId: deleteRecipe
      deprecated: true
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Recipe deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /recipe_rows/{id}:
    patch:
      summary: Update a recipe row
      tags:
        - Recipe
      description: Updates a recipe row. The recipe rows endpoint is deprecated in favor of BOM rows.
      operationId: updateRecipeRow
      deprecated: true
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Recipe row update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateRecipeRowRequest"
      responses:
        "200":
          description: Recipe row updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Recipe"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a recipe row
      tags:
        - Recipe
      description: Deletes a recipe row. The recipe rows endpoint is deprecated in favor of BOM rows.
      operationId: deleteRecipeRow
      deprecated: true
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Recipe row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /user_info:
    get:
      summary: Get current user info
      tags:
        - User
      description: Returns information about the currently authenticated user.
      operationId: getUserInfo
      responses:
        "200":
          description: Current user information
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserInfo"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /users:
    get:
      summary: List all users
      tags:
        - User
      description: Returns a list of active users in your account.
      operationId: getAllUsers
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of users
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /services:
    get:
      summary: Get All Services
      tags:
        - Services
      description: |-
        Retrieve a list of all Service objects. (See: [Get All
        Services](https://developer.katanamrp.com/reference/getallservices))
      operationId: getAllServices
      parameters:
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/uom"
        - $ref: "#/components/parameters/is_sellable"
        - $ref: "#/components/parameters/category_name"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/include_archived"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: A list of Service objects.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServiceListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create Service
      tags:
        - Services
      description:
        "Create a new Service. (See: [Create
        Service](https://developer.katanamrp.com/reference/createservice))"
      requestBody:
        description: Service data for creating a new service record
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateServiceRequest"
      operationId: createService
      parameters:
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: Service created successfully.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Service"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /services/{id}:
    get:
      summary: Get Service
      tags:
        - Services
      description:
        "Retrieve a single Service by its ID. (See: [Get
        Service](https://developer.katanamrp.com/reference/getservice))"
      operationId: getService
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/custom_fields_format"
      responses:
        "200":
          description: A Service object.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Service"
        "404":
          description: Service not found.
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update Service
      tags:
        - Services
      description:
        "Update an existing Service. (See: [Update
        Service](https://developer.katanamrp.com/reference/updateservice))"
      operationId: updateService
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/custom_fields_format"
      requestBody:
        description: Service data for updating an existing service record
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateServiceRequest"
      responses:
        "200":
          description: Service updated successfully.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Service"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete Service
      tags:
        - Services
      description:
        "Delete a Service by its ID. (See: [Delete
        Service](https://developer.katanamrp.com/reference/deleteservice))"
      operationId: deleteService
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Service deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_orders:
    get:
      summary: List all sales orders
      tags:
        - Sales order
      description: Returns a list of sales orders you've previously created.
      operationId: getAllSalesOrders
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/order_no"
        - $ref: "#/components/parameters/customer_id"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/status"
        - name: production_status
          in: query
          description: Filter by production status
          schema:
            $ref: "#/components/schemas/SalesOrderProductionStatus"
        - name: invoicing_status
          in: query
          description: Filter by invoicing status
          schema:
            type: string
        - $ref: "#/components/parameters/currency"
        - name: source
          in: query
          description: Filter by source
          schema:
            type: string
        - name: ecommerce_store_name
          in: query
          description: Filter by storefront host or slug (e.g. `acme.myshopify.com`)
          schema:
            type: string
        - name: ecommerce_order_id
          in: query
          description: Filter by the source platform's order identifier
          schema:
            type: string
        - name: ecommerce_order_type
          in: query
          description: Filter by source ecommerce platform identifier (e.g. `shopify`)
          schema:
            type: string
        - $ref: "#/components/parameters/ingredient_availability"
        - name: product_availability
          in: query
          description: Filters sales order rows by product availability
          required: false
          schema:
            type: string
            enum:
              - IN_STOCK
              - EXPECTED
              - PICKED
              - NOT_AVAILABLE
              - NOT_APPLICABLE
      responses:
        "200":
          description: List of sales orders
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales order
      tags:
        - Sales order
      description: Creates a new sales order object.
      operationId: createSalesOrder
      requestBody:
        description: New sales order details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesOrderRequest"
      responses:
        "200":
          description: Sales order created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrder"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_orders/{id}:
    get:
      summary: Retrieve a sales order
      tags:
        - Sales order
      description: Retrieves a sales order by ID.
      operationId: getSalesOrder
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Sales order details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrder"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a sales order
      tags:
        - Sales order
      description: Updates a sales order.
      operationId: updateSalesOrder
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Sales order update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesOrderRequest"
      responses:
        "200":
          description: Sales order updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrder"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales order
      tags:
        - Sales order
      description: Deletes a sales order.
      operationId: deleteSalesOrder
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "412":
          $ref: "#/components/responses/PreconditionFailedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_orders/search:
    post:
      summary: Search sales orders
      tags:
        - Sales order
      description: |
        Searches sales orders using a structured filter body with nested
        logical operators (``and`` / ``or``) and per-field comparators.
        Only the fields in the request schema may appear in ``where`` /
        ``order``; unknown fields return 422. Custom field values are
        addressable via ``custom_fields.<uuid>`` nested paths. Returns the
        same shape as ``GET /sales_orders`` — a paginated list of
        ``SalesOrder`` records.
      operationId: searchSalesOrders
      requestBody:
        description: Structured filter body. See the schema for the field allowlist, operators, and caps.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SalesOrderSearchRequest"
      responses:
        "200":
          description: Matching sales orders
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderListResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_orders/{id}/returnable_items:
    get:
      summary: Get returnable items for a sales order
      tags:
        - Sales order
      description: Retrieves a list of items that can be returned from a sales order.
      operationId: getSalesOrderReturnableItems
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: List of returnable items
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ReturnableItem"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /customers/search:
    post:
      summary: Search customers
      tags:
        - Customer
      description: |
        Searches customers using a structured filter body with nested
        logical operators (``and`` / ``or``) and per-field comparators.
        Only the fields in the filter schema may appear; unknown fields
        return 422. Custom field values are addressable via
        ``custom_fields.<uuid>`` nested paths. Returns the same shape as
        ``GET /customers`` — a paginated list of records.
      operationId: searchCustomers
      requestBody:
        description: Structured search body. See the schema for the field allowlist, operators, and caps.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CustomerSearchRequest"
      responses:
        "200":
          description: Matching customers
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerListResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /customers:
    get:
      summary: List all customers
      tags:
        - Customer
      description: Returns a list of customers you've previously created.
      operationId: getAllCustomers
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/name"
        - $ref: "#/components/parameters/email"
        - $ref: "#/components/parameters/first_name"
        - $ref: "#/components/parameters/last_name"
        - $ref: "#/components/parameters/company"
        - $ref: "#/components/parameters/phone"
        - $ref: "#/components/parameters/category"
        - $ref: "#/components/parameters/currency"
        - name: reference_id
          in: query
          description: Filter by reference ID
          schema:
            type: string
      responses:
        "200":
          description: List of customers
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a customer
      tags:
        - Customer
      description: Creates a new customer.
      operationId: createCustomer
      requestBody:
        description: New customer details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomerRequest"
      responses:
        "200":
          description: Customer created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /customers/{id}:
    patch:
      summary: Update a customer
      tags:
        - Customer
      description: |-
        Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will
        be left unchanged.
      operationId: updateCustomer
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Customer details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCustomerRequest"
      responses:
        "200":
          description: Customer updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a customer
      tags:
        - Customer
      description: Deletes a customer by ID.
      operationId: deleteCustomer
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Customer deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /demand_forecasts:
    get:
      summary: List planned demand forecast for variant in location
      tags:
        - Demand forecast
      description: Returns planned forecasted demand for a variant in given location.
      operationId: getDemandForecasts
      parameters:
        - name: variant_id
          in: query
          required: true
          description: ID of variant for which to retrieve demand forecast for.
          schema:
            type: integer
        - name: location_id
          in: query
          required: true
          description: ID of location for which to retrieve variant demand forecast for.
          schema:
            type: integer
      responses:
        "200":
          description: Planned demand forecast for variant in location.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DemandForecastResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Add planned demand forecast to variant
      tags:
        - Demand forecast
      description: Add planned demand forecast for a variant in location for the specified periods.
      operationId: createDemandForecast
      requestBody:
        description: Planned demand forecast for variant in location for specified periods.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDemandForecastRequest"
      responses:
        "204":
          description: Planned demand forecast added for variant in location for specified periods.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Clear planned demand forecast to variant
      tags:
        - Demand forecast
      description: Clears planned demand forecast for a variant in location for the specified periods.
      operationId: clearDemandForecast
      requestBody:
        description: Clear planned demand forecast for variant in location for specified periods.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClearDemandForecastRequest"
      responses:
        "204":
          description: Planned demand forecast cleared for variant in location for specified periods.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stock_adjustments:
    get:
      summary: List all stock adjustments
      tags:
        - Stock adjustment
      description: Returns a list of stock adjustments.
      operationId: getAllStockAdjustments
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/location_id"
        - name: stock_adjustment_number
          in: query
          description: Filters stock adjustments by stock adjustment number
          required: false
          schema:
            type: string
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of stock adjustments
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockAdjustmentListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a stock adjustment
      tags:
        - Stock adjustment
      description: Creates a new stock adjustment to correct inventory levels.
      operationId: createStockAdjustment
      requestBody:
        description: Stock adjustment details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateStockAdjustmentRequest"
      responses:
        "200":
          description: Stock adjustment created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockAdjustment"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stock_adjustments/{id}:
    patch:
      summary: Update a stock adjustment
      tags:
        - Stock adjustment
      description: |-
        Updates the specified stock adjustment by setting the values of the parameters passed. Any parameters not
        provided will be left unchanged.
      operationId: updateStockAdjustment
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Stock adjustment details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateStockAdjustmentRequest"
      responses:
        "200":
          description: Stock adjustment updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockAdjustment"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a stock adjustment
      tags:
        - Stock adjustment
      description: Deletes a stock adjustment by ID.
      operationId: deleteStockAdjustment
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Stock adjustment deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stock_transfers:
    get:
      summary: List all stock transfers
      tags:
        - Stock transfer
      description: Returns a list of stock transfers.
      operationId: getAllStockTransfers
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - name: source_location_id
          in: query
          description: Filter by source location ID
          schema:
            type: integer
        - name: target_location_id
          in: query
          description: Filter by target location ID
          schema:
            type: integer
        - name: stock_transfer_number
          in: query
          description: Filter by stock transfer number
          schema:
            type: string
      responses:
        "200":
          description: List of stock transfers
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockTransferListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a stock transfer
      tags:
        - Stock transfer
      description: Creates a new stock transfer.
      operationId: createStockTransfer
      requestBody:
        description: Stock transfer details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateStockTransferRequest"
      responses:
        "200":
          description: Stock transfer created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockTransfer"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stock_transfers/{id}:
    patch:
      summary: Update a stock transfer
      tags:
        - Stock transfer
      description: Updates a stock transfer.
      operationId: updateStockTransfer
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Stock transfer update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateStockTransferRequest"
      responses:
        "200":
          description: Stock transfer updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockTransfer"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a stock transfer
      tags:
        - Stock transfer
      description: Deletes a stock transfer.
      operationId: deleteStockTransfer
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Stock transfer deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stock_transfers/{id}/status:
    patch:
      summary: Update stock transfer status
      tags:
        - Stock transfer
      description: Updates the status of a stock transfer.
      operationId: updateStockTransferStatus
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Status update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateStockTransferStatusRequest"
      responses:
        "200":
          description: Stock transfer status updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StockTransfer"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_rerank:
    post:
      summary: Change a sales order's rank
      tags:
        - Sales order
      description: |-
        Moves one or more sales orders to an exact place in the sales order list.

        The sales orders in `order_ids` are placed as one consecutive block, in the order given, at the place set in `place`. The first id ends up highest in the list. All other sales orders keep their order relative to each other.

        `before_id` places them directly above that sales order, and `after_id` directly below it. Sending the same request again changes nothing, so a request can be retried safely.

        Only open sales orders can be reranked. A sales order moves together with its linked manufacturing orders.

        To rerank more than 250 sales orders, send them in batches: the first batch with `place.position` set to `top`, each next batch with `place.after_id` set to the last id in the previous response's `order_ids`.

        Sales order lists show the new order shortly after the request returns.

        The request returns 422 when any of the sales orders, including the one in `before_id` or `after_id`, doesn't exist or is not open, or when `before_id` or `after_id` is one of `order_ids`.
      operationId: rerankSalesOrder
      requestBody:
        description: sales order rerank details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RerankSalesOrderRequest"
      responses:
        "204":
          description: Sales order reranked successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
        '200':
          description: Sales orders reranked
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RerankOrdersResponse'
              example:
                order_ids:
                  - 101
                  - 102
  /sales_order_rows:
    get:
      summary: List sales order rows
      tags:
        - Sales order row
      description: Returns a list of sales order rows.
      operationId: getAllSalesOrderRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/variant_id"
        - $ref: "#/components/parameters/ids"
        - name: sales_order_ids
          in: query
          description: Filters sales order rows by an array of sales order IDs
          required: false
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/tax_rate_id"
        - name: linked_manufacturing_order_id
          in: query
          description: Filters sales order rows by manufacturing order ID
          required: false
          schema:
            type: integer
        - name: product_availability
          in: query
          description: Filters sales order rows by product availability
          required: false
          schema:
            type: string
            enum:
              - IN_STOCK
              - EXPECTED
              - PICKED
              - NOT_AVAILABLE
              - NOT_APPLICABLE
        - $ref: "#/components/parameters/extend_sales_order_row"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of sales order rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales order row
      tags:
        - Sales order row
      description: Creates a new sales order row (line item).
      operationId: createSalesOrderRow
      requestBody:
        description: Sales order row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesOrderRowRequest"
      responses:
        "200":
          description: Sales order row created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_rows/search:
    post:
      summary: Search sales order rows
      tags:
        - Sales order row
      description: |-
        Search sales order rows using a structured filter body. Unlike
        ``GET /sales_order_rows`` (which uses simple query parameters), this
        endpoint accepts a rich ``filter`` object with per-field
        comparators and ``and`` / ``or`` composition. Only the fields in
        the request schema may appear in ``where`` / ``order``; unknown
        fields return 422. Custom field values are addressable via
        ``custom_fields.<uuid>`` nested paths.
      operationId: searchSalesOrderRows
      requestBody:
        description: Structured filter body. See the schema for the field allowlist, operators, and caps.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SalesOrderRowSearchRequest"
      responses:
        "200":
          description: Matching sales order rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_rows/{id}:
    get:
      summary: Retrieve a sales order row
      tags:
        - Sales order row
      description: Retrieves the details of an existing sales order row by ID.
      operationId: getSalesOrderRow
      parameters:
        - $ref: "#/components/parameters/id"
        - $ref: "#/components/parameters/extend_sales_order_row"
      responses:
        "200":
          description: Sales order row details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a sales order row
      tags:
        - Sales order row
      description: |-
        Updates the specified sales order row by setting the values of the parameters passed. Any parameters not
        provided will be left unchanged.
      operationId: updateSalesOrderRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Sales order row details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesOrderRowRequest"
      responses:
        "200":
          description: Sales order row updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales order row
      tags:
        - Sales order row
      description: Deletes a sales order row by ID.
      operationId: deleteSalesOrderRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Sales order row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_addresses:
    get:
      summary: List sales order addresses
      tags:
        - Sales order address
      description: Returns a list of sales order addresses.
      operationId: getAllSalesOrderAddresses
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/address_entity_type"
        - $ref: "#/components/parameters/ids"
        - name: sales_order_ids
          in: query
          description: Filters sales order rows by an array of sales order IDs
          required: false
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/company"
        - $ref: "#/components/parameters/first_name"
        - $ref: "#/components/parameters/last_name"
        - $ref: "#/components/parameters/line_1"
        - $ref: "#/components/parameters/line_2"
        - $ref: "#/components/parameters/city"
        - $ref: "#/components/parameters/state"
        - $ref: "#/components/parameters/zip"
        - $ref: "#/components/parameters/country"
        - $ref: "#/components/parameters/phone"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of sales order addresses
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderAddressListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales order address
      tags:
        - Sales order address
      description: Creates a new sales order address (billing or shipping).
      operationId: createSalesOrderAddress
      requestBody:
        description: Sales order address details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesOrderAddressRequest"
      responses:
        "200":
          description: Sales order address created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderAddress"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_addresses/{id}:
    patch:
      summary: Update a sales order address
      tags:
        - Sales order address
      description: |-
        Updates the specified sales order address by setting the values of the parameters passed. Any parameters not
        provided will be left unchanged.
      operationId: updateSalesOrderAddress
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Sales order address details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesOrderAddressRequest"
      responses:
        "200":
          description: Sales order address updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderAddress"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales order address
      tags:
        - Sales order address
      description: Deletes a sales order address by ID.
      operationId: deleteSalesOrderAddress
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Sales order address deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_fulfillments:
    get:
      summary: List sales order fulfillments
      tags:
        - Sales order fulfillment
      description: Returns a list of sales order fulfillments.
      operationId: getAllSalesOrderFulfillments
      parameters:
        - $ref: "#/components/parameters/fulfillment_invoice_status"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/sales_order_id"
        - $ref: "#/components/parameters/sales_order_fulfillment_status"
        - name: tracking_carrier
          in: query
          description: Filters sales order fulfillments by tracking carrier
          required: false
          schema:
            type: string
        - name: tracking_method
          in: query
          description: Filters sales order fulfillments by tracking method
          required: false
          schema:
            type: string
        - name: tracking_number
          in: query
          description: Filters sales order fulfillments by tracking number
          required: false
          schema:
            type: string
        - name: tracking_url
          in: query
          description: Filters sales order fulfillments by tracking URL
          required: false
          schema:
            type: string
        - name: picked_date_min
          in: query
          description: Filters sales order fulfillments by minimum picked date
          required: false
          schema:
            type: string
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List of sales order fulfillments
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderFulfillmentListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales order fulfillment
      tags:
        - Sales order fulfillment
      description: Creates a new sales order fulfillment.
      operationId: createSalesOrderFulfillment
      requestBody:
        description: Sales order fulfillment details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesOrderFulfillmentRequest"
      responses:
        "200":
          description: Sales order fulfillment created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderFulfillment"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_fulfillments/{id}:
    get:
      summary: Retrieve a sales order fulfillment
      tags:
        - Sales order fulfillment
      description: Retrieves a sales order fulfillment by ID.
      operationId: getSalesOrderFulfillment
      parameters:
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Sales order fulfillment details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderFulfillment"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a sales order fulfillment
      tags:
        - Sales order fulfillment
      description: Updates a sales order fulfillment.
      operationId: updateSalesOrderFulfillment
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Sales order fulfillment update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesOrderFulfillmentRequest"
      responses:
        "200":
          description: Sales order fulfillment updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderFulfillment"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales order fulfillment
      tags:
        - Sales order fulfillment
      description: Deletes a sales order fulfillment.
      operationId: deleteSalesOrderFulfillment
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Sales order fulfillment deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /customer_addresses:
    get:
      summary: List customer addresses
      tags:
        - Customer address
      description: Returns a list of customer addresses.
      operationId: getAllCustomerAddresses
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/address_entity_type"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/customer_ids"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/company"
        - $ref: "#/components/parameters/first_name"
        - $ref: "#/components/parameters/last_name"
        - $ref: "#/components/parameters/line_1"
        - $ref: "#/components/parameters/line_2"
        - $ref: "#/components/parameters/city"
        - $ref: "#/components/parameters/state"
        - $ref: "#/components/parameters/zip"
        - $ref: "#/components/parameters/country"
        - $ref: "#/components/parameters/phone"
      responses:
        "200":
          description: List of customer addresses
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerAddressListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a customer address
      tags:
        - Customer address
      description: Creates a new customer address.
      operationId: createCustomerAddress
      requestBody:
        description: New customer address details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomerAddressRequest"
      responses:
        "200":
          description: Customer address created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerAddress"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /customer_addresses/{id}:
    patch:
      summary: Update a customer address
      tags:
        - Customer address
      description: Updates a customer address.
      operationId: updateCustomerAddress
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Customer address update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCustomerAddressRequest"
      responses:
        "200":
          description: Customer address updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerAddress"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a customer address
      tags:
        - Customer address
      description: Deletes a customer address.
      operationId: deleteCustomerAddress
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /price_lists:
    get:
      summary: List price lists
      tags:
        - Price list
      description: Returns a list of price lists.
      operationId: getAllPriceLists
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/name"
        - name: is_active
          in: query
          description: Filters price lists by active status
          required: false
          schema:
            type: boolean
      responses:
        "200":
          description: List of price lists
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a price list
      tags:
        - Price list
      description: Creates a new price list.
      operationId: createPriceList
      requestBody:
        description: Price list details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePriceListRequest"
            example:
              name: VIP Customer Pricing
      responses:
        "200":
          description: Price list created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceList"
              example:
                id: 12345
                name: VIP Customer Pricing
                currency: USD
                is_default: false
                markup_percentage: 15.0
                start_date: "2023-01-01T00:00:00.000Z"
                end_date: "2023-12-31T23:59:59.999Z"
                created_at: "2023-10-21T10:37:05.085Z"
                updated_at: "2023-10-21T10:37:05.085Z"
                deleted_at: null
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /price_lists/{id}:
    get:
      summary: Retrieve a price list
      tags:
        - Price list
      description: Retrieves the details of an existing price list by ID.
      operationId: getPriceList
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Price list details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceList"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a price list
      tags:
        - Price list
      description: |-
        Updates the specified price list by setting the values of the parameters passed. Any parameters not provided
        will be left unchanged.
      operationId: updatePriceList
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Price list details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePriceListRequest"
      responses:
        "200":
          description: Price list updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceList"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a price list
      tags:
        - Price list
      description: Deletes a price list by ID.
      operationId: deletePriceList
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Price list deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /price_list_rows:
    get:
      summary: List price list rows
      tags:
        - Price list row
      description: Returns a list of price list rows.
      operationId: getAllPriceListRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - name: price_list_ids
          in: query
          description: Filters price list rows by an array of price list IDs
          required: false
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/variant_ids"
      responses:
        "200":
          description: List of price list rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a price list row
      tags:
        - Price list row
      description: Creates a new price list row.
      operationId: createPriceListRow
      requestBody:
        description: Price list row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePriceListRowRequest"
            example:
              price_list_id: 12345
              price_list_rows:
                - variant_id: 67890
                  adjustment_method: fixed
                  amount: 29.99
      responses:
        "200":
          description: Price list row created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/PriceListRow"
              example:
                - id: 98765
                  price_list_id: 12345
                  variant_id: 67890
                  adjustment_method: fixed
                  amount: 29.99
                  created_at: "2023-10-21T10:37:05.085Z"
                  updated_at: "2023-10-21T10:37:05.085Z"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /price_list_rows/{id}:
    get:
      summary: Retrieve a price list row
      tags:
        - Price list row
      description: Retrieves the details of an existing price list row by ID.
      operationId: getPriceListRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Price list row details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a price list row
      tags:
        - Price list row
      description: |-
        Updates the specified price list row by setting the values of the parameters passed. Any parameters not provided
        will be left unchanged.
      operationId: updatePriceListRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Price list row details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePriceListRowRequest"
      responses:
        "200":
          description: Price list row updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a price list row
      tags:
        - Price list row
      description: Deletes a price list row by ID.
      operationId: deletePriceListRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Price list row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /price_list_customers:
    get:
      summary: List price list customers
      tags:
        - Price list customer
      description: Returns a list of price list customers.
      operationId: getAllPriceListCustomers
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - name: price_list_ids
          in: query
          description: Filters price list rows by an array of price list IDs
          required: false
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/customer_ids"
        - $ref: "#/components/parameters/ids"
      responses:
        "200":
          description: List of price list customers
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListCustomerListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a price list customer assignment
      tags:
        - Price list customer
      description: Assigns a customer to a price list.
      operationId: createPriceListCustomer
      requestBody:
        description: Price list customer assignment details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePriceListCustomerRequest"
            example:
              price_list_id: 12345
              price_list_customers:
                - customer_id: 67890
      responses:
        "200":
          description: Price list customer assignment created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/PriceListCustomer"
              example:
                - id: 98765
                  price_list_id: 12345
                  customer_id: 67890
                  created_at: "2023-10-21T10:37:05.085Z"
                  updated_at: "2023-10-21T10:37:05.085Z"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /price_list_customers/{id}:
    get:
      summary: Retrieve a price list customer assignment
      tags:
        - Price list customer
      description: Retrieves the details of an existing price list customer assignment by ID.
      operationId: getPriceListCustomer
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Price list customer assignment details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListCustomer"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a price list customer assignment
      tags:
        - Price list customer
      description: |-
        Updates the specified price list customer assignment by setting the values of the parameters passed. Any
        parameters not provided will be left unchanged.
      operationId: updatePriceListCustomer
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Price list customer assignment details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePriceListCustomerRequest"
      responses:
        "200":
          description: Price list customer assignment updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListCustomer"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a price list customer assignment
      tags:
        - Price list customer
      description: Removes a customer from a price list by deleting the assignment.
      operationId: deletePriceListCustomer
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Price list customer assignment deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bom_rows:
    get:
      summary: List all BOM rows
      tags:
        - BOM row
      description: |-
        Returns a list of BOM (Bill of Materials) rows you've previously created. Product variant BOM consists of
        ingredient variants and their quantities.
      operationId: getAllBomRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - name: id
          in: query
          description: Filter by BOM row ID
          schema:
            type: string
        - name: product_item_id
          in: query
          description: Filter by product item ID
          schema:
            type: integer
        - $ref: "#/components/parameters/product_variant_id"
        - $ref: "#/components/parameters/ingredient_variant_id"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of BOM rows
          headers:
            X-Pagination:
              $ref: "#/components/headers/X-Pagination"
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BomRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a BOM row
      tags:
        - BOM row
      description: Create a new BOM row for a product.
      operationId: createBomRow
      requestBody:
        description: New BOM row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateBomRowRequest"
      responses:
        "200":
          description: Returns the created BOM row with its server-assigned id, rank, and timestamps.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BomRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bom_rows/batch/create:
    post:
      summary: Create many BOM rows
      tags:
        - BOM row
      description: Create BOM rows for a product.
      operationId: batchCreateBomRows
      requestBody:
        description: Batch BOM rows creation details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BatchCreateBomRowsRequest"
      responses:
        "204":
          $ref: "#/components/responses/NoContent"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /bom_rows/{id}:
    patch:
      summary: Update a BOM row
      tags:
        - BOM row
      description: |-
        Updates the specified BOM row by setting the values of the parameters passed. Any parameters not provided will
        be left unchanged.
      operationId: updateBomRow
      parameters:
        - $ref: "#/components/parameters/bom_row_id"
      requestBody:
        description: BOM row update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateBomRowRequest"
      responses:
        "200":
          description: BOM row updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BomRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a BOM row
      tags:
        - BOM row
      description: Deletes a BOM row by id.
      operationId: deleteBomRow
      parameters:
        - $ref: "#/components/parameters/bom_row_id"
      responses:
        "204":
          description: BOM row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stocktakes:
    get:
      summary: List stocktakes
      tags:
        - Stocktake
      description: Returns a list of stocktakes.
      operationId: getAllStocktakes
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/location_id"
        - $ref: "#/components/parameters/stocktake_status"
        - name: stocktake_number
          in: query
          description: Filters stocktakes by stocktake number
          required: false
          schema:
            type: string
        - name: stock_adjustment_id
          in: query
          description: Filters stocktakes by stock adjustment ID
          required: false
          schema:
            type: string
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: List of stocktakes
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StocktakeListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a stocktake
      tags:
        - Stocktake
      description: Creates a new stocktake to perform inventory counting.
      operationId: createStocktake
      requestBody:
        description: Stocktake details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateStocktakeRequest"
      responses:
        "200":
          description: Stocktake created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Stocktake"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stocktakes/{id}:
    patch:
      summary: Update a stocktake
      tags:
        - Stocktake
      description: |-
        Updates the specified stocktake by setting the values of the parameters passed. Any parameters not provided will
        be left unchanged.
      operationId: updateStocktake
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Stocktake details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateStocktakeRequest"
      responses:
        "200":
          description: Stocktake updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Stocktake"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a stocktake
      tags:
        - Stocktake
      description: Deletes a stocktake by ID.
      operationId: deleteStocktake
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Stocktake deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stocktake_rows:
    get:
      summary: List stocktake rows
      tags:
        - Stocktake row
      description: Returns a list of stocktake rows.
      operationId: getAllStocktakeRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/variant_id"
        - $ref: "#/components/parameters/ids"
        - name: stocktake_ids
          in: query
          description: Filters stocktake rows by an array of stocktake IDs
          required: false
          schema:
            type: array
            items:
              type: integer
        - $ref: "#/components/parameters/batch_id"
        - name: bin_location_id
          in: query
          description: Filters stocktake rows by bin location ID
          required: false
          schema:
            type: integer
        - name: stock_adjustment_id
          in: query
          description: Filters stocktakes by stock adjustment ID
          required: false
          schema:
            type: number
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of stocktake rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StocktakeRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a stocktake row
      tags:
        - Stocktake row
      description: Creates a new stocktake row for counting specific variants.
      operationId: createStocktakeRow
      requestBody:
        description: Stocktake row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateStocktakeRowRequest"
      responses:
        "200":
          description: Stocktake row created
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/StocktakeRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /stocktake_rows/{id}:
    patch:
      summary: Update a stocktake row
      tags:
        - Stocktake row
      description: |-
        Updates the specified stocktake row by setting the values of the parameters passed. Any parameters not provided
        will be left unchanged.
      operationId: updateStocktakeRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Stocktake row details to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateStocktakeRowRequest"
      responses:
        "200":
          description: Stocktake row updated
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StocktakeRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a stocktake row
      tags:
        - Stocktake row
      description: Deletes a stocktake row by ID.
      operationId: deleteStocktakeRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Stocktake row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /serial_numbers:
    get:
      summary: List serial numbers
      tags:
        - Serial number
      description: |
        Returns a list of serial numbers, optionally filtered by
        ``resource_type`` and/or ``resource_id``.

        **Filter behavior** (verified live 2026-05-19):

        - Both filters set → results scoped to that exact ``(type, id)``.
        - ``resource_type`` alone → ALL serial numbers of that type
          across all resources (paginated, never 422).
        - ``resource_id`` alone → narrows to that resource regardless of
          type.
        - Neither filter → all serial numbers in the tenant (paginated).
        - Page beyond data → 200 with an empty ``data`` array, not 404.
      operationId: getAllSerialNumbers
      parameters:
        - $ref: "#/components/parameters/serial_number_resource_type"
        - $ref: "#/components/parameters/resource_id"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List of serial numbers
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SerialNumberListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Attach serial numbers
      tags:
        - Serial number
      description: |
        Attaches pre-existing serial-number strings to a resource. This endpoint
        did not mint a new string for any tested resource type or manufacturing-
        order state. Serial identities are created by inventory-producing
        workflows such as production and goods receipt.

        **Error cases** (verified live 2026-07-14, #980): a non-existent
        ``resource_id`` returns ``404 NotFoundError`` with a type-specific
        message (e.g. ``manufacturing order <id> not found`` /
        ``production <id> not found``). A ``resource_type`` outside the
        ``CreateSerialNumberResourceType`` enum returns ``422`` with an
        Ajv-style validation detail. Unknown, duplicate, and mixed
        valid/invalid strings hard-fail the whole request with ``422``; the
        legacy ``failed`` array was never observed. A completed manufacturing
        order can instead reject because it has no remaining quantity and
        direct callers to update completed production traceability.

        Manual attachment to valid standalone and make-to-order manufacturing
        orders returned ``404`` in September 2026, before and after production.
        Production and fulfillment can use their unified ``traceability``
        contracts without a successful call to this endpoint.

        **Transfer response quirks:** on a successful transfer the moved
        record's ``transaction_id`` may be the literal string
        ``undefined`` and ``resource_id`` may be ``null`` — re-fetch via
        ``GET /serial_numbers`` to confirm the landing state.
      operationId: createSerialNumbers
      requestBody:
        description: Serial number creation details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSerialNumbersRequest"
      responses:
        "200":
          description: |
            Serial numbers attached. The published ``successful`` / ``failed``
            envelope is retained pending a current valid-success capture.
            Verified invalid inputs return 422 rather than this response.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateSerialNumbersResponse"
        "204":
          description: No operation performed when resource_type is omitted
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete serial numbers
      tags:
        - Serial number
      description: |
        Deletes serial numbers for a resource.

        **DELETE is unconditionally idempotent.** Empirically (live-API
        probes 2026-05-19) the endpoint returns 204 No Content for every
        request variant tested: valid id, already-deleted id, mixed
        valid+invalid id batches, pure-invalid id, and ``resource_id``
        mismatch between body and the SN's actual parent. The endpoint
        does NOT validate the request body — callers cannot detect
        ``id didn't exist`` or ``id belongs to wrong resource`` via
        the response. If strong confirmation is needed, follow up with a
        ``GET /serial_numbers`` filtered by ``resource_id`` and verify
        the deleted ids are absent.
      operationId: deleteSerialNumbers
      requestBody:
        description: Serial number deletion details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeleteSerialNumbersRequest"
      responses:
        "204":
          description: |
            Serial numbers deleted successfully. Returned for every
            well-formed request (valid auth, valid JSON body) regardless
            of whether the supplied ids actually exist.
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /serial_numbers/serial_numbers_stock:
    get:
      summary: List serial number stock (alternate path)
      tags:
        - Serial number
      description: |-
        Returns a list of serial number stock. This is an alternate path for the /serial_numbers_stock endpoint.
      operationId: getSerialNumbersStockAlt
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: List of serial number stock
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SerialNumberStockListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /serial_numbers_stock:
    get:
      summary: List serial number stock
      tags:
        - Serial number
      description: Returns a list of serial number stock.
      operationId: getAllSerialNumbersStock
      responses:
        "200":
          description: List of serial number stock
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SerialNumberStockListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /factory:
    get:
      summary: Retrieve the current factory
      tags:
        - Factory
      description: Returns the general information about the factory.
      operationId: getFactory
      responses:
        "200":
          description: Factory information
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Factory"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /operators:
    get:
      summary: Get all operators
      tags:
        - Operator
      description: Retrieves a list of operators based on the provided filters.
      operationId: getAllOperators
      parameters:
        - name: working_area
          in: query
          description: Filters operators by their working area
          schema:
            $ref: "#/components/schemas/OperatorWorkingArea"
        - $ref: "#/components/parameters/resource_id"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
      responses:
        "200":
          description: A list of operators
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OperatorListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /custom_fields_collections:
    get:
      summary: List all custom fields collections
      tags:
        - Custom fields
      description: Retrieves a list of custom fields collections.
      operationId: getAllCustomFieldsCollections
      responses:
        "200":
          description: Custom field collections
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomFieldsCollectionListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /custom_field_definitions:
    get:
      summary: List custom field definitions
      tags:
        - Custom fields
      description: |
        Returns a paginated list of custom field definitions. Each definition
        configures a custom field that callers can attach to a resource (sales
        order, service, product, etc.) via the resource's ``custom_fields``
        property.
      operationId: getAllCustomFieldDefinitions
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - name: label
          in: query
          required: false
          description: Filters definitions by their display label
          schema:
            type: string
        - name: field_type
          in: query
          required: false
          description: Filters definitions by their field_type
          schema:
            type: string
        - name: entity_type
          in: query
          required: false
          description: Filters definitions by the resource entity_type they target
          schema:
            type: string
      responses:
        "200":
          description: List of custom field definitions
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomFieldDefinitionListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a custom field definition
      tags:
        - Custom fields
      description: Creates a new custom field definition.
      operationId: createCustomFieldDefinition
      requestBody:
        description: Custom field definition details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomFieldDefinitionRequest"
      responses:
        "200":
          description: Custom field definition created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomFieldDefinition"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /custom_field_definitions/{id}:
    get:
      summary: Retrieve a custom field definition
      tags:
        - Custom fields
      description: Retrieves a single custom field definition by ID.
      operationId: getCustomFieldDefinition
      parameters:
        - $ref: "#/components/parameters/custom_field_definition_id"
      responses:
        "200":
          description: Custom field definition retrieved successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomFieldDefinition"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a custom field definition
      tags:
        - Custom fields
      description: Updates an existing custom field definition.
      operationId: updateCustomFieldDefinition
      parameters:
        - $ref: "#/components/parameters/custom_field_definition_id"
      requestBody:
        description: Custom field definition update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateCustomFieldDefinitionRequest"
      responses:
        "200":
          description: Custom field definition updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomFieldDefinition"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a custom field definition
      tags:
        - Custom fields
      description: Deletes an existing custom field definition.
      operationId: deleteCustomFieldDefinition
      parameters:
        - $ref: "#/components/parameters/custom_field_definition_id"
      responses:
        "204":
          description: Custom field definition deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /inventory_reorder_points:
    post:
      summary: Create an inventory reorder point
      tags:
        - Inventory
      description: Creates a new inventory reorder point.
      operationId: createInventoryReorderPoint
      requestBody:
        description: Inventory reorder point details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateInventoryReorderPointRequest"
      responses:
        "200":
          description: Inventory reorder point created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InventoryReorderPoint"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /outsourced_purchase_order_recipe_rows:
    get:
      summary: List all outsourced purchase order recipe rows
      tags:
        - Purchase orders
      description: Retrieves a list of outsourced purchase order recipe rows.
      operationId: getOutsourcedPurchaseOrderRecipeRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/purchase_order_id"
        - name: purchase_order_row_id
          in: query
          description: Filters outsourced purchase order recipe rows by purchase order row ID
          required: false
          schema:
            type: number
        - $ref: "#/components/parameters/ingredient_variant_id"
        - $ref: "#/components/parameters/include_deleted"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: Outsourced purchase order recipe rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OutsourcedPurchaseOrderRecipeRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create an outsourced purchase order recipe row
      tags:
        - Purchase orders
      description: Creates a new outsourced purchase order recipe row.
      operationId: createOutsourcedPurchaseOrderRecipeRow
      requestBody:
        description: Outsourced purchase order recipe row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOutsourcedPurchaseOrderRecipeRowRequest"
      responses:
        "200":
          description: Outsourced purchase order recipe row created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OutsourcedPurchaseOrderRecipeRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /outsourced_purchase_order_recipe_rows/{id}:
    get:
      summary: Retrieve an outsourced purchase order recipe row
      tags:
        - Purchase orders
      description: Retrieves an outsourced purchase order recipe row by ID.
      operationId: getOutsourcedPurchaseOrderRecipeRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Outsourced purchase order recipe row details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OutsourcedPurchaseOrderRecipeRow"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update an outsourced purchase order recipe row
      tags:
        - Purchase orders
      description: Updates an outsourced purchase order recipe row.
      operationId: updateOutsourcedPurchaseOrderRecipeRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Outsourced purchase order recipe row update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateOutsourcedPurchaseOrderRecipeRowRequest"
      responses:
        "200":
          description: Outsourced purchase order recipe row updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OutsourcedPurchaseOrderRecipeRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete an outsourced purchase order recipe row
      tags:
        - Purchase orders
      description: Deletes an outsourced purchase order recipe row.
      operationId: deleteOutsourcedPurchaseOrderRecipeRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Outsourced purchase order recipe row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /product_operation_rerank:
    post:
      summary: Rerank product operations
      tags:
        - Products
      description: Reranks the operations for a product.
      operationId: rerankProductOperations
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProductOperationRerankRequest"
      responses:
        "200":
          description: Product operations reranked successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductOperationRerank"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /product_operation_rows:
    get:
      summary: List product operation rows
      tags:
        - Products
      description: Returns a list of product operation rows.
      operationId: getAllProductOperationRows
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/product_id"
        - $ref: "#/components/parameters/operation_id"
        - $ref: "#/components/parameters/product_variant_id"
        - $ref: "#/components/parameters/operation_name"
        - $ref: "#/components/parameters/resource_name"
        - $ref: "#/components/parameters/resource_id"
        - $ref: "#/components/parameters/product_operation_row_id"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
      responses:
        "200":
          description: List of product operation rows
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductOperationRowListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create product operations
      tags:
        - Products
      description: |-
        Create one or many new product operation rows for a product.
        The endpoint accepts up to 150 product operation rows and processes them in bulk.
        If rows are successfully created, 204 is returned.
      operationId: createProductOperationRows
      requestBody:
        description: New product operation row details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProductOperationRowsRequest"
      responses:
        "204":
          description: New product operation rows were successfully added
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /product_operation_rows/{id}:
    patch:
      summary: Update a product operation row
      tags:
        - Products
      description: Updates a product operation row.
      operationId: updateProductOperationRow
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Product operation row update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateProductOperationRowRequest"
      responses:
        "200":
          description: Product operation row updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductOperationRow"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a product operation row
      tags:
        - Products
      description: Deletes a product operation row.
      operationId: deleteProductOperationRow
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Product operation row deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_accounting_metadata:
    get:
      summary: List sales order accounting metadata
      tags:
        - Sales orders
      description: Retrieves accounting metadata for sales orders.
      operationId: getSalesOrderAccountingMetadata
      parameters:
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/sales_order_id"
        - name: fulfillment_id
          in: query
          description: Filters sales order accounting metadata by fulfillment ID
          required: false
          schema:
            type: number
      responses:
        "200":
          description: Sales order accounting metadata
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderAccountingMetadataListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_shipping_fee:
    get:
      summary: List sales order shipping fees
      tags:
        - Sales orders
      description: Retrieves shipping fees for sales orders.
      operationId: getSalesOrderShippingFees
      parameters:
        - $ref: "#/components/parameters/sales_order_id"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - $ref: "#/components/parameters/ids"
        - $ref: "#/components/parameters/created_at_min"
        - $ref: "#/components/parameters/created_at_max"
        - $ref: "#/components/parameters/updated_at_min"
        - $ref: "#/components/parameters/updated_at_max"
        - $ref: "#/components/parameters/include_deleted"
      responses:
        "200":
          description: Sales order shipping fees
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderShippingFeeListResponse"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    post:
      summary: Create a sales order shipping fee
      tags:
        - Sales orders
      description: Creates a sales order shipping fee and adds it to a sales order.
      operationId: createSalesOrderShippingFee
      requestBody:
        description: Shipping fee details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSalesOrderShippingFeeRequest"
            example:
              sales_order_id: 12345
              amount: "15.99"
              description: Standard shipping
      responses:
        "200":
          description: Shipping fee created successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderShippingFee"
              example:
                id: 67890
                sales_order_id: 12345
                amount: 15.99
                description: Standard shipping
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
  /sales_order_shipping_fee/{id}:
    get:
      summary: Retrieve a sales order shipping fee
      tags:
        - Sales orders
      description: Retrieves a sales order shipping fee by ID.
      operationId: getSalesOrderShippingFee
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "200":
          description: Sales order shipping fee details
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderShippingFee"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    patch:
      summary: Update a sales order shipping fee
      tags:
        - Sales orders
      description: Updates a sales order shipping fee.
      operationId: updateSalesOrderShippingFee
      parameters:
        - $ref: "#/components/parameters/id"
      requestBody:
        description: Shipping fee update details
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateSalesOrderShippingFeeRequest"
      responses:
        "200":
          description: Sales order shipping fee updated successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SalesOrderShippingFee"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "422":
          $ref: "#/components/responses/UnprocessableEntityError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
    delete:
      summary: Delete a sales order shipping fee
      tags:
        - Sales orders
      description: Deletes a sales order shipping fee.
      operationId: deleteSalesOrderShippingFee
      parameters:
        - $ref: "#/components/parameters/id"
      responses:
        "204":
          description: Sales order shipping fee deleted successfully
          headers:
            X-Ratelimit-Limit:
              $ref: "#/components/headers/X-Ratelimit-Limit"
            X-Ratelimit-Remaining:
              $ref: "#/components/headers/X-Ratelimit-Remaining"
            X-Ratelimit-Reset:
              $ref: "#/components/headers/X-Ratelimit-Reset"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "404":
          $ref: "#/components/responses/NotFoundError"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
webhooks:
  sales_order_events:
    post:
      operationId: salesOrderEventsWebhook
      summary: Sales Order Events
      description: |-
        Webhook events for sales orders. Supports all sales order lifecycle events:
        - sales_order.created: When a new sales order is created
        - sales_order.updated: When a sales order is updated (any attribute)
        - sales_order.deleted: When a sales order is deleted
        - sales_order.packed: When status is marked as PACKED
        - sales_order.delivered: When status is marked as DELIVERED
        - sales_order.availability_updated: When availability or expected date is updated
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            examples:
              created:
                summary: Sales Order Created
                value:
                  resource_type: sales_order
                  action: sales_order.created
                  webhook_id: 123
                  object:
                    id: "12345"
                    status: DRAFT
                    href: https://api.katanamrp.com/v1/sales_orders/12345
              delivered:
                summary: Sales Order Delivered
                value:
                  resource_type: sales_order
                  action: sales_order.delivered
                  webhook_id: 123
                  object:
                    id: "12345"
                    status: DELIVERED
                    href: https://api.katanamrp.com/v1/sales_orders/12345
              deleted:
                summary: Sales Order Deleted (no href)
                value:
                  resource_type: sales_order
                  action: sales_order.deleted
                  webhook_id: 123
                  object:
                    id: "12345"
                    status: CANCELLED
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully (any 2XX response acknowledges receipt)
  purchase_order_events:
    post:
      operationId: purchaseOrderEventsWebhook
      summary: Purchase Order Events
      description: |-
        Webhook events for purchase orders. Supports all purchase order lifecycle events:
        - purchase_order.created: When a new purchase order is created
        - purchase_order.updated: When a purchase order is updated
        - purchase_order.deleted: When a purchase order is deleted
        - purchase_order.partially_received: When status is marked as PARTIALLY_RECEIVED
        - purchase_order.received: When status is marked as RECEIVED
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            examples:
              created:
                summary: Purchase Order Created
                value:
                  resource_type: purchase_order
                  action: purchase_order.created
                  webhook_id: 123
                  object:
                    id: po-67890
                    status: DRAFT
                    href: https://api.katanamrp.com/v1/purchase_orders/po-67890
              received:
                summary: Purchase Order Received
                value:
                  resource_type: purchase_order
                  action: purchase_order.received
                  webhook_id: 123
                  object:
                    id: po-67890
                    status: RECEIVED
                    href: https://api.katanamrp.com/v1/purchase_orders/po-67890
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  purchase_order_row_events:
    post:
      operationId: purchaseOrderRowEventsWebhook
      summary: Purchase Order Row Events
      description: |-
        Webhook events for purchase order rows. Supports all purchase order row lifecycle events:
        - purchase_order_row.created: When a new purchase order row is created
        - purchase_order_row.updated: When a purchase order row is updated
        - purchase_order_row.deleted: When a purchase order row is deleted
        - purchase_order_row.received: When a purchase order row is marked received
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: purchase_order_row
              action: purchase_order_row.created
              webhook_id: 123
              object:
                id: por-123
                status: DRAFT
                href: https://api.katanamrp.com/v1/purchase_order_rows/por-123
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  manufacturing_order_events:
    post:
      operationId: manufacturingOrderEventsWebhook
      summary: Manufacturing Order Events
      description: |-
        Webhook events for manufacturing orders. Supports all manufacturing order lifecycle events:
        - manufacturing_order.created: When a new manufacturing order is created
        - manufacturing_order.updated: When a manufacturing order is updated (except ingredient_availability,
        total_planned_time, total_actual_time, and cost-related fields)
        - manufacturing_order.deleted: When a manufacturing order is deleted
        - manufacturing_order.in_progress: When status gets marked as IN_PROGRESS
        - manufacturing_order.blocked: When status gets marked as BLOCKED
        - manufacturing_order.done: When status gets marked as DONE
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            examples:
              created:
                summary: Manufacturing Order Created
                value:
                  resource_type: manufacturing_order
                  action: manufacturing_order.created
                  webhook_id: 123
                  object:
                    id: mo-456
                    status: DRAFT
                    href: https://api.katanamrp.com/v1/manufacturing_orders/mo-456
              done:
                summary: Manufacturing Order Done
                value:
                  resource_type: manufacturing_order
                  action: manufacturing_order.done
                  webhook_id: 123
                  object:
                    id: mo-456
                    status: DONE
                    href: https://api.katanamrp.com/v1/manufacturing_orders/mo-456
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  manufacturing_order_operation_row_events:
    post:
      operationId: manufacturingOrderOperationRowEventsWebhook
      summary: Manufacturing Order Operation Row Events
      description: |-
        Webhook events for manufacturing order operation rows. Supports all operation row lifecycle events:
        - manufacturing_order_operation_row.created: When an operation row is added to a manufacturing order
        - manufacturing_order_operation_row.updated: When an operation row is updated in a manufacturing order
        - manufacturing_order_operation_row.deleted: When an operation row is deleted from a manufacturing order
        - manufacturing_order_operation_row.in_progress: When the operation status gets marked as IN_PROGRESS
        - manufacturing_order_operation_row.paused: When the operation status gets marked as PAUSED
        - manufacturing_order_operation_row.blocked: When the operation status gets marked as BLOCKED
        - manufacturing_order_operation_row.completed: When the operation status gets marked as COMPLETED
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: manufacturing_order_operation_row
              action: manufacturing_order_operation_row.completed
              webhook_id: 123
              object:
                id: moor-789
                status: COMPLETED
                href: https://api.katanamrp.com/v1/manufacturing_order_operation_rows/moor-789
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  manufacturing_order_recipe_row_events:
    post:
      operationId: manufacturingOrderRecipeRowEventsWebhook
      summary: Manufacturing Order Recipe Row Events
      description: |-
        Webhook events for manufacturing order recipe rows. Supports all recipe row lifecycle events:
        - manufacturing_order_recipe_row.created: When a recipe row is added to a manufacturing order
        - manufacturing_order_recipe_row.updated: When a recipe row is updated in a manufacturing order
        - manufacturing_order_recipe_row.deleted: When a recipe row is deleted from a manufacturing order
        - manufacturing_order_recipe_row.ingredients_in_stock: When the ingredient availability of a manufacturing order
        recipe row is updated to IN_STOCK
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: manufacturing_order_recipe_row
              action: manufacturing_order_recipe_row.ingredients_in_stock
              webhook_id: 123
              object:
                id: morr-101
                status: IN_STOCK
                href: https://api.katanamrp.com/v1/manufacturing_order_recipe_rows/morr-101
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  current_inventory_events:
    post:
      operationId: currentInventoryEventsWebhook
      summary: Current Inventory Events
      description: |-
        Webhook events for current inventory changes. Supports all inventory monitoring events:
        - current_inventory.product_updated: When a product's current stock level or average cost is updated
        - current_inventory.material_updated: When a material's current stock level or average cost is updated
        - current_inventory.product_out_of_stock: When a product's current stock level is below the optimal level
        (quantity_missing_or_excess <= 0)
        - current_inventory.material_out_of_stock: When a material's current stock level is below the optimal level
        (quantity_missing_or_excess <= 0)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            examples:
              product_updated:
                summary: Product Inventory Updated
                value:
                  resource_type: current_inventory
                  action: current_inventory.product_updated
                  webhook_id: 123
                  object:
                    id: prod-456
                    status: UPDATED
                    href: https://api.katanamrp.com/v1/products/prod-456
              out_of_stock:
                summary: Product Out of Stock
                value:
                  resource_type: current_inventory
                  action: current_inventory.product_out_of_stock
                  webhook_id: 123
                  object:
                    id: prod-456
                    status: OUT_OF_STOCK
                    href: https://api.katanamrp.com/v1/products/prod-456
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  product_events:
    post:
      operationId: productEventsWebhook
      summary: Product Events
      description: |-
        Webhook events for products. Supports all product lifecycle events:
        - product.created: When a new product is created
        - product.updated: When a product is updated
        - product.deleted: When a product is deleted
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: product
              action: product.created
              webhook_id: 123
              object:
                id: prod-789
                status: ACTIVE
                href: https://api.katanamrp.com/v1/products/prod-789
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  material_events:
    post:
      operationId: materialEventsWebhook
      summary: Material Events
      description: |-
        Webhook events for materials. Supports all material lifecycle events:
        - material.created: When a new material is created
        - material.updated: When a material is updated
        - material.deleted: When a material is deleted
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: material
              action: material.created
              webhook_id: 123
              object:
                id: mat-321
                status: ACTIVE
                href: https://api.katanamrp.com/v1/materials/mat-321
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  variant_events:
    post:
      operationId: variantEventsWebhook
      summary: Variant Events
      description: |-
        Webhook events for variants. Supports all variant lifecycle events:
        - variant.created: When a new variant is added to a product or material
        - variant.updated: When a variant is updated
        - variant.deleted: When a variant is deleted
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: variant
              action: variant.created
              webhook_id: 123
              object:
                id: var-654
                status: ACTIVE
                href: https://api.katanamrp.com/v1/variants/var-654
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  product_recipe_row_events:
    post:
      operationId: productRecipeRowEventsWebhook
      summary: Product Recipe Row Events
      description: |-
        Webhook events for product recipe rows. Supports all product recipe row lifecycle events:
        - product_recipe_row.created: When a product recipe row is created
        - product_recipe_row.updated: When a product recipe row is updated
        - product_recipe_row.deleted: When a product recipe row is deleted (no href for deleted events)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: product_recipe_row
              action: product_recipe_row.created
              webhook_id: 123
              object:
                id: prr-987
                status: ACTIVE
                href: https://api.katanamrp.com/v1/product_recipe_rows/prr-987
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  outsourced_purchase_order_events:
    post:
      operationId: outsourcedPurchaseOrderEventsWebhook
      summary: Outsourced Purchase Order Events
      description: |-
        Webhook events for outsourced purchase orders. Supports all outsourced purchase order lifecycle events:
        - outsourced_purchase_order.created: When an outsourced purchase order is created
        - outsourced_purchase_order.updated: When an outsourced purchase order is updated
        - outsourced_purchase_order.deleted: When an outsourced purchase order is deleted
        - outsourced_purchase_order.received: When an outsourced purchase order is received
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: outsourced_purchase_order
              action: outsourced_purchase_order.created
              webhook_id: 123
              object:
                id: opo-555
                status: DRAFT
                href: https://api.katanamrp.com/v1/outsourced_purchase_orders/opo-555
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  outsourced_purchase_order_row_events:
    post:
      operationId: outsourcedPurchaseOrderRowEventsWebhook
      summary: Outsourced Purchase Order Row Events
      description: |-
        Webhook events for outsourced purchase order rows. Supports all outsourced purchase order row lifecycle events:
        - outsourced_purchase_order_row.created: When an outsourced purchase order row is created
        - outsourced_purchase_order_row.updated: When an outsourced purchase order row is updated
        - outsourced_purchase_order_row.deleted: When an outsourced purchase order row is deleted
        - outsourced_purchase_order_row.received: When an outsourced purchase order row is received
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: outsourced_purchase_order_row
              action: outsourced_purchase_order_row.created
              webhook_id: 123
              object:
                id: opor-777
                status: DRAFT
                href: https://api.katanamrp.com/v1/outsourced_purchase_order_rows/opor-777
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
  outsourced_purchase_order_recipe_row_events:
    post:
      operationId: outsourcedPurchaseOrderRecipeRowEventsWebhook
      summary: Outsourced Purchase Order Recipe Row Events
      description: |-
        Webhook events for outsourced purchase order recipe rows. Supports all outsourced purchase order recipe row
        lifecycle events:
        - outsourced_purchase_order_recipe_row.created: When an outsourced purchase order recipe row is created
        - outsourced_purchase_order_recipe_row.updated: When an outsourced purchase order recipe row is updated
        - outsourced_purchase_order_recipe_row.deleted: When an outsourced purchase order recipe row is deleted
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookEventPayload"
            example:
              resource_type: outsourced_purchase_order_recipe_row
              action: outsourced_purchase_order_recipe_row.created
              webhook_id: 123
              object:
                id: oporr-888
                status: ACTIVE
                href: https://api.katanamrp.com/v1/outsourced_purchase_order_recipe_rows/oporr-888
      responses:
        "200":
          description: Webhook received successfully
        2XX:
          description: Webhook received successfully
x-explorer-enabled: false

x-samples-enabled: true

x-samples-languages:
  - curl
  - node
  - go
  - ruby
  - python
  - php
x-headers:
  - key: Authorization
    value: Bearer <Your api key>
