Skip to main content

Download Itinerary PDF - Tải File PDF Hành Trình

API Endpoint: GET /api/v1/services/booking/v1/ve/{ve_id}/itinerary-pdf


Overview

Download booking itinerary as PDF file.

Supported Airlines:

  • VietJet Air (VJ)
  • Bamboo Airways (QH)
  • Vietnam Airlines (VN)

File Format: PDF (application/pdf)


API Specification

Endpoint

GET {{base_url}}/api/v1/services/booking/v1/ve/{ve_id}/itinerary-pdf

Headers

{
"Authorization": "Bearer {access_token}",
"Accept": "application/pdf"
}

URL Parameters

ParameterTypeRequiredDescription
ve_idnumberYesBooking ID

Request Body

No request body required.


Success Response

Status: 200 OK

Content-Type: application/pdf

Body: Binary PDF file

Example Response Headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename="itinerary-{pnr}-{ve_id}.pdf"
Content-Length: 245678

Downloaded File:

  • File saved to: downloads/{pnr}-{ve_id}.pdf
  • Typical size: 100-500 KB

Error Responses

404 Not Found

{
"message": "Booking not found",
"status": "error",
"code": 404
}

400 Bad Request

{
"message": "Invalid booking ID",
"status": "error",
"code": 400
}

Usage Example

cURL

curl -X GET "http://localhost:3000/api/v1/services/booking/v1/ve/659/itinerary-pdf" \
-H "Authorization: Bearer {access_token}" \
-H "Accept: application/pdf" \
--output itinerary.pdf

JavaScript (Node.js)

const response = await apiRequest(
CONFIG.BASE_URL,
CONFIG.USE_HTTPS,
STATE.access_token,
`/api/v1/services/booking/v1/ve/${ve_id}/itinerary-pdf`,
"GET",
null,
{ "Accept": "application/pdf" }
);

if (response.status === 200) {
const pdfContent = Buffer.isBuffer(response.data)
? response.data
: Buffer.from(response.data, 'base64');

fs.writeFileSync(`downloads/${pnr}-${ve_id}.pdf`, pdfContent);
console.log(`PDF downloaded: ${(pdfContent.length / 1024).toFixed(2)} KB`);
}

Flow Diagram


Notes

  1. File Format: Always returns PDF binary data
  2. File Size: Typically 100-500 KB depending on booking complexity
  3. Booking Status: Works for both HOLD and ISSUED bookings
  4. Content: Includes:
    • PNR and booking reference
    • Flight details (departure/arrival times, airports)
    • Passenger information
    • Fare breakdown
    • Airline terms & conditions

Success Criteria

  • API returns 200 OK
  • Content-Type is application/pdf
  • PDF file can be opened and read
  • File size > 0 bytes

Troubleshooting

Issue: PDF corrupted or cannot open

Cause: Binary data handling issue

Solution:

  • Ensure response data is treated as Buffer
  • Set correct Accept: application/pdf header
  • Do not convert binary to string

Issue: 404 Not Found

Cause: Invalid booking ID

Solution:

  • Verify ve_id exists in database
  • Check booking hasn't been deleted

  • 01-LIST-BOOKINGS.md - Get booking ID
  • 02-GET-DETAILS.md - View booking details
  • 07-SEND-VJ-EMAIL.md - Send itinerary via VJ email