POST/v1/trains/book/:gdsprovider/:bookingId/order

Create and confirm a train order

Submit passenger details to create and confirm an order from a pre-booking.

Share

Submit passenger details to create and confirm an order from a pre-booking.

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

The body requires passengers[]. Each passenger requires id, title (mr, ms, mx), firstName, lastName, phone and email; send additional fields requested by required-fields.

json
json
{"passengers":[{"id":"passenger_1","title":"mr","firstName":"John","lastName":"Doe","phone":"+34123456789","email":"john.doe@example.com","countryCode":"ES","bornDate":"1988-04-20","nationality":"ES","identityDocument":{"documentNumber":"X1234567","type":"passport"}}]}

Request Params Schema

gdsprovider
enum
0
Yes
Currently 0
bookingId
stringYes
Booking id returned by prebook.

Request Body Schema

passengers
arrayYes
passengers[]id
stringYes
Passenger id returned by prebook.
passengers[]title
enum
mrmsmx
Yes
passengers[]firstName
stringYes
passengers[]lastName
stringYes
passengers[]age
numberNo
passengers[]nationality
string
Format: 2-letter country code
No
passengers[]phone
string
Format: E.164
Yes
passengers[]email
string
Format: email
Yes
passengers[]countryCode
stringNo
passengers[]bornDate
string
Format: YYYY-MM-DD
No
passengers[]cityOfBirth
stringNo
passengers[]countryOfBirth
stringNo
passengers[]address
stringNo
passengers[]city
stringNo
passengers[]postalCode
stringNo
passengers[]identityDocument
objectYes
passengers[]identityDocumentdocumentNumber
stringYes
passengers[]identityDocumenttype
enum
passport
Yes

Success response

Returns orderId, bookingId, bookingReference and bookingStatus. Status can be pending, confirmed or cancelled.

Response Body Schema

orderId
stringYes
bookingId
stringYes
bookingReference
stringYes
bookingStatus
enum
pendingconfirmedcancelled
Yes

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 the pre-booking is missing or expired.

Usage notes

Use the passenger ids returned by prebook. Preserve the order identifiers exactly as returned for later retrieval and refund calls.

cURL example

bash
bash
curl --request POST \
  --url "https://api.sandbox.travelandz.com/v1/trains/book/0/booking_123/order" \
  --header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  --header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
  --header "Content-Type: application/json" \
  --data '{"passengers":[{"id":"passenger_1","title":"mr","firstName":"John","lastName":"Doe","phone":"+34123456789","email":"john.doe@example.com"}]}'