Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/160906/Yakultt-App/llms.txt

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

The Orders API is the operational core of Yakult App. Creating an order automatically deducts the sold quantities from each product’s stock in a single database transaction and, when a delivery driver (repartidor) is assigned at creation time, fires an in-app notification to alert them. Status transitions follow the lifecycle Pendiente → En camino → Entregado; any status change triggered by someone other than the assigned driver also sends a notification so drivers stay informed in real time. No global authentication middleware is applied — callers identify themselves via the x-user-id header where needed.

GET /api/ordenes

Returns all orders with their line items, client details, and assigned personnel, ordered from most recent to oldest. Example request
curl http://localhost:3000/api/ordenes
Example response
[
  {
    "id": 1,
    "clienteNombre": "Tienda López",
    "clienteTelefono": "6641234567",
    "vendedorNombre": "Ana García",
    "repartidorId": 3,
    "repartidorNombre": "Luis Méndez",
    "total": 750.00,
    "estado": "Pendiente",
    "fecha": "15 Jan",
    "items": [
      {
        "nombre": "Yakult Original 65ml",
        "cantidad": 30,
        "precio": 15.00
      }
    ]
  }
]
id
number
Unique numeric order ID.
clienteNombre
string
Name of the client who placed the order.
clienteTelefono
string
Phone number of the client.
vendedorNombre
string
Name of the sales promotor who created the order, or null if unassigned.
repartidorId
number
Numeric ID of the assigned delivery driver, or null if unassigned.
repartidorNombre
string
Name of the assigned delivery driver, or null if unassigned.
total
number
Sum of all line item subtotals.
estado
string
Current status: Pendiente, En camino, or Entregado.
fecha
string
Formatted order date, e.g. "15 Jan".
items
array
Line items included in the order.

POST /api/ordenes

Creates a new order, deducts stock for every line item in a single transaction, and optionally notifies the assigned delivery driver. No authentication is required; include x-user-id in the header if needed for downstream notification logic.
Stock deduction is performed as part of order creation in a transaction. If any step fails, the entire operation rolls back. The API does not validate that stock is sufficient before deducting — check GET /api/productos beforehand if needed.
clienteId
number
required
ID of the client receiving the order.
vendedorId
number
ID of the promotor creating the order. Pass null to leave unassigned.
repartidorId
number
ID of the delivery driver responsible for fulfillment. Pass null to leave unassigned. If provided, an in-app notification is sent to this user immediately.
items
array
required
Array of line items. Must contain at least one entry.
total
number
required
Pre-calculated grand total for the order.
Example request
curl -X POST http://localhost:3000/api/ordenes \
  -H "Content-Type: application/json" \
  -d '{
    "clienteId": 1,
    "vendedorId": 2,
    "repartidorId": 3,
    "items": [
      { "productoId": 1, "cantidad": 30, "precio": 15.00 }
    ],
    "total": 450.00
  }'
Example response
{ "id": 1 }
id
number
Auto-generated ID of the newly created order.
Errors
StatusReason
500A database error occurred; the transaction was rolled back.

PUT /api/ordenes/:id/estado

Updates the status of an existing order. If the change is triggered by someone other than the assigned delivery driver, the driver receives an in-app notification.
id
number
required
Numeric ID of the order to update.
estado
string
required
New status for the order. Typical values: Pendiente, En camino, or Entregado.
Pass the caller’s user ID in the x-user-id header so the API can determine whether to notify the repartidor (the notification is skipped when the actor is the same user as the assigned driver). Example request
curl -X PUT http://localhost:3000/api/ordenes/1/estado \
  -H "Content-Type: application/json" \
  -H "x-user-id: 2" \
  -d '{ "estado": "En camino" }'
Example response
{ "ok": true }

PUT /api/ordenes/:id/repartidor

Assigns or unassigns a delivery driver for an existing order. When a driver is assigned, they receive an in-app notification.
id
number
required
Numeric ID of the order to update.
repartidorId
number
required
ID of the delivery driver to assign, or null to remove the current assignment.
Example request
curl -X PUT http://localhost:3000/api/ordenes/1/repartidor \
  -H "Content-Type: application/json" \
  -d '{ "repartidorId": 4 }'
Example response
{ "ok": true }

DELETE /api/ordenes/:id

Permanently deletes an order and all of its line items in a single transaction. If any step fails, the entire operation is rolled back.
Deleting an order does not restore the stock that was deducted when the order was created. Adjust inventory manually via PUT /api/productos/:id if needed.
id
number
required
Numeric ID of the order to delete.
Example request
curl -X DELETE http://localhost:3000/api/ordenes/1
Example response
{ "ok": true }
Errors
StatusReason
500A database error occurred; the transaction was rolled back.

Build docs developers (and LLMs) love