POST/v1/trains/book/:gdsprovider/prebook

Create a train pre-booking

Create a temporary booking from one or more selected train offers.

Share

Create a temporary booking from one or more selected train offers.

Authentication and headers

HeaderDescription
AuthorizationBearer <secret_key>. Keep the secret on the server and never write it to client logs.
X-Travelandz-Id<public_key>:<profile_code>, where the persisted profile code has the form dp_<12 alphanumeric>.
Content-Typeapplication/json for requests with a JSON body.

Request

Path gdsprovider is currently 0. The body requires a non-empty offerIds array of strings.

Request Params Schema

gdsprovider
enum
0
Yes
Currently 0

Request Body Schema

offerIds
arrayYes
offerIds[]
string[]Yes

Success response

Returns booking with bookingId, expiresAt, terms and conditions, total price, passengers and extra fees.

Response Body Schema

booking
objectYes
bookinggdsprovider
numberYes
bookingbookingId
stringYes
bookingexpiresAt
string
Format: ISO 8601
Yes
bookingtermsAndConditions
arrayYes
bookingtermsAndConditions[]
string[]Yes
bookingtotalPrice
objectYes
bookingtotalPriceamount
numberYes
bookingtotalPricecurrency
stringYes
bookingpassengers
arrayYes
bookingpassengers[]id
stringYes
bookingpassengers[]type
enum
youthadultsenior
Yes
bookingextraFees
arrayYes
bookingextraFees[]amount
numberNo
bookingextraFees[]currency
stringNo

Errors

  • 400 for validation or unknown fields.
  • 401 or 403 for invalid API credentials.
  • 500 internal_communication_error or unknown_error for provider failures.
  • booking_not_found when an offer cannot be pre-booked or has expired.

Usage notes

Keep bookingId and complete the order before expiresAt.

cURL example

bash
bash
curl --request POST \
  --url "https://api.sandbox.travelandz.com/v1/trains/book/0/prebook" \
  --header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  --header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
  --header "Content-Type: application/json" \
  --data '{"offerIds":["offer_123"]}'