The inventory API manages stock levels per branch, supports adjustments and inter-branch transfers, and provides critical stock alerts. All operations are branch-aware — non-admin users can only access their assigned branch.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Carlos-Gnd/FERRED-Inventario-y-Ventas/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/inventario/status
Returns the current online/offline connectivity status of the server. Roles: ADMIN, BODEGA, CAJEROtrue if the server can reach Supabase; false if operating in offline mode.GET /api/inventario/stock/:sucursalId
Returns all stock records for a branch, including full product details. When offline, the response is served from the local SQLite snapshot. Roles: ADMIN, BODEGA, CAJEROWhen the server cannot reach Supabase — either because
online is false or because a Prisma connection error occurs — this endpoint automatically falls back to the local SQLite database. The response shape is identical in both cases.Path parameters
ID of the branch whose stock you want to retrieve.
Response
Returns an array ofStockSucursal records, each including nested product details.
Example
GET /api/inventario/criticos/:sucursalId
Returns all active products in a branch whose current stock is at or below their minimum threshold. Roles: ADMIN, BODEGAPath parameters
ID of the branch to check for critical stock.
Response
Total number of products at or below minimum stock.
GET /api/inventario/criticos-detalle
Returns detailed critical stock items with a computedestado field. ADMIN users can filter by branch using the sucursalId query parameter; other roles see only their assigned branch.
Roles: ADMIN, BODEGA
Query parameters
Filter by branch ID. Only applied when the authenticated user has the ADMIN role.
Response
Total number of critical items returned.
GET /api/inventario/criticos-por-sucursal
Returns the count of critical stock items for every branch. Admin-only. Roles: ADMINResponse
Returns an array, one entry per branch.PATCH /api/inventario/:productoId/ajuste
Applies a stock adjustment for a product in a specific branch. Creates theStockSucursal record if it does not exist (upsert). After adjusting, the product’s aggregate stockActual is recalculated and logged to the sync queue.
Roles: ADMIN, BODEGA
Path parameters
ID of the product to adjust.
Body
ID of the branch where the adjustment takes place.
New absolute stock quantity. Can be negative to correct overstock.
Minimum stock threshold to set for this product in this branch.
Optional free-text reason for the adjustment. Stored in the sync log.
Response
Always
true on success.The updated
StockSucursal record.Aggregate stock across all branches after the adjustment.
POST /api/inventario/transferencia
Transfers stock of a product from one branch to another in an atomic transaction. Fails if the origin branch does not have enough stock. Roles: ADMINBody
ID of the product to transfer.
ID of the source branch. Must differ from
destinoId.ID of the destination branch.
Number of units to transfer. Must be greater than 0 and cannot exceed the stock available at the origin.
Response
Confirmation message:
"Transferencia realizada".Updated
StockSucursal record for the source branch.Updated
StockSucursal record for the destination branch.Errors
| Status | Condition |
|---|---|
| 400 | Missing or invalid fields, or origenId === destinoId. |
| 409 | Insufficient stock in the origin branch. |
Example
GET /api/inventario/stock-comparativo
Returns all active products with their stock levels broken down per branch, along with a computedestado per branch entry.
Roles: ADMIN, BODEGA
Response
Returns an array, one entry per active product.GET /api/inventario/sync-pendientes
Returns counts of sync log entries grouped by status for the current user. ADMIN users see all entries; other roles see only their own. Roles: All authenticated usersResponse
Number of sync log entries with status
PENDIENTE.Number of entries successfully synced (
SINCRONIZADO).Number of entries that failed to sync (
ERROR).Current connectivity status of the server.
The branch ID of the authenticated user, or
null for ADMIN users without an assigned branch.