Skip to main content

Warehouse setup

Controller. warehouse.controller.ts. Service: warehouse.service.ts.

CallPath
CreatePOST /v1/operations/warehouse
List and getGET /v1/operations/warehouse and GET /v1/operations/warehouse/:id
UpdatePUT /v1/operations/warehouse/:id
PrimaryPUT /v1/operations/warehouse/:id/primary
DeleteDELETE /v1/operations/warehouse/:id

Create​

WarehouseService.create requires a live seller (seller.error.sellerNotFound) and a live tenant. code must be unique per seller among rows with deletedAt: null (warehouse.error.codeAlreadyExistsForSeller).

The insert sets code, name, description, stockOwnership, type, config, sellerId, and addressId inside a transaction. claimPrimaryIfUnset sets TenantSetting.preferredWarehouseId only when that field is empty. A tenant that already has a preferred warehouse keeps it. The flag lives on the setting, not on the warehouse row, so setPrimary does not demote another row.

setPrimary rejects a missing warehouse, a caller whose tenant does not match unless they are a platform admin (auth.error.insufficientPermissions), and an inactive warehouse (warehouse.error.inactiveWarehouseCannotBePrimary).

stockOwnership includes EXTERNAL. Routing will not auto-pick those warehouses. See Warehouse routing.

Delete​

delete loads a warehouse with deletedAt: null and throws warehouse.error.warehouseNotFound when it is missing. The service does not query stock or fulfillment orders before delete. A foreign key can still reject the SQL. If the deleted id is preferredWarehouseId, the setting is pointed at the oldest remaining warehouse (createdAt ascending), or null when none remain. Success message is warehouse.success.warehouseDeleted.

The warehouse controller does not declare @RequirePermissions. Authenticated callers pass the permissions guard. setPrimary has its own tenant check. Create checks seller and tenant ids on the body. It does not compare those ids with the caller’s allowed warehouses in the portion of create that was read.

Floor access​

Pick and pack use the fulfillment APIs, not this controller. This controller is master data: site, ownership, and which warehouse is primary.