An Elixir client for the Duffel API.
Usage
Build a client, then pass it to resource functions:
client = Duffel.new(access_token: "duffel_test_...")
{:ok, offer_request} =
Duffel.OfferRequests.create(client, %{
slices: [%{origin: "LHR", destination: "JFK", departure_date: "2026-07-01"}],
passengers: [%{type: "adult"}],
cabin_class: "economy"
})Configuration
new/0 reads configuration from the application environment:
config :duffel, access_token: System.fetch_env!("DUFFEL_ACCESS_TOKEN")Supported options (for new/1 and the application environment):
:access_token- Duffel API access token (required):base_url- defaults to"https://api.duffel.com":api_version- value for theDuffel-Versionheader, defaults to"v2":receive_timeout- milliseconds to wait for a response, defaults to130_000, which covers the 120 seconds Duffel allows order and booking creation to take:req_options- extra options merged into everyReqrequest (useful for test stubs). Merged last, so it overrides everything above
Summary
Functions
@spec new() :: Duffel.Client.t()
Builds a client from the :duffel application environment.
See the module documentation for supported configuration keys.
@spec new(keyword()) :: Duffel.Client.t()
Builds a client from the given options.
Examples
iex> client = Duffel.new(access_token: "duffel_test_abc")
iex> client.api_version
"v2"