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

# Detect Material Variation Gap

> Costing-gap detector — the backend of the "magic button". Given a
master-level costing and the order's colors/sizes, resolve the variations it
*should* have, subtract the ones that already exist, and report what's
missing plus the records to create. Compute-only: actually inserting the
material_sku rows is a separate, explicit DB-write step (not done here).



## OpenAPI

````yaml /api/openapi-cutmake.json post /material-requests/variation-gap
openapi: 3.1.0
info:
  title: VM App API
  version: 0.1.0
servers:
  - url: https://vinmake-erp.onrender.com
security: []
paths:
  /material-requests/variation-gap:
    post:
      tags:
        - Material Requests
      summary: Detect Material Variation Gap
      description: >-
        Costing-gap detector — the backend of the "magic button". Given a

        master-level costing and the order's colors/sizes, resolve the
        variations it

        *should* have, subtract the ones that already exist, and report what's

        missing plus the records to create. Compute-only: actually inserting the

        material_sku rows is a separate, explicit DB-write step (not done here).
      operationId: detect_material_variation_gap_material_requests_variation_gap_post
      parameters:
        - name: X-Org-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Org-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MaterialRequestVariationGapRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2PasswordBearer: []
components:
  schemas:
    MaterialRequestVariationGapRequest:
      properties:
        lines:
          items:
            $ref: '#/components/schemas/MaterialRequestCostLineInput'
          type: array
          title: Lines
        colors:
          items:
            type: string
          type: array
          title: Colors
        sizes:
          items:
            type: string
          type: array
          title: Sizes
        existing:
          items:
            $ref: '#/components/schemas/MaterialRequestExistingVariation'
          type: array
          title: Existing
      type: object
      title: MaterialRequestVariationGapRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MaterialRequestCostLineInput:
      properties:
        materialId:
          type: string
          title: Materialid
        materialName:
          type: string
          title: Materialname
        dependencyType:
          type: string
          title: Dependencytype
          description: color | size | order
          default: color
        netConsumption:
          type: number
          title: Netconsumption
          default: 0
        uom:
          type: string
          title: Uom
          default: pcs
        costPerUnit:
          anyOf:
            - type: number
            - type: 'null'
          title: Costperunit
      type: object
      required:
        - materialId
        - materialName
      title: MaterialRequestCostLineInput
    MaterialRequestExistingVariation:
      properties:
        materialId:
          type: string
          title: Materialid
        color:
          anyOf:
            - type: string
            - type: 'null'
          title: Color
        size:
          anyOf:
            - type: string
            - type: 'null'
          title: Size
      type: object
      required:
        - materialId
      title: MaterialRequestExistingVariation
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2PasswordBearer:
      type: oauth2
      flows:
        password:
          scopes: {}
          tokenUrl: /auth/login

````