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

# Replace the BOM for a SKU

> Replaces the SKU's full bill of materials atomically. Sending an empty `children` array clears the SKU back to non-composite. Nesting is capped at one level — composite children are rejected (NESTING_NOT_ALLOWED).



## OpenAPI

````yaml /api-reference/openapi.json put /skus/{id}/bom
openapi: 3.1.0
info:
  title: AutoPrintFarm Public API
  version: 1.0.0
  description: >-
    Public API for AutoPrintFarm — read + write surface for printers, jobs,
    inventory, orders, SKUs, files, worklist, and assembly. Authorization uses
    three scopes: `read` (any list/get), `write` (data mutations — create,
    update, delete, uploads, fulfillment), and `control` (physical printer
    actions: start, pause, resume, stop, heaters, light, filament). Authenticate
    with an API key minted from Settings → API Keys in the AutoPrintFarm
    dashboard.
  contact:
    name: AutoPrintFarm
    url: https://autoprintfarm.com
servers:
  - url: https://api.autoprintfarm.com/public/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Printers
    description: Printer fleet status
  - name: Jobs
    description: Print job queue and history
  - name: Inventory
    description: Finished-goods stock levels
  - name: Orders
    description: Customer orders and line items
  - name: Wiki
    description: Internal documentation articles
  - name: Worklist
    description: Operational task queue
  - name: Products
    description: Product catalog, SKUs, components, and color presets
  - name: Files
    description: Print file metadata and versions
  - name: Hubs
    description: Hub fleet and connection status
  - name: Assembly
    description: Post-print assembly tasks with bundled wiki
  - name: Materials
    description: Filament, components, packaging, and printer parts inventory
  - name: Analytics
    description: >-
      Dashboard rollups and reporting (overview, production, printers, failures,
      inventory, revenue)
paths:
  /skus/{id}/bom:
    put:
      tags:
        - Products
      summary: Replace the BOM for a SKU
      description: >-
        Replaces the SKU's full bill of materials atomically. Sending an empty
        `children` array clears the SKU back to non-composite. Nesting is capped
        at one level — composite children are rejected (NESTING_NOT_ALLOWED).
      parameters:
        - schema:
            type: string
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                children:
                  type: array
                  items:
                    type: object
                    properties:
                      child_sku_id:
                        type: string
                      quantity_required:
                        type: integer
                        minimum: 1
                    required:
                      - child_sku_id
                      - quantity_required
                  default: []
                inventory:
                  type: array
                  items:
                    type: object
                    properties:
                      inventory_type:
                        type: string
                        enum:
                          - filament
                          - packaging
                          - accessory
                          - printer_part
                      inventory_item_id:
                        type: string
                      quantity_required:
                        type: number
                        exclusiveMinimum: 0
                    required:
                      - inventory_type
                      - inventory_item_id
                      - quantity_required
                  default: []
      responses:
        '200':
          description: BOM replaced
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/SkuBom'
                required:
                  - success
                  - data
        '400':
          description: Validation error (unknown child SKU, self-reference, etc.)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, invalid, revoked, or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: API key lacks the required scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: SKU not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Nesting cap violated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (120 req/min/key)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth:
            - write
components:
  schemas:
    SkuBom:
      type: object
      properties:
        sku_id:
          type: string
        is_composite:
          type: boolean
        available_to_build:
          type: number
        children:
          type: array
          items:
            type: object
            properties:
              child_sku_id:
                type: string
              quantity_required:
                type: number
              child_sku:
                type:
                  - string
                  - 'null'
              child_color:
                type:
                  - string
                  - 'null'
              child_is_composite:
                type:
                  - boolean
                  - 'null'
              child_ready_stock:
                type: number
            required:
              - child_sku_id
              - quantity_required
              - child_sku
              - child_color
              - child_is_composite
              - child_ready_stock
        inventory:
          type: array
          items:
            type: object
            properties:
              inventory_type:
                type: string
                enum:
                  - filament
                  - packaging
                  - accessory
                  - printer_part
              inventory_item_id:
                type: string
              quantity_required:
                type: number
              item_name:
                type:
                  - string
                  - 'null'
              remaining:
                type: number
              unit:
                type: string
            required:
              - inventory_type
              - inventory_item_id
              - quantity_required
              - item_name
              - remaining
              - unit
      required:
        - sku_id
        - is_composite
        - available_to_build
        - children
        - inventory
    Error:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                Machine-readable error code (e.g. NOT_FOUND, VALIDATION_ERROR,
                FORBIDDEN, HUB_OFFLINE). Stable across releases — use this for
                branching.
              example: NOT_FOUND
            message:
              type: string
              description: >-
                Human-readable error message. May vary across releases — do not
                branch on this.
              example: Resource not found
            details:
              description: >-
                Optional structured detail. For VALIDATION_ERROR this is `{
                field: [messages] }`.
          required:
            - code
            - message
          description: Error detail object
      required:
        - success
        - error
      description: Standard error response envelope
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: apf_live_<64 hex>
      description: >-
        API keys are minted in the AutoPrintFarm web app under Settings → API
        Keys. Send as `Authorization: Bearer apf_live_...`. Keys are shown
        exactly once at creation and can be revoked at any time.

````