Set a product's bill of materials

distru-set-product-bill-of-materialsWrite

Creates, updates or removes a product's bill of materials: what one unit of the product takes, and the costs it adds.

Inputs

Every tool also takes the common inputs.

FieldTypeRequiredDescription
productIdstringYesThe product the bill makes. Resolve via distru-search-products.
namestringNoDefaults to the product's name when creating the bill.
descriptionstring or nullNoSend null to clear it.
inputsobject[] or nullNoWhat one unit of the product takes. Replaces the whole list when sent; required to create the bill. Send null, alone, to remove the bill with its costs.
inputs[].quantitystring or numberYesPer one unit of the product, in the input product's unit type, or in unitTypeId for anyProductMatching.
inputs[].productIdstringNoA fixed product, active or inactive; not a deleted product nor the product itself. Resolve via distru-search-products.
inputs[].anyProductMatchingobjectNoAny product meeting every listed condition (any entry within a list; {} sets none) whose unit type has the same measure (count, volume or weight) as unitTypeId; its quantity is converted to unitTypeId.
inputs[].anyProductMatching.oneOfProductCategoryIdsstring[]NoResolve via distru-search-lookups (type PRODUCT_CATEGORY).
inputs[].anyProductMatching.oneOfProductSubcategoryIdsstring[]NoEach must belong to a category in oneOfProductCategoryIds. Resolve via distru-search-lookups (type PRODUCT_CATEGORY, each row's subcategories).
inputs[].anyProductMatching.oneOfProductGroupIdsstring[]NoResolve via distru-search-lookups (type PRODUCT_GROUP).
inputs[].anyProductMatching.oneOfProductStrainIdsstring[]NoFrom the strain on distru-search-products rows.
inputs[].anyProductMatching.oneOfProductTagIdsstring[]NoResolve via distru-search-lookups (type PRODUCT_TAG).
inputs[].unitTypeIdstringNoRequired with anyProductMatching, refused with productId. Resolve via distru-search-lookups (type UNIT_TYPE).
costsobject[]NoReplaces the whole list when sent; [] removes every cost.
costs[].costTypeIdstringYesResolve via distru-search-lookups (type COST_TYPE).
costs[].quantitystring or numberYesCost type units per one unit of the product.
costs[].descriptionstringNo

Output

Presence on a nested field assumes its parent exists.

FieldTypePresence
billOfMaterialsobjectCan be null
billOfMaterials.namestringAlways
billOfMaterials.descriptionstringCan be null
billOfMaterials.inputsobject[]Always
billOfMaterials.inputs[].quantitystringAlways
billOfMaterials.inputs[].unitTypeobjectCan be null
billOfMaterials.inputs[].unitType.idstringAlways
billOfMaterials.inputs[].unitType.namestringAlways
billOfMaterials.inputs[].productobjectCan be null
billOfMaterials.inputs[].product.idstringAlways
billOfMaterials.inputs[].product.namestringAlways
billOfMaterials.inputs[].product.skustringCan be null
billOfMaterials.inputs[].anyProductMatchingobjectCan be null
billOfMaterials.inputs[].anyProductMatching.oneOfProductCategoriesobject[]Can be absent
billOfMaterials.inputs[].anyProductMatching.oneOfProductCategories[].idstringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductCategories[].namestringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductSubcategoriesobject[]Can be absent
billOfMaterials.inputs[].anyProductMatching.oneOfProductSubcategories[].idstringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductSubcategories[].namestringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductGroupsobject[]Can be absent
billOfMaterials.inputs[].anyProductMatching.oneOfProductGroups[].idstringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductGroups[].namestringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductStrainsobject[]Can be absent
billOfMaterials.inputs[].anyProductMatching.oneOfProductStrains[].idstringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductStrains[].namestringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductTagsobject[]Can be absent
billOfMaterials.inputs[].anyProductMatching.oneOfProductTags[].idstringAlways
billOfMaterials.inputs[].anyProductMatching.oneOfProductTags[].namestringAlways
billOfMaterials.costsobject[]Always
billOfMaterials.costs[].costTypeobjectAlways
billOfMaterials.costs[].costType.idstringAlways
billOfMaterials.costs[].costType.namestringAlways
billOfMaterials.costs[].quantitystringAlways
billOfMaterials.costs[].descriptionstringCan be null
What the AI reads

Creates, updates or removes a product's bill of materials: what one unit of the product takes, and the costs it adds. A product has at most one bill. Read the current bill with distru-get-product (includeBillOfMaterials). Sparse update: only the fields passed change and the rest stay as they are; inputs and costs, when passed, replace the whole list. inputs: null removes the bill with its costs. Returns the bill in distru-get-product's shape, or null after removal. The bill pre-fills new assemblies in the Distru web app; distru-create-assembly does not read it, and existing assemblies keep their inputs. It never changes the product's cost or inventory.