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

ParameterTypeRequiredDescription
idPositive integer scalarYesExactly one positive integer ID; omitted, malformed and array values are rejected. A valid missing/already-deleted ID returns ok.

Example request

$deleted = FM_api('StockStorage_deleteData', ['id'=>'1042']);

Example response

{"ok":1}

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: id"}No positive scalar integer ID.
{"error":"default stock location cannot be deleted"}ID is 1, even if the row is absent.
{"error":"stock location contains inventory"}An active inventory row at this location has qty!=0, including a negative balance.
{"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.
  • Rejects location 1 and locations containing any active non-zero inventory balance. Zero-balance retained rows do not prevent deletion. No inventory quantities or storage assignments are moved.
  • Reparents active direct children to the deleted location's parent. A missing/deleted ancestor or cyclic chain falls back to parent 0. Children receive fresh edit timestamps and individual parentID history, including when the new parent is 0.
  • Deletion, child changes (for storage), history and tenant deletion audit commit together; any checked failure rolls back the transaction.

Side effects

  • Retains stock_storages 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.
  • Reparents active child storage rows and records their parentID history atomically. Historical stock movements retain access to saved/deleted location metadata.

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 Locations. The tree loads StockStorage_getRequestedDetails; Create and rename/parent saves use mapped createData/updateData helpers. Drag nodes then Save to write parentID. Filter Network for StockStorage_deleteData. The UI hides deletion of location 1 and checks inventory first; the server independently enforces both safeguards.

Related endpoints