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.

Prefer WebSocket

When creating a booking for a JourneyOffer availability of fares needs to be verified and so the request can be slow and is recommended to be done over WebSocket.

Example: Create a booking
graphql
mutation CreateBooking {
  createBooking(journeyOffer: "837e67d1-2e3e-4724-b9b1-bb076660f553") {
    id
    passengers {
      id
      age
      type
    }
    requirements {
      passportNumber
      dateOfBirth
      nationality
      email
      tel
    }
    selections {
      ... on JourneyOfferSelection {
        fares {
          id
          name
          price {
            amount
            currency
          }
        }
        journey {
          ... on JourneySelection {
            itinerary {
              ... on Stopover {
                location {
                  name
                }
              }
              ... on SegmentCollection {
                status
                segments {
                  departureAt
                  arrivalAt
                  origin {
                    name
                  }
                  destination {
                    name
                  }
                }
                fares {
                  id
                  name
                  price {
                    amount
                    currency
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
mutation CreateBooking {
  createBooking(journeyOffer: "3ae0f99d-11ff-4556-a936-28b2f5648e66") {
    id
    passengers {
      id
      age
      type
    }
    requirements {
      passportNumber
      dateOfBirth
      nationality
      email
      tel
    }
    selections {
      ... on JourneyOfferSelection {
        fares {
          id
          name
          price {
            amount
            currency
          }
        }
        journey {
          ... on JourneySelection {
            itinerary {
              ... on Stopover {
                location {
                  name
                }
              }
              ... on SegmentCollection {
                status
                segments {
                  departureAt
                  arrivalAt
                  origin {
                    name
                  }
                  destination {
                    name
                  }
                }
                fares {
                  id
                  name
                  price {
                    amount
                    currency
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

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 Fares

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

To select a fare you update the booking with the selection(s) you wish to make.

Example: Selecting fares
graphql
mutation SelectFare {
  updateBooking(
    id: "12c60e28-d0b5-4d6b-b27e-87cb706f7174"
    selections: [{ fare: { id: "358e683e-0a14-4d31-b546-f4fa2c7ec6e5" } }]
  ) {
    selections {
      ... on JourneyOfferSelection {
        fares {
          id
          name
          placePreference {
            id
            name
          }
        }
      }
    }
  }
}
mutation SelectFare {
  updateBooking(
    id: "12c60e28-d0b5-4d6b-b27e-87cb706f7174"
    selections: [{ fare: { id: "66664fb7-3f7f-42cb-ab3d-841706329506" } }]
  ) {
    selections {
      ... on JourneyOfferSelection {
        fares {
          id
          name
          placePreference {
            id
            name
          }
        }
      }
    }
  }
}

Create Order

Once you have a booking with all the fares 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 a code that allows the passengers to fetch their tickets at the station from a ticketing machine. Please refer to the Resource type for ticket formats.

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 the an Order. See the details on how to query anything for more information.

Example: Get tickets
graphql
query GetTickets {
  node(id: "aae7d380-710b-424e-858b-ff8f1cca1699") {
    ... on Order {
      items {
        ... on JourneyOrderItem {
          tickets {
            url
            type
          }
        }
      }
    }
  }
}
query GetTickets {
  node(id: "f84ba713-50dc-45c1-9232-a293ee3677b8") {
    ... on Order {
      items {
        ... on JourneyOrderItem {
          tickets {
            url
            type
          }
        }
      }
    }
  }
}