Booking Tickets

A booking is created by calling createBooking with a JourneyOffer id. The returned booking will include information on passenger details required to complete the booking.

Example: Create a booking
graphql
mutation CreateBooking {
  createBooking(journeyOffer: "741afd68-dd00-4a23-954a-8c62e81e5a1b") {
    id
    passengers {
      id
      age
      type
    }
    requirements {
      passportNumber
      dateOfBirth
      nationality
      email
      tel
    }
    selections {
      ... on JourneyOfferSelection {
        offers {
          ...OfferFragment
        }
        journey {
          ... on JourneySelection {
            itinerary {
              ... on Stopover {
                location {
                  name
                }
              }
              ... on SegmentCollection {
                status
                segments {
                  departureAt
                  arrivalAt
                  origin {
                    name
                  }
                  destination {
                    name
                  }
                }
                offers {
                  ...OfferFragment
                }
              }
            }
          }
        }
      }
    }
  }
}

fragment OfferFragment on Offer {
  id
  price {
    amount
    currency
  }
  parts {
    ... on AdmissionPart {
      conditions {
        description
        type
      }
      flexibility
      serviceClass
      comfortClass
    }
    ... on ReservationPart {
      conditions {
        description
        type
      }
      flexibility
      comfortClass
      accommodation {
        type
      }
    }
  }
}
mutation CreateBooking {
  createBooking(journeyOffer: "e3bd0547-b6c2-408b-b534-70895906ab98") {
    id
    passengers {
      id
      age
      type
    }
    requirements {
      passportNumber
      dateOfBirth
      nationality
      email
      tel
    }
    selections {
      ... on JourneyOfferSelection {
        offers {
          ...OfferFragment
        }
        journey {
          ... on JourneySelection {
            itinerary {
              ... on Stopover {
                location {
                  name
                }
              }
              ... on SegmentCollection {
                status
                segments {
                  departureAt
                  arrivalAt
                  origin {
                    name
                  }
                  destination {
                    name
                  }
                }
                offers {
                  ...OfferFragment
                }
              }
            }
          }
        }
      }
    }
  }
}

fragment OfferFragment on Offer {
  id
  price {
    amount
    currency
  }
  parts {
    ... on AdmissionPart {
      conditions {
        description
        type
      }
      flexibility
      serviceClass
      comfortClass
    }
    ... on ReservationPart {
      conditions {
        description
        type
      }
      flexibility
      comfortClass
      accommodation {
        type
      }
    }
  }
}

Having successfully created a booking does not mean that the tickets have been prebooked. An order needs to be created to hold the tickets for you before finalizing the order. Refer to the expiresAt field of a Booking to see how long you have to create an order.

Selecting Offers

The booking will include the JourneyOfferSelection which contains details on the offers available for each segment of the journey. When first creating a booking an initial selection is automatically made, these are usually the most affordable offers but please note that this is not guaranteed.

To select an offer you update the booking with the selection(s) you wish to make.

Example: Selecting offers
graphql
mutation SelectOffer {
  updateBooking(
    id: "2f061bea-196c-4202-b9a7-7348801b2ce8"
    selections: [{ offer: { id: "82e38927-d3a5-475a-b703-3c60775f73fc" } }]
  ) {
    selections {
      ... on JourneyOfferSelection {
        id
        price {
          amount
          currency
        }
        parts {
          ... on AdmissionPart {
            flexibility
            serviceClass
            comfortClass
          }
          ... on ReservationPart {
            flexibility
            comfortClass
            accommodation {
              type
            }
          }
        }
      }
    }
  }
}
mutation SelectOffer {
  updateBooking(
    id: "2f061bea-196c-4202-b9a7-7348801b2ce8"
    selections: [{ offer: { id: "db6d723c-116f-40be-a425-fe8ce71a96ff" } }]
  ) {
    selections {
      ... on JourneyOfferSelection {
        id
        price {
          amount
          currency
        }
        parts {
          ... on AdmissionPart {
            flexibility
            serviceClass
            comfortClass
          }
          ... on ReservationPart {
            flexibility
            comfortClass
            accommodation {
              type
            }
          }
        }
      }
    }
  }
}

Updating Passengers

Before a booking can be confirmed you need to provide passenger details. The booking will include the PassengerRequirements for the passengers.

Contact person

At least one passenger needs to be marked as the contact person. The contact persons details will be forwarded to the train carrier and is the person that will be contacted in case of any issues.

Example: Updating passengers
graphql
mutation UpdatePassengers {
  updateBooking(
    id: "2f061bea-196c-4202-b9a7-7348801b2ce8"
    passengers: [
      {
        id: "68b9abbd-764e-455d-8a87-83705819d01c"
        email: "jane.doe@example.com"
        isContactPerson: true
        birthDate: "1980-02-15"
        nationality: "NL"
        firstName: "Jane"
        lastName: "Doe"
        title: MS
      }
    ]
  ) {
    id
    passengers {
      ... on FullPassenger {
        id
        isContactPerson
        email
        birthDate
        nationality
        firtName
        lastName
        title
      }
    }
  }
}
mutation UpdatePassengers {
  updateBooking(
    id: "2f061bea-196c-4202-b9a7-7348801b2ce8"
    passengers: [
      {
        id: "68b9abbd-764e-455d-8a87-83705819d01c"
        email: "jane.doe@example.com"
        isContactPerson: true
        birthDate: "1980-02-15"
        nationality: "NL"
        firstName: "Jane"
        lastName: "Doe"
        title: MS
      }
    ]
  ) {
    id
    passengers {
      ... on FullPassenger {
        id
        isContactPerson
        email
        birthDate
        nationality
        firtName
        lastName
        title
      }
    }
  }
}

Create Order

Once you have a booking with all the offerss selected and passengers updated, you can create an order. There are two ways of creating an order; either by creating a payment or by manually creating an order. The latter is a privileged operation and requires a special commercial configuration.

Get tickets

Once an order has been finalized tickets are automatically issued. Tickets come in several formats, depending on the carrier. The most common format is PDF but some train carriers will provide check-in link or a code that allows the passengers to fetch their tickets at the station from a ticketing machine.

Ticket issuing time

It may take 15 minutes or more for the tickets to be issued and collected from the train carriers.

Just like with all types that implement the Node interface, you can use the node query to fetch an Order. See the details on how to query anything for more information.

Example: Get tickets
graphql
query GetTickets {
  node(id: "02a4c469-a47b-409b-ad2f-196f8cdcff6d") {
    ... on Order {
      items {
        ... on JourneyOrderItem {
          resources {
            ... on PdfTicket {
              url
            }
            ... on CheckInResource {
              url
            }
            ... on TicketOnDeparture {
              reference
              description
            }
          }
        }
      }
    }
  }
}
query GetTickets {
  node(id: "e8d5cc58-df3b-49f3-bf06-a8cc8b6405c7") {
    ... on Order {
      items {
        ... on JourneyOrderItem {
          resources {
            ... on PdfTicket {
              url
            }
            ... on CheckInResource {
              url
            }
            ... on TicketOnDeparture {
              reference
              description
            }
          }
        }
      }
    }
  }
}

PDF Tickets

There are several types of tickets. An absolute majority of tickets are PDF files that the passenger can download and either show on their phone or print out before departure. See PdfTicket.

Check-in Resource

Some carriers do not issue tickets automatically but require a check-in via a website before departure. Additional information may need to be provided via this website before it's possible to check in and issue the ticket. See CheckInResource.

Ticket On Departure

Some carriers in the UK issue what is called a Ticket On Departure. These tickets are not issued as PDF files but as a ticket collection reference that the passenger can use to get their tickets at the station from a ticketing machine. See TicketOnDeparture for more information.