The Store Inventory API exposes theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/RoyGeova07/Credith/llms.txt
Use this file to discover all available pages before exploring further.
stores_inventories table, which acts as the bridge between products and stores. Every time a product is added to a store — either at product creation time or via the product update endpoint — a row is inserted into stores_inventories associating that product with the store and recording its current inStock count. Because multiple stores can carry the same product, stock levels are tracked and managed independently per store. In addition to the standard read and update operations, the API provides endpoints for querying your own store’s inventory, identifying low-stock items before they run out, and transferring units between stores without manual adjustments.
The stores_inventories Table
Each row in this table represents a single product-store relationship. The composite primary key is (productId, storeId), meaning a product can appear in many stores but only once per store.
| Field | Type | Description |
|---|---|---|
productId | UUID (PK) | References products.product_id. |
storeId | UUID (PK) | References stores.store_id. |
inStock | INTEGER | Current quantity available in this store. Defaults to 1. |
isActive | BOOLEAN | Whether the product is visible/active in this store. Defaults to true. Set to false when the product is store-archived via DELETE /api/products/:id?storeId=.... |
Stock is decremented atomically inside the bill creation transaction. When
POST /api/bills is processed, each line item in the invoice reduces the corresponding inStock value for the store where the sale occurs. If any product in the bill has insufficient stock at the time of checkout, the entire transaction is aborted and no inventory changes are committed.Get All Inventories (Paginated)
stores_inventories records across every store, with the associated product details and store data embedded in each row. Restricted to OWNER role only.
Maximum number of inventory records to return per page.
Number of records to skip. Used for pagination.
Get Inventory for a Specific Store
404 is returned. Restricted to OWNER role.
UUID of the store whose inventory you want to retrieve.
Get Stock for a Single Product in a Store
404 if no matching record exists (i.e., the product has never been registered in that store). Restricted to OWNER role.
UUID of the store.
UUID of the product.
Get My Store’s Inventory
req.user.storeId — no path or query parameter is needed. Returns 400 if the user does not have a store assigned. Accessible by any authenticated user.
Response
Get Low-Stock Items
inStock is at or below the specified threshold. ADMIN users see only their own store; OWNER users see all stores belonging to their company. Accessible by OWNER and ADMIN roles.
Inventory quantity at or below which a product is considered low-stock. Must be
>= 0. Defaults to 5.Update Stock
inStock value for a specific product-store combination. Use this to perform manual stock corrections or restocking operations. Requires OWNER or ADMIN role.
UUID of the product whose stock will be updated.
UUID of the store in which to update the stock count.
The new stock count. Must be
>= 0. This value replaces the current inStock value — it is not additive.Transfer Stock Between Stores
inStock is decremented and the destination store’s inStock is incremented by the same amount. If the destination store does not yet have an inventory record for the product, one is created automatically. Requires OWNER role.
UUID of the product to transfer.
UUID of the store from which stock will be deducted. Must differ from
toStoreId.UUID of the store that will receive the transferred stock. Must differ from
fromStoreId.Number of units to transfer. Must be
>= 1. Returns 400 if the source store has fewer units available than the requested quantity.Inventory Record Object
UUID of the product. Part of the composite primary key.
UUID of the store. Part of the composite primary key.
Current quantity of the product available in the store. Decremented automatically by bill creation. Minimum is
0; the API will reject negative values on manual updates.Whether this product-store combination is currently active. Set to
false when the product is store-level archived via DELETE /api/products/:id?storeId=.... Inactive inventory records are excluded from product listings.Role Requirements
| Endpoint | Required Role |
|---|---|
GET /api/store-inventory | OWNER |
GET /api/store-inventory/store/:storeId | OWNER |
GET /api/store-inventory/:storeId/:productId | OWNER |
GET /api/store-inventory/my-store | Any authenticated user |
GET /api/store-inventory/low-stock | OWNER, ADMIN |
PATCH /api/store-inventory/stock | OWNER, ADMIN |
POST /api/store-inventory/transfer | OWNER |
Error Responses
| Status | Meaning |
|---|---|
400 | Invalid stock value, missing required fields, insufficient stock for transfer, or fromStoreId === toStoreId |
404 | Inventory record, store, or product not found |
500 | Unexpected server error |