> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Braian551/viax/llms.txt
> Use this file to discover all available pages before exploring further.

# Trip Status

> Get trip status and manage active trips

## Get Trip by ID

```
GET /viajes/get_trip.php
```

Retrieve detailed information about a specific trip.

### Query Parameters

<ParamField query="trip_id" type="integer" required>
  Trip ID to retrieve
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Request success status
</ResponseField>

<ResponseField name="trip" type="object">
  Complete trip information
</ResponseField>

### Request Example

```bash cURL theme={null}
curl -X GET "https://76.13.114.194/viajes/get_trip.php?trip_id=789" \
  -H "Accept: application/json"
```

### Response Example

```json theme={null}
{
  "success": true,
  "trip": {
    "id": 789,
    "usuario_id": 456,
    "conductor_id": 25,
    "tipo_servicio": "motocicleta",
    "estado": "en_curso",
    "origen": {
      "direccion": "Carrera 15 #85-30, Bogotá",
      "latitud": 4.6814,
      "longitud": -74.0479
    },
    "destino": {
      "direccion": "Calle 72 #10-20, Bogotá",
      "latitud": 4.6533,
      "longitud": -74.0602
    },
    "precio_estimado": 18500,
    "distancia_km": 4.2,
    "fecha_solicitud": "2024-03-15T14:30:00.000Z",
    "fecha_aceptacion": "2024-03-15T14:32:00.000Z",
    "fecha_inicio": "2024-03-15T14:40:00.000Z"
  }
}
```

***

## Accept Trip (Driver)

```
POST /viajes/accept_trip.php
```

Driver accepts a trip request.

### Request Body

<ParamField body="trip_id" type="integer" required>
  Trip ID to accept
</ParamField>

<ParamField body="conductor_id" type="integer" required>
  Driver ID accepting the trip
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Acceptance success status
</ResponseField>

<ResponseField name="trip" type="object">
  Updated trip with driver assigned
</ResponseField>

### Request Example

```bash cURL theme={null}
curl -X POST https://76.13.114.194/viajes/accept_trip.php \
  -H "Content-Type: application/json" \
  -d '{
    "trip_id": 789,
    "conductor_id": 25
  }'
```

***

## Start Trip (Driver)

```
POST /viajes/start_trip.php
```

Mark the trip as started after passenger pickup.

### Request Body

<ParamField body="trip_id" type="integer" required>
  Trip ID to start
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Start success status
</ResponseField>

<ResponseField name="trip" type="object">
  Updated trip with status "en\_curso"
</ResponseField>

### Request Example

```bash cURL theme={null}
curl -X POST https://76.13.114.194/viajes/start_trip.php \
  -H "Content-Type: application/json" \
  -d '{"trip_id": 789}'
```

***

## Complete Trip (Driver)

```
POST /viajes/complete_trip.php
```

Mark the trip as completed and set final price.

### Request Body

<ParamField body="trip_id" type="integer" required>
  Trip ID to complete
</ParamField>

<ParamField body="precio_final" type="number" required>
  Final trip price in COP
</ParamField>

<ParamField body="distancia_real" type="number">
  Actual distance traveled in kilometers
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Completion success status
</ResponseField>

<ResponseField name="trip" type="object">
  Completed trip with final price
</ResponseField>

### Request Example

```bash cURL theme={null}
curl -X POST https://76.13.114.194/viajes/complete_trip.php \
  -H "Content-Type: application/json" \
  -d '{
    "trip_id": 789,
    "precio_final": 19000,
    "distancia_real": 4.5
  }'
```

***

## Cancel Trip

```
POST /viajes/cancel_trip.php
```

Cancel a trip. Can be called by passenger or driver.

### Request Body

<ParamField body="trip_id" type="integer" required>
  Trip ID to cancel
</ParamField>

<ParamField body="motivo" type="string" required>
  Cancellation reason

  **Common reasons:**

  * `Usuario no encontrado`
  * `Cambio de planes`
  * `Tiempo de espera excesivo`
  * `Conductor no disponible`
  * `Emergencia`
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Cancellation success status
</ResponseField>

<ResponseField name="trip" type="object">
  Cancelled trip with cancellation reason
</ResponseField>

### Request Example

<CodeGroup>
  ```bash Passenger Cancellation theme={null}
  curl -X POST https://76.13.114.194/viajes/cancel_trip.php \
    -H "Content-Type: application/json" \
    -d '{
      "trip_id": 789,
      "motivo": "Cambio de planes"
    }'
  ```

  ```bash Driver Cancellation theme={null}
  curl -X POST https://76.13.114.194/viajes/cancel_trip.php \
    -H "Content-Type: application/json" \
    -d '{
      "trip_id": 789,
      "motivo": "Usuario no encontrado"
    }'
  ```

  ```dart Dart theme={null}
  await http.post(
    Uri.parse('https://76.13.114.194/viajes/cancel_trip.php'),
    headers: {'Content-Type': 'application/json'},
    body: jsonEncode({
      'trip_id': tripId,
      'motivo': 'Cambio de planes',
    }),
  );
  ```
</CodeGroup>

***

## Rate Driver (Passenger)

```
POST /viajes/rate_conductor.php
```

Rate the driver after trip completion.

### Request Body

<ParamField body="trip_id" type="integer" required>
  Completed trip ID
</ParamField>

<ParamField body="calificacion" type="integer" required>
  Rating from 1 to 5 stars
</ParamField>

<ParamField body="comentario" type="string">
  Optional review comment
</ParamField>

### Request Example

```bash cURL theme={null}
curl -X POST https://76.13.114.194/viajes/rate_conductor.php \
  -H "Content-Type: application/json" \
  -d '{
    "trip_id": 789,
    "calificacion": 5,
    "comentario": "Excelente conductor, muy amable"
  }'
```

***

## Rate Passenger (Driver)

```
POST /viajes/rate_user.php
```

Rate the passenger after trip completion.

### Request Body

<ParamField body="trip_id" type="integer" required>
  Completed trip ID
</ParamField>

<ParamField body="calificacion" type="integer" required>
  Rating from 1 to 5 stars
</ParamField>

<ParamField body="comentario" type="string">
  Optional review comment
</ParamField>

### Request Example

```bash cURL theme={null}
curl -X POST https://76.13.114.194/viajes/rate_user.php \
  -H "Content-Type: application/json" \
  -d '{
    "trip_id": 789,
    "calificacion": 5,
    "comentario": "Pasajero puntual y respetuoso"
  }'
```

***

## Trip Status Values

<ResponseField name="pendiente" type="status">
  Trip created, waiting for driver
</ResponseField>

<ResponseField name="aceptado" type="status">
  Driver assigned, on the way to pickup
</ResponseField>

<ResponseField name="en_ruta" type="status">
  Driver en route to passenger location
</ResponseField>

<ResponseField name="en_curso" type="status">
  Passenger picked up, trip in progress
</ResponseField>

<ResponseField name="completado" type="status">
  Trip successfully completed
</ResponseField>

<ResponseField name="cancelado" type="status">
  Trip cancelled by passenger or driver
</ResponseField>

## Error Responses

<ResponseField name="400" type="Bad Request">
  Invalid parameters or trip already in final state
</ResponseField>

<ResponseField name="404" type="Not Found">
  Trip not found
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error
</ResponseField>

## See Also

* [Create Trip](/api/trips/create) - Request a new trip
* [Trip History](/api/trips/history) - View past trips
* [Find Nearby Drivers](/api/trips/pricing#find-nearby-drivers) - Check driver availability
