Skip to main content

Split Passenger - Tách Hành Khách Ra PNR Mới

API Endpoint: POST /api/v1/services/booking/v1/tach-pnr


Overview

Split one or more passengers from existing PNR into a new separate PNR.

Use Cases:

  • Passenger cancellation (move to separate PNR before cancel)
  • Group booking separation
  • Individual itinerary changes

Requirements:

  • Original booking must have 2+ passengers
  • Booking must be VietJet Air (VJ)
  • Booking status: HOLD or ISSUED

API Specification

Endpoint

POST {{base_url}}/api/v1/services/booking/v1/tach-pnr

Headers

{
"Content-Type": "application/json",
"Authorization": "Bearer {access_token}"
}

Request Body

{
"ve_id": 659,
"ds_hanh_khach": [1765],
"xac_nhan": "y"
}

Request Fields:

FieldTypeRequiredDescription
ve_idnumberYesOriginal booking ID
ds_hanh_khacharray[number]YesArray of passenger IDs to split
xac_nhanstringYesConfirmation flag ("y" = confirm)

Notes:

  • ds_hanh_khach: Passenger database IDs (from hanh_khach[].id)
  • At least 1 passenger must remain in original PNR
  • VJ auto-confirms split operation

Success Response

Status: 200 OK

{
"message": "Tách PNR thành công",
"data": {
"original_pnr": "ABC123",
"new_pnr": "XYZ789",
"new_reservation_key": "AKqlh8tSfnQBx7rF3¥xvO...",
"passengers_split": 1,
"passengers_remaining": 1
},
"status": "success",
"code": 200
}

Response Fields:

FieldTypeDescription
data.original_pnrstringOriginal PNR (remaining passengers)
data.new_pnrstringNew PNR for split passengers
data.new_reservation_keystringVJ reservation key for new PNR
data.passengers_splitnumberNumber of passengers moved to new PNR
data.passengers_remainingnumberNumber of passengers in original PNR

Error Responses

400 Bad Request - Not Enough Passengers

{
"message": "Booking phải có ít nhất 2 hành khách để tách",
"status": "error",
"code": 400
}

400 Bad Request - Invalid Passenger IDs

{
"message": "Danh sách hành khách không hợp lệ",
"status": "error",
"code": 400
}

400 Bad Request - All Passengers Selected

{
"message": "Phải giữ lại ít nhất 1 hành khách trong PNR gốc",
"status": "error",
"code": 400
}

404 Not Found

{
"message": "Không tìm thấy booking",
"status": "error",
"code": 404
}

Usage Example

Step 1: Get Booking Details

GET /api/v1/services/booking/v1/thong-tin-ve/659

Response:

{
"data": {
"ve": {
"id": 659,
"pnr": "ABC123",
"tong_hanh_khach": 2
},
"hanh_khach": [
{ "id": 1764, "ho": "VO", "ten": "TUONG" },
{ "id": 1765, "ho": "NGUYEN", "ten": "VANB" }
]
}
}

Extract passenger IDs: [1764, 1765]

Step 2: Split Passenger

curl -X POST "http://localhost:3000/api/v1/services/booking/v1/tach-pnr" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access_token}" \
-d '{
"ve_id": 659,
"ds_hanh_khach": [1765],
"xac_nhan": "y"
}'

JavaScript (Node.js)

// Step 1: Get passenger IDs
const reservationResponse = await apiRequest(
CONFIG.BASE_URL,
CONFIG.USE_HTTPS,
STATE.access_token,
`/api/v1/services/booking/v1/thong-tin-ve/${ve_id}`,
"GET"
);

const passengers = reservationResponse.data.data.hanh_khach || [];
const passengerIds = passengers.map(p => p.id);

// Step 2: Split second passenger
const splitRequestBody = {
ve_id: STATE.ve_id,
ds_hanh_khach: [passengerIds[1]], // Split passenger #2
xac_nhan: "y"
};

const splitResponse = await apiRequest(
CONFIG.BASE_URL,
CONFIG.USE_HTTPS,
STATE.access_token,
"/api/v1/services/booking/v1/tach-pnr",
"POST",
splitRequestBody
);

console.log(`Parent PNR: ${splitResponse.data.data.original_pnr}`);
console.log(`New PNR: ${splitResponse.data.data.new_pnr}`);

Flow Diagram


Important Notes

1. Passenger ID vs Passenger Key

Passenger ID (hanh_khach[].id):
- Database internal ID
- Used for tach-pnr API
- Example: 1764, 1765

Passenger Key (hanh_khach[].key):
- VJ API encrypted key
- Used for VJ direct API calls
- Example: "WwXcehUljtnq4kkeHJJtCT..."

2. Booking Status Impact

StatusCan Split?Notes
HOLD (0)YesRecommended - no payment impact
ISSUED (1)MaybeCheck VJ policy - may require refund

3. Fare Distribution

After split:

  • Original PNR: Fare recalculated for remaining passengers
  • New PNR: Fare calculated for split passengers
  • Total may differ from original booking

Success Criteria

  • API returns 200 OK
  • new_pnr is returned
  • Original PNR has reduced passenger count
  • New PNR exists with split passengers

Troubleshooting

Issue: "Booking phải có ít nhất 2 hành khách"

Cause: Trying to split booking with only 1 passenger

Solution:

  • Verify booking has 2+ passengers
  • Check tong_hanh_khach field

Issue: "Phải giữ lại ít nhất 1 hành khách"

Cause: Trying to split all passengers

Solution:

  • Leave at least 1 passenger in original PNR
  • Example: If 2 passengers, can only split 1

Issue: Passenger IDs not found

Cause: Passenger records missing id field

Solution:

  • Check hanh_khach array structure
  • Ensure passengers exist in database

  • 01-LIST-BOOKINGS.md - Get booking ID
  • 02-GET-DETAILS.md - Get passenger IDs
  • 03-PAYMENT.md - Payment for new PNR (if needed)