Implementation Guides

Cancelling an order

caution

Order cancellation is not yet supported for all airlines. In the future we plan to surface in the API whether that's possible or not. For now, cancelling an order of an airline that does not support this operation will result in a not_implemented error.

What do you need to start?

All you need to get started with a cancellation is the id of the order you'd like to cancel. If you still haven't learned how to create an order, head over to our quick start.

Overview

The order cancellation process happens in 3 steps:
  • You request a cancellation refund quote

  • You confirm your cancellation

  • You validate your order was cancelled

Request Cancellation Refund Quote

Before you actually cancel an order, we give you the ability to see what your refund would be. We call this step "requesting a cancellation". Using the id of the order you'd like to cancel, request the cancellation to receive the refund amount you'd get back when the order is cancelled.

Shell

curl -X POST --compressed "https://api.duffel.com/air/order_cancellations" \
-H "Accept-Encoding: gzip" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Duffel-Version: beta" \
-H "Authorization: Bearer
$YOUR_ACCESS_TOKEN
" \
-d '{
"data": {
"order_id": "'"
$ORDER_ID
"'"
}
}'
This request is effectively creating an order cancellation object, which can be referenced by its id. The order cancellation will include the refund_currency and refund_amount that will be refunded to your organisation upon cancellation.
{
// we'll use the id on the next step
"id": "ore_00009qzZWzjDipIkqpaUAj",
// determine whether you want to continue with the
// cancellation or not based on the refund amount
"refund_currency": "GBP",
"refund_amount": "90.80",
// if this timestamp is in the past you will
// not be able to confirm your cancellation
// and will need to re-request a cancellation quote
"expires_at": "2020-01-17T10:42:14.545052Z",
...
}
For a complete schema of the order cancellation object please refer to our api reference

Confirm Cancellation

If you'd like to move forward, you can now confirm the cancellation you've created on the previous step. Use the order cancellation unique id to make the following request.

Shell

curl -X POST --compressed "https://api.duffel.com/air/order_cancellations/
$ORDER_CANCELLATION_ID
/actions/confirm" \
-H "Accept-Encoding: gzip" \
-H "Accept: application/json" \
-H "Duffel-Version: beta" \
-H "Authorization: Bearer
$YOUR_ACCESS_TOKEN
"
Once the request is successful you'll receive the order cancellation object in the response and will now include a timestamp in the confirmed_at attribute.

Validate Cancellation

Once you cancel an order, it changes. Cancelled orders may no longer return slices and, most importantly, it will now have a timestamp in the cancelled_at attribute. To validate that your order has been cancelled, you can get an order by id and check the cancelled_at attribute.

Shell

curl -X GET --compressed "https://api.duffel.com/air/orders/
$ORDER_ID
" \
-H "Accept-Encoding: gzip" \
-H "Accept: application/json" \
-H "Duffel-Version: beta" \
-H "Authorization: Bearer
$YOUR_ACCESS_TOKEN
"

Keep Learning

This is it! That's how you cancel an order. To get a complete look at this flow in our API reference you can jump to:
If you haven't learned how to add extra bags to your bookings, we recommend looking at that next: