API: Create a New Coach Configuration

Request

Create a new coach configuration with a POST request:

POST /coach-configurations

Request Body:


{
  "coach_id": 1,
  "schedule_id": 2,
  "bus_id": 3,
  "seat_plan_id": 4,
  "route_id": 5,
  "coach_type": 1,
  "status": 1,
  "boarding_dropping_points": [
    {
      "counter_id": 1,
      "type": 1,
      "time": "08:00",
      "starting_point_status": true,
      "ending_point_status": false,
      "status": 1
    },
    {
      "counter_id": 2,
      "type": 1,
      "time": "08:30",
      "starting_point_status": false,
      "ending_point_status": false,
      "status": 1
    },
    {
      "counter_id": 3,
      "type": 2,
      "time": "14:00",
      "starting_point_status": false,
      "ending_point_status": false,
      "status": 1
    },
    {
      "counter_id": 4,
      "type": 2,
      "time": "14:30",
      "starting_point_status": false,
      "ending_point_status": true,
      "status": 1
    }
  ]
}
                

Sample Response:


{
  "success": true,
  "message": "Coach configuration created successfully",
  "data": {
    "data": {
      "id": 1,
      "coach_id": 1,
      "schedule_id": 2,
      "bus_id": 3,
      "seat_plan_id": 4,
      "route_id": 5,
      "coach_type": 1,
      "status": 1,
      "created_by": 1,
      "updated_by": null,
      "created_at": "2025-08-10T10:00:00.000000Z",
      "updated_at": "2025-08-10T10:00:00.000000Z",
      "coach": {
        "id": 1,
        "name": "Express Coach 001",
        "code": "EC001"
      },
      "schedule": {
        "id": 2,
        "name": "Morning Schedule",
        "departure_time": "08:00:00"
      },
      "boarding_droppings": [
        {
          "id": 1,
          "coach_configuration_id": 1,
          "counter_id": 1,
          "type": 1,
          "time": "08:00:00",
          "starting_point_status": 1,
          "ending_point_status": 0,
          "status": 1,
          "counter": {
            "id": 1,
            "name": "Kallyanpur Counter",
            "location": "Kallyanpur, Dhaka"
          }
        }
      ]
    }
  }
}
                

Field Definitions:

  • coach_id - Required, must exist in coaches table
  • schedule_id - Required, must exist in schedules table
  • bus_id - Required, must exist in buses table
  • seat_plan_id - Required, must exist in seat_plans table
  • route_id - Required, must exist in routes table
  • coach_type - Required, 1 = AC, 2 = Non-AC
  • status - Optional, 1 = Active, 0 = Inactive (default: 1)

Boarding/Dropping Points:

  • counter_id - Required, must exist in counters table
  • type - Required, 1 = Boarding, 2 = Dropping
  • time - Required, time in HH:MM format
  • starting_point_status - Boolean, true if this is the starting point
  • ending_point_status - Boolean, true if this is the ending point
  • status - Optional, 1 = Active, 0 = Inactive (default: 1)