API: Update Trip Instance

Request

Update the details of a specific trip instance by ID:

PUT /coach-configurations/{id}

Request Body (Update with new boarding/dropping points):


{
  "coach_id": 2,
  "bus_id": 1,
  "schedule_id": 1,
  "seat_plan_id": 1,
  "route_id": 1,
  "coach_type": 1,
  "trip_date": "2025-09-18",
  "boarding_dropping_points": [
    {
      "id": 1,
      "counter_id": 1,
      "type": 1,
      "time": "09:00",
      "starting_point_status": true,
      "ending_point_status": false,
      "status": 1
    },
    {
      "counter_id": 5,
      "type": 1,
      "time": "09:30",
      "starting_point_status": false,
      "ending_point_status": false,
      "status": 1
    },
    {
      "counter_id": 6,
      "type": 2,
      "time": "15:00",
      "starting_point_status": false,
      "ending_point_status": true,
      "status": 1
    }
  ]
}
                

Sample Response:


{
  "success": true,
  "message": "Trip Instance updated successfully",
  "data": {
    "id": 1,
    "coach_id": 2,
    "bus_id": 1,
    "schedule_id": 1,
    "seat_plan_id": 1,
    "route_id": 1,
    "coach_type": 1,
    "driver_id": null,
    "supervisor_id": null,
    "trip_date": "2025-09-28T00:00:00.000000Z",
    "status": 1,
    "migrated_trip_id": null,
    "created_by": 2,
    "updated_at": "2025-08-17T10:28:31.000000Z",
    "created_at": "2025-08-17T10:28:31.000000Z"
    "boarding_droppings": [
      {
        "id": 1,
        "coach_configuration_id": 1,
        "counter_id": 1,
        "type": 1,
        "time": "09:00:00",
        "starting_point_status": 1,
        "ending_point_status": 0,
        "status": 1,
        "created_by": 1,
        "updated_by": 1,
        "created_at": "2025-08-10T10:00:00.000000Z",
        "updated_at": "2025-08-10T11:00:00.000000Z"
      },
      {
        "id": 5,
        "coach_configuration_id": 1,
        "counter_id": 5,
        "type": 1,
        "time": "09:30:00",
        "starting_point_status": 0,
        "ending_point_status": 0,
        "status": 1,
        "created_by": 1,
        "updated_by": null,
        "created_at": "2025-08-10T11:00:00.000000Z",
        "updated_at": "2025-08-10T11:00:00.000000Z"
      },
      {
        "id": 6,
        "coach_configuration_id": 1,
        "counter_id": 6,
        "type": 2,
        "time": "15:00:00",
        "starting_point_status": 0,
        "ending_point_status": 1,
        "status": 1,
        "created_by": 1,
        "updated_by": null,
        "created_at": "2025-08-10T11:00:00.000000Z",
        "updated_at": "2025-08-10T11:00:00.000000Z"
      }
    ]
  }
}
                

Update Behavior:

  • Existing Boarding/Dropping Points - Include "id" field to update existing points
  • New Boarding/Dropping Points - Omit "id" field to create new points
  • Remove Points - Points not included in the request will be deleted
  • Core Fields - coach_id, schedule_id, bus_id, seat_plan_id, route_id cannot be updated

Validation Rules:

  • coach_type - Optional, 1 = AC, 2 = Non-AC
  • status - Optional, 1 = Active, 0 = Inactive
  • boarding_dropping_points - Array of boarding/dropping points
  • time - Must be in HH:MM format
  • type - 1 = Boarding, 2 = Dropping

Notes:

  • The trip instance ID is required in the URL to specify which configuration to update.
  • If the trip instance does not exist, the API will return a 404 error.
  • The boarding_dropping_points array completely replaces existing points.
  • Each boarding/dropping point with an ID will be updated, those without will be created.