Cancel a Booking
The cancel endpoint cancels a hotel reservation. Cancellation policies determine if penalties apply.
Endpoint
POST /hotels/v1/bookings/{bookingId}/cancel
Request
Path Parameters
| Parameter | Type | Description |
|---|---|---|
bookingId | string | Bundleport booking ID |
Body Parameters
| Parameter | Type | Description |
|---|---|---|
reason | string | Cancellation reason (optional) |
cancelPenalty | object | Penalty handling (optional) |
Example Request
{
"reason": "Customer request",
"cancelPenalty": {
"apply": true
}
}
Response
Success Response
{
"booking": {
"id": "BK-987654321",
"status": "CANCELLED",
"reference": {
"bookingID": "BK-987654321",
"clientReference": "BOOKING-2025-001",
"providerReference": "SUPPLIER-12345"
},
"cancelInfo": {
"cancelledAt": "2025-06-05T14:30:00Z",
"reason": "Customer request",
"penalty": {
"amount": 75.00,
"currency": "EUR",
"type": "PERCENT",
"value": 50
},
"refund": {
"amount": 75.00,
"currency": "EUR"
}
}
}
}
Free Cancellation
If cancellation is free:
{
"booking": {
"id": "BK-987654321",
"status": "CANCELLED",
"cancelInfo": {
"cancelledAt": "2025-06-05T14:30:00Z",
"reason": "Customer request",
"penalty": null,
"refund": {
"amount": 150.00,
"currency": "EUR"
}
}
}
}
Cancellation Policies
Before canceling, check the cancellation policy:
const booking = await getBooking(bookingId);
const cancelPolicy = booking.booking.cancelPolicy;
if (!cancelPolicy.refundable) {
// Non-refundable - full penalty
console.log('Booking is non-refundable');
} else {
// Check if within free cancellation period
const freeCancelDeadline = getFreeCancelDeadline(cancelPolicy.cancelPenalties);
const now = new Date();
if (now < new Date(freeCancelDeadline)) {
console.log('Free cancellation available');
} else {
// Calculate penalty
const penalty = calculatePenalty(cancelPolicy.cancelPenalties, booking.booking.price);
console.log(`Cancellation penalty: ${penalty.amount} ${penalty.currency}`);
}
}
Best Practices
1. Check Cancellation Policy First
async function cancelBooking(bookingId, reason) {
// Get booking to check cancellation policy
const booking = await getBooking(bookingId);
// Calculate penalty
const penalty = calculateCancellationPenalty(booking.booking);
// Inform user of penalty
if (penalty.amount > 0) {
const confirmed = await confirmCancellation({
bookingId,
penalty,
message: `Cancellation penalty: ${penalty.amount} ${penalty.currency}`,
});
if (!confirmed) {
return { cancelled: false };
}
}
// Proceed with cancellation
return await cancelBookingRequest(bookingId, reason);
}
2. Handle Cancellation Response
const cancelResult = await cancelBooking(bookingId, reason);
if (cancelResult.booking.status === 'CANCELLED') {
// Process refund if applicable
if (cancelResult.booking.cancelInfo.refund) {
await processRefund(cancelResult.booking.cancelInfo.refund);
}
// Update internal records
await updateBookingStatus(bookingId, 'CANCELLED');
// Notify customer
await notifyCustomer({
bookingId,
status: 'CANCELLED',
refund: cancelResult.booking.cancelInfo.refund,
});
}
Code Examples
- cURL
- JavaScript
- Python
curl -X POST https://api.bundleport.com/hotels/v1/bookings/BK-987654321/cancel \
-H "Authorization: ApiKey YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"reason": "Customer request",
"cancelPenalty": {
"apply": true
}
}'
async function cancelBooking(bookingId, reason) {
const response = await fetch(
`https://api.bundleport.com/hotels/v1/bookings/${bookingId}/cancel`,
{
method: 'POST',
headers: {
'Authorization': 'ApiKey YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
reason,
cancelPenalty: { apply: true },
}),
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error?.message || 'Failed to cancel booking');
}
return await response.json();
}
import requests
def cancel_booking(booking_id, reason):
url = f"https://api.bundleport.com/hotels/v1/bookings/{booking_id}/cancel"
headers = {
"Authorization": "ApiKey YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"reason": reason,
"cancelPenalty": {"apply": True}
}
response = requests.post(url, json=payload, headers=headers)
if not response.ok:
error = response.json()
raise Exception(error.get("error", {}).get("message", "Failed to cancel booking"))
return response.json()
Next Steps
- Retrieve Booking - Get booking details
- List Bookings - Query bookings
- Cancellation Policies - Understand cancellation rules