Stock inventory, storage and bundles
Soft-delete a bundle definition
/a/StockBundle_delete
Soft-delete one bundle definition without changing physical stock.
When to use this endpoint
Use for a reviewed single ID. CRM2 bulk deletion sends one request per ID; mapped filters and native ID arrays are not supported.
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 | Positive integer scalar | Yes | Exactly one positive integer ID; omitted, malformed and array values are rejected. A valid missing/already-deleted ID returns ok. |
Example request
$deleted = FM_api('StockBundle_delete', ['id'=>'1042']);
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"} | No positive scalar integer ID. |
{"error":"inventory read failed"} | A required database read fails; no deletion/child changes commit. |
{"error":"inventory write failed"} | A delete-state, child or history write fails; the transaction rolls back. |
{"error":"stock deletion could not be recorded"} | Tenant deletion audit fails; the transaction rolls back. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Locks the active target and sets deleted=1, ddate and last_edited to server Unix seconds. The retained row is excluded from mapped active readers and writers. Missing/already-deleted IDs are idempotent successes; no restore endpoint is provided here.
- No bundle-usage or stock-availability guard is added. Existing saved bundle references and component quantities are not rewritten.
- Mobile sync excludes deleted bundle definitions and publishes deletion tombstones as stockBundles so cached definitions are removed.
- Deletion, child changes (for storage), history and tenant deletion audit commit together; any checked failure rolls back the transaction.
Side effects
- Retains stock_bundles rows as soft-deleted, invalidates affected table caches and writes the tenant deletes audit. Does not alter warehouse in_stock, send notifications 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_delete. Bulk Delete posts one ID per request; direct updateField has no dedicated call in this page.
Related endpoints
StockBundle_getRequestedDetailsreads stored mapped values; an omitted ID can retrieve all active tenant rows.StockBundle_createDatacreates a new bundle rather than changing physical warehouse stock.