> For the complete documentation index, see [llms.txt](https://docs.phptravels.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.phptravels.com/modules/flights/duffel.md).

# Duffel

Duffel flights API in PHPTRAVELS: create a Duffel access token, add it to the Duffel module settings, set your markup and run a first test flight search.

{% embed url="<https://www.youtube.com/watch?t=115s&v=XRKJvNUivN8>" %}

### What Duffel is

Duffel is a flight API that gives travel businesses access to airline content, including NDC, GDS and low-cost carriers, through one connection. Duffel works with **offers** (the fares returned for a search) and **orders** (the booking created when a traveller pays). PHPTRAVELS ships a Duffel module in the **Flights** category: Duffel supplies the offers and orders, and PHPTRAVELS runs the search page, checkout, markup and booking admin around them.

### What you need

* A Duffel account for your business. Duffel decides which markets and content your account can use.
* A Duffel **test access token** from your Duffel dashboard for setup, and a live token once Duffel activates your account for real bookings.
* Admin access to your PHPTRAVELS website.

### Set up the module

1. Log in to the admin panel at `yourdomain.com/admin`.
2. Go to **Settings > Modules** and open **Duffel**.
3. On **General**, enable the module and keep **Dev mode** on development while you use the test token.
4. On **Credentials**, paste the access token, click **Test** if it is shown, and save.
5. On **Markup**, set your margin so the selling price includes it.

### First test search

1. Search a common route on your website for one adult, a few weeks ahead.
2. Check that Duffel offers appear with airline, times, baggage and price including your markup.
3. Continue to checkout, enter test passenger details and complete the payment step.
4. Confirm the order and airline booking reference appear on the booking in your admin before the customer email goes out.

### Go live

Complete Duffel's activation requirements, replace the test token with your live token and switch **Dev mode** to production. Test and live content are kept apart, so test bookings never reach airlines.

### Common errors

* **Unauthorised** -- the token is wrong, revoked, or a test token is used in production mode.
* **Offer expired** -- Duffel offers are valid for a limited time; search again before booking.
* **No results on a route** -- your Duffel account may not have content for that market.

Questions? Email <info@phptravels.com> or [submit a ticket](https://docs.phptravels.com/support/submit-ticket).
