Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Luisangelebp/SCO_Autolavados/llms.txt

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

All protected endpoints require a valid JWT token obtained from POST /api/users/login. Include it in the Authorization header:
Authorization: Bearer <your_jwt_token>

Service Orders

Manage the vehicle service queue — from creation through laundrer assignment to completion.
Order State Reference:
  • EN_ESPERA — Vehicle is waiting in the reception queue (set manually at creation)
  • LAVANDO — Vehicle is actively being washed (set by PATCH /api/service-orders/:id/start)
  • FINALIZADO — Wash is complete (set by PATCH /api/service-orders/:id/finish or the /state endpoint)
  • En cola — Auto-queued from a customer web order via POST /api/customer/orders (not yet assigned to a laundrer)
  • CANCELLED — Order was cancelled when its parent customer order was rejected
When a service order transitions to FINALIZADO, the system automatically decrements inventory for any items linked as resources to the service definition (ServiceResource records).

Get All Service Orders

Public endpoint — no authentication required. Returns all service orders, optionally filtered by date, vehicle, user, or laundrer. Supports pagination when page and limit are both supplied.
date
string
Filter by date in YYYY-MM-DD format. Returns all orders created on that calendar day.
carId
string
Filter orders by vehicle UUID.
userId
string
Filter orders by the UUID of the receptionist or admin who created them.
laundrerId
string
Filter orders by the UUID of the assigned laundrer.
page
number
Page number for paginated results (requires limit).
limit
number
Number of records per page (requires page). When both are omitted, all records are returned.
GET /api/service-orders
Response 200 — Array of ServiceOrder objects (or paginated wrapper when page/limit are supplied):
id
string
UUID of the service order.
state
string
Current state: EN_ESPERA, LAVANDO, FINALIZADO, En cola, or CANCELLED.
timeStart
string
ISO 8601 datetime when the wash started (or was scheduled to start).
stimatedTimeEnd
string
ISO 8601 datetime of the estimated completion.
timeEnd
string | null
ISO 8601 datetime when the wash actually finished. null until finalized.
comment
string | null
Optional note left by the receptionist.
car
object
Nested vehicle object (plate, mark, model, color, year).
service
object
Nested service object (name, priceUsd, stimatedTimeMin).
laundrer
object | null
Nested user object for the assigned laundrer. null until a laundrer is assigned.
[
  {
    "id": "uuid",
    "state": "LAVANDO",
    "timeStart": "2026-06-26T10:00:00.000Z",
    "stimatedTimeEnd": "2026-06-26T10:30:00.000Z",
    "timeEnd": null,
    "comment": "Cliente pide atención especial en los rines",
    "date": "2026-06-26T10:00:00.000Z",
    "carId": "uuid",
    "car": { "plate": "ABC12D", "mark": "Toyota", "model": "Corolla" },
    "serviceId": "uuid",
    "service": { "name": "Lavado Básico", "priceUsd": 3.0 },
    "laundrerId": "uuid",
    "laundrer": { "name": "Pedro", "lastName": "González" }
  }
]
Paginated response (when page and limit are provided):
{
  "orders": [ /* array of ServiceOrder objects */ ],
  "total": 42,
  "page": 1,
  "totalPages": 5
}

Create a Service Order

🔒 Requires: ADMIN role Creates a new service order in the reception queue.
state
string
required
Initial state for the order. Typically EN_ESPERA when created directly from reception.
timeStart
string
required
ISO 8601 datetime for when the service is scheduled to begin (e.g. 2026-06-26T10:00:00.000Z).
stimatedTimeEnd
string
required
ISO 8601 datetime for the estimated end time.
carId
string
required
UUID of the vehicle being washed.
serviceId
string
required
UUID of the service to be performed (e.g. "Lavado Básico").
userId
string
required
UUID of the receptionist or admin creating the order.
comment
string
Optional note about special customer requests or vehicle condition.
curl -X POST http://localhost:3000/api/service-orders \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "state": "EN_ESPERA",
    "timeStart": "2026-06-26T10:00:00.000Z",
    "stimatedTimeEnd": "2026-06-26T10:30:00.000Z",
    "carId": "<vehicle-uuid>",
    "serviceId": "<service-uuid>",
    "userId": "<admin-uuid>",
    "comment": "Cliente pide atención especial en los rines"
  }'
Response 201 — The newly created ServiceOrder object:
{
  "id": "uuid",
  "state": "EN_ESPERA",
  "timeStart": "2026-06-26T10:00:00.000Z",
  "stimatedTimeEnd": "2026-06-26T10:30:00.000Z",
  "timeEnd": null,
  "comment": "Cliente pide atención especial en los rines",
  "date": "2026-06-26T10:00:00.000Z",
  "carId": "uuid",
  "serviceId": "uuid",
  "userId": "uuid",
  "laundrerId": null
}

Update Order State

🔒 Requires: ADMIN role Manually sets the state of any service order to an arbitrary value. For structured workflow transitions, prefer the dedicated /start and /finish endpoints.
id
string
required
UUID of the service order to update.
state
string
required
The new state value. Common values: EN_ESPERA, LAVANDO, FINALIZADO.
Setting state to FINALIZADO via this endpoint records timeEnd as the current timestamp and automatically decrements inventory for any resources linked to the service. For consistent timeEnd tracking and inventory handling, prefer PATCH /api/service-orders/:id/finish.
curl -X PATCH http://localhost:3000/api/service-orders/<order-uuid>/state \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "state": "FINALIZADO" }'
Response 200 — Updated ServiceOrder object.

Start a Service Order (Assign Laundrer)

🔒 Requires: ADMIN role Assigns a laundrer to the order and transitions its state to LAVANDO. Records timeStart as the actual wash-start timestamp and automatically marks the laundrer as isWorkingToday: true with lastShiftStart set to now.
id
string
required
UUID of the service order.
laundrerId
string
required
UUID of the laundrer (User with role LAUNDRER) to assign to this order.
Returns 500 if the specified laundrer already has another order in LAVANDO state: "Este lavador ya se encuentra lavando un vehículo en este momento". A laundrer can only actively wash one vehicle at a time.
curl -X PATCH http://localhost:3000/api/service-orders/<order-uuid>/start \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "laundrerId": "<laundrer-uuid>" }'
Response 200 — Updated ServiceOrder object with state: "LAVANDO" and laundrerId set:
{
  "id": "uuid",
  "state": "LAVANDO",
  "timeStart": "2026-06-26T10:05:22.000Z",
  "stimatedTimeEnd": "2026-06-26T10:30:00.000Z",
  "timeEnd": null,
  "laundrerId": "uuid",
  "carId": "uuid",
  "serviceId": "uuid",
  "userId": "uuid"
}

Finish a Service Order

🔒 Requires: ADMIN role Marks a service order as complete. Sets state to FINALIZADO, records timeEnd as the current timestamp, and automatically decrements inventory for any items listed as service resources (ServiceResource records linked to the service).
id
string
required
UUID of the service order to finalize.
curl -X PATCH http://localhost:3000/api/service-orders/<order-uuid>/finish \
  -H "Authorization: Bearer <token>"
Response 200 — Updated ServiceOrder object with state: "FINALIZADO" and timeEnd populated:
{
  "id": "uuid",
  "state": "FINALIZADO",
  "timeStart": "2026-06-26T10:05:22.000Z",
  "stimatedTimeEnd": "2026-06-26T10:30:00.000Z",
  "timeEnd": "2026-06-26T10:28:45.000Z",
  "laundrerId": "uuid",
  "carId": "uuid",
  "serviceId": "uuid",
  "userId": "uuid"
}

Delete a Service Order

🔒 Requires: ADMIN role Permanently deletes a service order record from the database. This action is irreversible.
id
string
required
UUID of the service order to delete.
This is a hard delete — the record cannot be recovered. For orders originating from a customer web order, use DELETE /api/customer/orders/:id/reject instead, which safely reverses inventory and marks associated service orders as CANCELLED rather than removing them.
curl -X DELETE http://localhost:3000/api/service-orders/<order-uuid> \
  -H "Authorization: Bearer <token>"
Response 200:
{
  "message": "Orden eliminada correctamente"
}

Laundrer Shift Management

Control which laundrers are active and counted in the wait-time algorithm and daily payroll calculations.

Start a Laundrer’s Shift

🔒 Requires: ADMIN role Marks a laundrer as working today by setting isWorkingToday = true and recording lastShiftStart. Active laundrers are included in the estimated wait-time algorithm and the daily payroll pool.
id
string
required
UUID of the laundrer (User with role LAUNDRER).
Returns 400 if the user UUID does not correspond to a user with the LAUNDRER role.
curl -X PATCH http://localhost:3000/api/laundrers/<laundrer-uuid>/shift/start \
  -H "Authorization: Bearer <token>"
Response 200:
{
  "message": "Turno iniciado exitosamente",
  "laundrer": {
    "id": "uuid",
    "name": "Pedro",
    "lastName": "González",
    "isWorkingToday": true,
    "lastShiftStart": "2026-06-26T08:00:00.000Z"
  }
}

End a Laundrer’s Shift

🔒 Requires: ADMIN role Marks a laundrer as off-shift by setting isWorkingToday = false. The laundrer will no longer be counted in the wait-time estimate or the daily payroll pool.
id
string
required
UUID of the laundrer.
curl -X PATCH http://localhost:3000/api/laundrers/<laundrer-uuid>/shift/end \
  -H "Authorization: Bearer <token>"
Response 200:
{
  "message": "Turno finalizado exitosamente",
  "laundrer": {
    "id": "uuid",
    "name": "Pedro",
    "lastName": "González",
    "isWorkingToday": false
  }
}

Get Estimated Wait Time

Public endpoint — no authentication required. Returns the dynamic estimated wait time based on the current queue depth and the number of laundrers who are actively on shift (isWorkingToday: true). This endpoint powers the customer-facing waiting display.
curl http://localhost:3000/api/autolavado/waiting-time
Response 200:
estimatedWaitTimeMin
number
Estimated minutes until the next available laundrer is free to start a new vehicle.
totalStimatedTime
number
Total estimated minutes until the last vehicle currently in the queue is finished.
activeLaundrers
number
Number of laundrers currently on shift (isWorkingToday: true).
waitingOrdersCount
number
Number of orders currently in an active queue state.
{
  "estimatedWaitTimeMin": 45,
  "totalStimatedTime": 90,
  "activeLaundrers": 2,
  "waitingOrdersCount": 3
}
If activeLaundrers is 0, the wait time calculation cannot proceed. Ensure at least one laundrer has started their shift before opening the queue.

Build docs developers (and LLMs) love