Switch to dark mode

Quick Start

A ticket booking through the API takes seven operations. Try them in the test GraphQL console with a test API key (see API Basics), copying the ids each step returns into the next one. Booking Flows summarizes the same steps for every payment method, and for rail passes.

1. Search for journeys

Find train journeys between two locations on a date. Pick a journey and copy its id.

graphql
query Journeys {
  journeys(
    origin: { uid: "Sb0ISveC" } # London
    destination: { uid: "p6fERure" } # Rome
    date: "2026-12-02"
  ) {
    id
    status
    itinerary {
      ... on SegmentCollection {
        segments {
          departureAt
          identifier
        }
      }
    }
  }
}

2. Get offers

Request prices for the journey and your passengers (journeyOffer). Each leg of the journey (SegmentCollection) has its own offers. Copy the id of the offer you want for each leg.

graphql
query JourneyOffer {
  journeyOffer(
    journeyId: "JOURNEY_ID"
    passengers: [{ type: ADULT }]
  ) {
    status
    itinerary {
      ... on SegmentCollection {
        status
        offers {
          id
          price {
            amount
            currency
          }
        }
      }
    }
  }
}

3. Create a booking

Create a booking from the offer ids (createBooking), with the same passengers you priced. This doesn't book anything with the operator yet. Copy the booking id and the passenger ids.

graphql
mutation CreateBooking {
  createBooking(
    offerIds: ["OFFER_ID"]
    passengers: [{ type: ADULT }]
  ) {
    id
    expiresAt
    passengers {
      id
    }
    requirements {
      passportNumber
      dateOfBirth
      nationality
      email
      tel
    }
  }
}

4. Add passenger details

Add names and contact details with updateBooking, plus anything listed in requirements. Exactly one passenger must be the contact person, with email and tel.

graphql
mutation UpdatePassengers {
  updateBooking(
    id: "BOOKING_ID"
    passengers: [
      {
        id: "PASSENGER_ID"
        firstName: "Jane"
        lastName: "Doe"
        email: "jane.doe@example.com"
        tel: "+46701234567"
        isContactPerson: true
      }
    ]
  ) {
    id
  }
}

5. Create an order

Create an order (createOrder). This pre-books the tickets with the operator and is the same step for every payment method. It can take up to 30 seconds. Copy the order id.

graphql
mutation CreateOrder {
  createOrder(booking: "BOOKING_ID") {
    id
    status
  }
}

6. Finalize the order

Finalize the order (finalizeOrder) to complete the purchase with your wallet or invoice. If your customer pays through the payment gateway instead, pass the order's id to createPayment; the order is finalized automatically after payment.

graphql
mutation FinalizeOrder {
  finalizeOrder(order: "ORDER_ID") {
    id
    status
  }
}

7. Retrieve tickets

Tickets are issued after finalization. Most are available within 15 minutes, but some take longer. Poll the order with node until resources appear. The order status turns CONFIRMED when the purchase completes, before the tickets are ready, so don't wait on the status.

graphql
query GetTickets {
  node(id: "ORDER_ID") {
    ... on Order {
      status
      items {
        ... on JourneyOrderItem {
          resources {
            ... on PdfTicket {
              url
            }
            ... on CheckInResource {
              url
            }
            ... on TicketOnDeparture {
              reference
              description
            }
          }
        }
      }
    }
  }
}

Next steps

For the terms used above, see Key Concepts. Each step has its own guide:

Finding Journeys
Search between two places, or stream results as they arrive.
Getting Offers
Prices, fares, seats and ancillaries for a journey.
Booking Tickets
Passengers, requirements and the booking itself.
Orders
Pre-booking, finalizing and getting the tickets.
Payment Methods
Wallet, invoice, or your customer paying through our gateway.
Booking Rail Passes
The same flow for Interrail and Eurail passes.