When to use this endpoint

Use for a new inventory row. This is a metadata/row insertion, not a goods-received or stock movement transaction.

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

ParameterTypeRequiredDescription
stockIDInteger-compatible scalarNoMaps to stock_id. Creation looks up stock costing defaults, including retained deleted/archived stock. Missing or invalid catalog IDs are not rejected as foreign-key errors by the handler.
nameStringNoOmitted creation derives the stock name, possibly overridden by a stock_suppliers row. Explicit blank is retained.
supplierIDInteger-compatible scalarNoSaved supplier_id if supplied. Creation uses the stock scalar supplier only for defaults lookup; it does not copy that derived ID into the request.
supplierObjectNoLegacy layout-value input with id/name; its id expands to request.id, not supplierID. Do not use it to assign a supplier; prefer supplierID. Its name expands to request.name and can overwrite the row name; the composite field itself is not persisted. Creation ignores that expanded id.
storageIDInteger-compatible scalarNoSaved storage_id; 0 is allowed. No storage existence check.
storageObjectNoLegacy layout input with id/name; its id expands to request.id rather than storageID. Use storageID for assignment. Its name expands to request.name and can overwrite the row name; the composite field itself is not persisted. Creation ignores that expanded id.
goodReceivedIDInteger-compatible scalarNoSaved goods-received linkage; no linked-record validation.
qtyNumber-compatible scalarNoFloat-converts, including negative or fractional input; no minimum or inventory/warehouse consistency guard.
costNumber-compatible scalarNoFloat-converts. Omitted creation derives stock average cost, with stock_suppliers override if found; explicit 0 is retained.
priceNumber-compatible scalarNoFloat-converts. Omitted creation derives stock price, with supplier override if found; explicit 0 is retained.
referenceStringNoSaved batch/serial text. No uniqueness or generation is performed.
receivedDateYYYY-MM-DD or blankNoMust round-trip as a real SQL date or be blank. Blank becomes SQL NULL; it is not the creation date.
cdateUnix seconds or date/time stringNoDefaults to now on creation; supplied values are accepted.
lastEditedUnix seconds or date/time stringNoOn creation omitted gets server Unix seconds; changed mapped updates also set server time.

Example request

$saved = FM_api('StockInventory_createData', ['stockID'=>'2042', 'storageID'=>'1', 'qty'=>'2.5']);

Example response

{"ok":1,"id":1042}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"invalid date parameter: receivedDate"}Invalid non-blank SQL date.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • UI readonly/hidden field metadata is not a write-access guard. Values integer-/float-convert according to the map; no minimum, finite-value or foreign-object validation is supplied here.
  • Creation is not atomic with history, and the insert result is not checked for a positive ID before returning ok. Re-read saved values before replaying an uncertain response.
  • Stock lookup supplies name/cost/price defaults and a scalar supplier for the stock_suppliers lookup; no deleted filter is applied. Only supplied supplierID is persisted. A stock_suppliers record can override name/cost/price, while explicit request values win.
  • Creates inventory data only; creating qty does not reconcile stock.in_stock or write stock_histories. It is not a replacement for the stock transaction workflow.
  • No exact caller was found in current app JavaScript or m/www for this office endpoint; app stock quantities use the separate mobile sync/transaction paths.

Side effects

  • Writes stock_inventories and invalidates its cache. Records mapped-field Core_log creation history.
  • Does not update warehouse in_stock, allocate stock, create movement history, send emails, call an external service or fire a configured event.

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

No direct createData action was found in the current Stock Inventory page. Its table uses StockInventories_getDataTable, while goods-received screens have their own receipt workflow. Do not substitute this row insertion for receiving or moving stock.

Related endpoints