Stock inventory, storage and bundles
Update selected inventory rows without changing catalog records
/a/StockInventory_updateData
Update selected inventory rows without changing catalog records.
When to use this endpoint
Use for mapped inventory-row corrections. Omitted fields retain saved values. This is not a stock movement or warehouse balance reconciliation.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. These handlers perform no additional stock, finance, page-role, department or owner check; UI button permissions are not server authorization.
Data is scoped to the authenticated tenant. Session CSRF, signed-request checks and account routing still apply. No stockTracking feature gate is enforced in these handlers.
Requires tenant upgrade 796: stock bundle, storage and inventory tables must have deleted/ddate columns before deploying these handlers.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible scalar or native array | Yes | Positive integer ID or non-empty native array of positive IDs. Every target must exist before writing; the entire batch commits or rolls back together. |
stockID | Integer-compatible scalar | No | Maps to inventory.stock_id. Non-negative integer; no catalog costing-default lookup occurs on update. |
name | String | No | Inventory row name, maximum 100 characters. Does not change the catalog name. |
supplierID | Integer-compatible scalar | No | Non-negative scalar supplier ID; assign through this alias, not supplier. |
supplier | Object | No | Composite input is rejected. Use supplierID/storageID; primary IDs cannot be assigned through a composite value. |
storageID | Integer-compatible scalar | No | Non-negative integer linkage. No linked-record existence validation is added here. |
storage | Object | No | Composite input is rejected. Use supplierID/storageID; primary IDs cannot be assigned through a composite value. |
goodReceivedID | Integer-compatible scalar | No | Non-negative integer linkage. No linked-record existence validation is added here. |
qty | Finite numeric scalar | No | Finite numeric inventory-row value. Numeric strings are accepted and fractions preserved; this does not update catalog costs/prices or warehouse stock. |
cost | Finite numeric scalar | No | Finite numeric inventory-row value. Numeric strings are accepted and fractions preserved; this does not update catalog costs/prices or warehouse stock. |
price | Finite numeric scalar | No | Finite numeric inventory-row value. Numeric strings are accepted and fractions preserved; this does not update catalog costs/prices or warehouse stock. |
reference | String | No | Batch/serial text, maximum 100 characters. Not automatically generated or made unique. |
receivedDate | YYYY-MM-DD or blank | No | Must round-trip as a real SQL date or be blank. Blank becomes SQL NULL; it is not the creation date. |
cdate | Unix seconds or date/time string | No | Supplied valid Unix timestamp/date-time value replaces the inventory creation timestamp. |
lastEdited | Unix seconds or date/time string | No | Ignored input; changed saves use server Unix seconds. |
Example request
$saved = FM_api('StockInventory_updateData', ['id'=>'1042', 'name'=>'Filter cartridge', 'qty'=>'2.5']);
Example response
{"ok":1}
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: id"} | Missing, malformed, zero or empty target IDs. |
{"error":"inventory does not exist"} | At least one target does not exist; nothing is saved. |
{"error":"use supplierID/storageID instead of composite values"} | supplier or storage composite input is supplied. |
{"error":"invalid date parameter: receivedDate"} | Invalid non-blank SQL date. |
{"warning":"No Change."} | Supplied mapped values already match. |
{"warning":"no updated fields."} | No writable mapped values supplied. |
{"error":"inventory write failed"} | A primary write or history insert fails; the transaction rolls back. |
{"error":"inventory read failed"} | Target lookup fails. |
{"error":"inventory transaction failed"} | Transaction begin/commit fails. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Only stock_inventories is updated; IDs never address the stock catalog. Primary IDs and supplied lastEdited cannot be written. Composite supplier/storage writes are rejected; use their scalar ID aliases.
- Every ID in a bulk request is validated and locked before writing. Values and Core_log-compatible history rows commit together, or the transaction rolls back; a failed write does not return ok.
- Finite decimal quantities, costs and prices are retained. UI readonly metadata is not authorization; mapped inventory corrections remain writable. No foreign-record validation or warehouse/movement reconciliation is performed.
- Changed saves set last_edited to server Unix seconds; unchanged values produce the No Change warning without history. Text compares as text, and null is distinct from zero.
- No exact caller was found in current app JavaScript or m/www for this office endpoint; app stock quantities use separate mobile sync/transaction paths.
Side effects
- Changed rows, server edit timestamps, inventory cache invalidation and mapped history are committed together. Does not update stock catalog fields, warehouse in_stock, movement history, notifications or configured events.
See it in Fieldmotion
CRM1
No direct CRM1 caller was found for this exact endpoint; the legacy Stock page uses its separate catalog/container APIs.
CRM2
The Layout stockInventory mapping uses this route for inventory saves; the Stock Inventory/Stock Location lists use StockInventories_getDataTable. Filter Network for StockInventory_updateData when saving a mapped inventory layout.
Related endpoints
StockInventory_getRequestedDetailsreads stored mapped values; an omitted ID can retrieve all active tenant rows.StockInventory_createDatacreates a new inventory row rather than changing physical warehouse stock.