Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/juadariasmar/inventory_project/llms.txt

Use this file to discover all available pages before exploring further.

Every change to a product’s stock quantity is represented as a movement (Movimiento). Movements come in two varieties: manual ones created directly through this API, and automatic ones generated by other workflows — for example, confirming a sale (POST /api/ventas) produces a salida movement for each line item, and receiving a purchase order creates corresponding entrada movements. This design means the full stock history is always auditable. The Movements API exposes three endpoints: listing, manual creation, and bulk deletion of manual records only.

Endpoints

MethodPathDescriptionAuth required
GET/api/movimientosList movements (cursor pagination)Active session
POST/api/movimientosCreate a manual movementREGISTRAR_MOVIMIENTOS permission or ADMIN
POST/api/movimientos/bulk-deleteDelete multiple manual movementsADMIN

GET /api/movimientos

Returns a paginated list of all movements for the authenticated user’s company, ordered by most recent first. Uses cursor-based pagination for efficient traversal of large movement logs.
cursor
number
The id of the last movement received. Omit to start from the most recent.
limite
number
default:"50"
Number of movements to return. Maximum 100.
curl -X GET "https://your-domain.com/api/movimientos?limite=25" \
  -H "Cookie: <session-cookie>"
Response
items
Movimiento[]
Array of movement objects for this page.
nextCursor
number | null
Pass as cursor in the next request. null when there are no more results.
total
number
Number of items in this page.
Each movement object in items contains:
id
number
Unique movement identifier.
tipo
string
"entrada" (stock in) or "salida" (stock out).
cantidad
number
Number of units moved.
notas
string | null
Optional description of the reason for the movement.
productoId
number
ID of the affected product.
ventaId
number | null
ID of the originating sale, if this movement was created automatically by a sale or sale cancellation.
ordenCompraId
number | null
ID of the originating purchase order, if this movement was created when a purchase order was received.
creadoEn
string
ISO 8601 timestamp when the movement was recorded.
empresaId
string
Company tenant identifier (always matches the session).
Error cases
StatusCause
401No active session, or user is not in ACTIVO state.
403User has no company assigned.
500Unexpected server error.

POST /api/movimientos

Records a manual inventory movement and immediately adjusts the product’s current stock count. This is the correct way to correct stock discrepancies, record breakage, or add stock received outside of the purchase order flow. Permissions: The user must have the REGISTRAR_MOVIMIENTOS permission, or be an ADMIN. Users with REALIZAR_VENTAS permission may create salida movements only.
Movements created automatically by sales, sale cancellations, or received purchase orders are also Movimiento records, but they are linked via ventaId or ordenCompraId. Those linkages are set only by the system — this endpoint creates unlinked manual records.
productoId
number
required
ID of the product to adjust. Must belong to the authenticated user’s company.
tipo
string
required
Movement direction: "entrada" to add stock, "salida" to remove stock.
cantidad
number
required
Number of units to add or remove. Must be a positive integer.
notas
string
Optional human-readable note explaining the reason for this movement (e.g. "Ajuste de inventario físico", "Merma por caducidad").
# Record a manual stock entry (receiving goods without a PO)
curl -X POST "https://your-domain.com/api/movimientos" \
  -H "Content-Type: application/json" \
  -H "Cookie: <session-cookie>" \
  -d '{
    "productoId": 42,
    "tipo": "entrada",
    "cantidad": 50,
    "notas": "Reposición de stock — proveedor local"
  }'
# Record a manual stock exit (breakage, write-off)
curl -X POST "https://your-domain.com/api/movimientos" \
  -H "Content-Type: application/json" \
  -H "Cookie: <session-cookie>" \
  -d '{
    "productoId": 42,
    "tipo": "salida",
    "cantidad": 5,
    "notas": "Merma por caducidad"
  }'
Returns the created movement object with HTTP 201 Created. Error cases
StatusCause
400Missing or invalid fields (e.g. cantidad ≤ 0, unknown tipo).
401No active session.
403Insufficient permissions for the requested movement type.
404Product not found or belongs to a different company.
500Unexpected server error.

POST /api/movimientos/bulk-delete

Deletes multiple manual movements in a single operation. Only movements where ventaId is null (i.e. not linked to any sale or sale cancellation) are eligible for deletion. If the selection includes any sale-linked movements, the entire request is rejected and nothing is deleted.
Deleting movement records does not adjust the product’s current stock count (cantidad). The Producto.cantidad field is a denormalized running total that reflects stock as of the time movements were applied. Use this endpoint only to clean up erroneous manual entries; do not use it to reverse stock adjustments — create a compensating movement instead.
ids
number[]
required
Array of movement IDs to delete. Must contain at least one valid positive integer.
curl -X POST "https://your-domain.com/api/movimientos/bulk-delete" \
  -H "Content-Type: application/json" \
  -H "Cookie: <session-cookie>" \
  -d '{ "ids": [101, 102, 107] }'
Response
eliminados
number
Number of movements deleted.
ids
number[]
The movement IDs that were actually removed.
Error cases
StatusCause
400Empty or invalid ids array.
403Not an ADMIN.
404None of the given IDs exist in the company.
409One or more movements are linked to sales or cancellations and cannot be deleted.
500Unexpected server error.

Build docs developers (and LLMs) love