Both the passenger and the conductor can move a ride through its lifecycle, but only if they are actually participants of that specific ride. Before applying any update, the server verifies that the requesting user’s ID matches eitherDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DavidCevallos15/Crucidrive---APP/llms.txt
Use this file to discover all available pages before exploring further.
pasajero_id or conductor_id on the record, and that the requested transition is valid given the ride’s current state. Attempts to skip states or cancel a completed ride are rejected.
Access: any authenticated user (authMiddleware only — no role restriction), provided they are a participant of the ride being updated.
Path parameter
UUID of the ride whose status should be changed. Passed as a URL segment:
PATCH /api/viajes/:id/estado.Request body
The target state to transition to. Must be one of:
"en_curso", "finalizado", or "cancelado". Any other value returns a 400 before the database is queried.Example request body
State transition rules
The server enforces the following valid transitions. Any request that violates these rules returns400 with a descriptive message.
| Target state | Required current state | Who can set |
|---|---|---|
en_curso | aceptado | Either participant |
finalizado | en_curso | Either participant |
cancelado | solicitado, aceptado, or en_curso | Either participant |
finalizado or cancelado cannot be cancelled — the server returns 400 with the current state in the error message.
Response 200
The full updated viaje record is returned after a successful transition.
UUID of the ride.
UUID of the passenger participant.
UUID of the conductor participant (set when the ride was accepted).
The new state of the ride:
"en_curso", "finalizado", or "cancelado".Ride fare in USD (
1.50).ISO 8601 timestamp stamped by the server at the time of this update.
Participant validation
Before any state change is applied,cambiarEstadoViaje checks:
userId is req.user.id — the UUID from the validated Supabase JWT. A user who is not listed as either the passenger or the conductor on the record receives a 403, regardless of their platform role.
Error cases
| HTTP status | Cause |
|---|---|
400 | estado is missing or not one of the three valid values |
404 | No ride found with the given :id |
403 | Authenticated user is not pasajero_id or conductor_id of this ride |
400 | Transition is invalid — e.g. trying to set en_curso when ride is still solicitado |
400 | Trying to cancel a ride already in finalizado or cancelado state |