POST
Assemble bundles from stock
Company space For: Manager, Stock keeper · Permission: bundles.populate Conditions
  • The bundle must not be archived.
  • asset_id must be a location of the organization; the assembled bundles are stocked in there.
  • components must list exactly the bundle’s recipe: a missing or extra stockable_id is refused, and each stockable_id may appear once.
  • A component’s own asset_id, inventory_group_id or group_id is refused (even null); stock sources go in stock_sources.
  • A tracked component must list stock_sources (at least one); an untracked component must not.
  • Each stock source names exactly one of asset_id (a location) or group_id (a stock group), and the same location or group cannot appear twice for one component.
  • For each tracked component the source quantities must add up to the recipe quantity times the number of bundles assembled.
  • A source location must hold stock of that component, and a source group must still hold stock and belong to that component.
  • Every component unit must be active.
  • A shortfall of stock in a source is refused; nothing is changed.
  • cost, when sent, is in major units, at least 0, with at most the currency’s decimals.
  • Concurrent stock operations are retried up to three times; if they keep conflicting the call answers 409 and nothing is changed.
What else happens
  • Withdraws the required quantity of each tracked component from its listed stock sources and records the inventory movements and the matching entries in the books.
  • Stocks the assembled bundles in at asset_id with the given total cost (0 when cost is omitted), creating the bundle’s stock record when needed, with the matching entries in the books.
  • Untracked components take part in the recipe but no stock movement is made for them.
Part of Sell bundles and kits.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

bundle
string
required

Identifier of the bundle (27-character KSUID string).

Body

application/json

Structural checks only. Recipe coverage, tracking, quantities per component and stock sources are resolved by BundleService::populate inside the bundle's scope.

Each tracked component lists its stock_sources; a source names one location (asset_id) or one stock group (group_id) and the quantity, in recipe units, taken from it for the whole operation.

asset_id
string
required

Identifier of the location where the assembled bundles are stocked in. It must be a location of the organization.

quantity
integer
required

Number of bundles to assemble, at least 1.

Required range: x >= 1
components
object[]
required

The bundle's recipe: one entry for each component of the bundle, no more and no fewer.

Minimum array length: 1
cost
number | null

Total cost of the assembled bundles stocked in, in major units, at least 0 with at most the currency's decimals. Treated as 0 when omitted.

Response

BundleStockOperationResource

bundle_id
string
required

Identifier of the bundle that was assembled or detached.

asset_id
string
required

Location where the bundles were stocked in (assembly) or taken out (detach).

quantity_assembled
integer | null
required

Number of bundles assembled. Null on a detach.

quantity_disassembled
integer | null
required

Number of bundles taken apart. Null on an assembly.

component_deductions
array | null
required

On an assembly, one entry per recipe component with stockable_id, stockable_unit_id, quantity_deducted (what was withdrawn, in the recipe unit; 0 for an untracked component) and base_quantity_deducted. Null on a detach.

component_returns
array | null
required

On a detach, one entry per component with stockable_id, stockable_unit_id, quantity_returned and base_quantity_returned. Null on an assembly.