POST
Correct stock quantities
Company space Cannot be undone For: Stock keeper, Manager · Permission: stock_regularizations.create Conditions
  • motif, input_mode (difference or final_stock) and at least one line are required.
  • Each line must target exactly one of inventory_group_id (a lot group) or asset_id (a location).
  • The item must be tracked in inventory and not archived.
  • A line targeting a lot group must use the item of that group; the group must be a single lot (one level, one cost, one supplier), otherwise it is refused as invalid.
  • The target location (or the location of the group) must be a location the company is allowed to use.
  • A stockable_unit_id must belong to the item and be active, and the current quantity must be expressible in that unit.
  • In final_stock mode quantity is the counted quantity and cannot be negative; in difference mode quantity is the signed change; the resulting stock cannot be negative.
  • A line that would not change the stock is refused.
  • Two lines on the same item and target are merged in difference mode (refused if either carries a manual cost) and refused in final_stock mode.
  • A location line and a lot group line on the same item and location cannot be mixed in one request.
  • When a line raises the stock of a location that currently holds none of the item, exactly one cost input is required (total_cost, unit_cost or their _minor forms), and unit_cost needs cost_remainder, unit_cost_minor needs cost_remainder_minor; in other cases cost inputs are ignored.
  • Stock increases need the item to be tracked in inventory, otherwise the line is refused.
What else happens
  • Creates the correction and its lines; it cannot be edited or deleted afterwards.
  • A negative change removes stock from the target (oldest lots first) and a positive change adds stock, both recorded in the stock history under the regularization operation.
  • Added stock on a lot group keeps the cost and supplier of that lot; on a location with existing stock it is valued at the average cost of the current stock; on an empty location it uses the manual cost sent.
  • Records the member who created it in created_by_user_id.
  • A POST answers 204 by default; add ?response=resource to receive the created correction with status 201.
Part of Correct stock and declare damage.

Authorizations

Authorization
string
header
required

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

Query Parameters

response
enum<string>
default:none

Response mode. Default none; none answers 204 No Content.

Available options:
none,
resource
fields
string

Comma-separated JSON keys of the root resource (id is always rendered). Available: id, motif, input_mode, created_by_user_id, created_at, updated_at.

include
string

Comma-separated include paths, each optionally followed by its fields in parentheses: units(id,sku),units.uomUnit(id,name). Max depth 6, max 40 paths. Available: lines, lines.stockable, lines.stockableUnit.

Body

application/json
motif
string
required

Reason for the correction (for example an inventory count), required, up to 250 characters.

Maximum string length: 250
input_mode
enum<string>
required

How the line quantities are read. difference: quantity is the signed change to apply (positive adds, negative removes). final_stock: quantity is the counted quantity that must remain after the correction. Required.

Available options:
difference,
final_stock
lines
object[]
required

Lines of the correction, at least one. Each line targets one lot group or one location for one item.

Minimum array length: 1

Response

Resource (only with response=resource).

id

Identifier of the stock correction (27-character KSUID).

motif

Reason given for the correction, up to 250 characters.

input_mode

How line quantities were read: difference (signed change) or final_stock (counted quantity).

created_by_user_id

Identifier of the member who recorded the correction; null when it could not be determined.

created_at

Date and time the record was created (ISO 8601, UTC).

updated_at

Date and time the record was last changed (ISO 8601, UTC).

lines
array

Lines of the correction; only present when selected with the include query parameter.