When to use this endpoint

Use for a new bundle. 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
nameStringYesNon-empty name; no uniqueness check. Whitespace is not trimmed by the required-value check.
stocksJSON text or native arrayNoStored component list, normally [{stockID:1042,qty:2}]. Replaces the entire saved list; no stock existence, quantity or schema validation is performed.
metaJSON text or objectNoReplaces the entire metadata value. No merge with existing keys.
widgetTableStockBundleJSON text or native arrayNoWidget rows use stockID and qty. Converted rows override stocks when supplied; unrecognized row keys, including id, are dropped. A present noConvert key bypasses conversion and is removed; this is a legacy internal control, not an integration format.
cdateUnix seconds or date/time stringNoCreation timestamp defaults to now; writable despite UI readonly metadata.
lastEditedUnix seconds or date/time stringNoCreation accepts a supplied value; omitted defaults to now. Changed updates set last_edited to server Unix seconds.

Example request

$saved = FM_api('StockBundle_createData', ['name'=>'Service kit']);

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":"missing or invalid parameter: name"}Required name omitted or blank.

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.
  • widgetTableStockBundle, when supplied, takes precedence over stocks. Its supported keys are stockID and qty; id is not an alias for stockID. The saved component list is replaced as a whole.
  • The mobile intermediary m/www/php/functions/syncDownloads.php reads stock_bundles as stockBundles. Current app code expands those locally synchronized components; it does not directly call this office endpoint.

Side effects

  • Writes stock_bundles 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

Open Stock Bundles. Its mapped table uses StockBundles_getDataTable; Create/Edit uses layoutStockBundleCreate/layoutStockBundleUpdate and the Layout stockBundle mapping. Filter Network for StockBundle_createData. Bulk Delete posts one ID per request; direct updateField has no dedicated call in this page.

Related endpoints