Skip to main content

Add Part to Unit

POST 

/api/repairs/:repair/lines/:line/parts

Records a part on a repair unit, either planned (demand only: no stock moves and nothing posts) or consumed (stock moves at FIFO and the cost posts).

Required scope: repairs:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Fields:

  • product_id (integer, required) — the part.
  • warehouse_id (integer, required) — where the part comes from (or goes to, for remove).
  • quantity (number, required, > 0, max 100000) — in the part's stock unit, or in uom_id when given. Fractions are kept.
  • uom_id (integer, optional) — enter the quantity in another unit configured on the part (e.g. cm of a chain stocked by the inch). See List Part Units. The response keeps what was typed in entered_quantity / entered_uom.
  • operation (string, optional) — add (default), remove (a component taken off a brand-owned unit enters stock as a new FIFO layer) or recycle.
  • state (string, optional) — consumed (default) or planned.
  • bill_to (string, optional) — warranty, goodwill, customer, supplier; defaults from the unit's coverage.
  • bill_price (number, optional, ≥ 0).
  • unit_cost (number, optional, ≥ 0) — planned parts only; defaults to the part's current cost. Consumed parts cost what the FIFO layers drew.
  • description (string, optional, max 255) — defaults to the part name.
  • lots (array, optional) — override the automatic FEFO/FIFO pick: lots.*.fifo_layer_id (integer, required with lots), lots.*.quantity (number, required with lots, > 0).
  • serials (array of strings, optional, max 191 each) — serial numbers for a serialised part; one per unit consumed.
  • planned_cost_id (integer, optional) — consume an existing planned part on this unit instead of adding a new line.

Refused with 422 when free stock is short, when a serialised part has too few serials, when the unit is not one of the part's units, or when remove is used on a customer-owned unit.

Authentication: Bearer token with the repairs:write scope.

Request​

Responses​

OK

Response Headers
    Content-Type