#Booking engine
A public page where guests book a room themselves, on a Antero Connect address or inside the hotel's own website. A booking made there is an ordinary booking: it takes its rooms off sale everywhere, in the same step, and appears in the feed like any other.
Payment. Guests pay at the property; nothing is charged online yet. Online payment will come as an option; the booking flow and this API will not change shape for it.
#Set it up
The hotel's settings need a key with write:catalog (to read them: read:catalog):
export CHANNEL_MANAGER=https://api.anteromas.com # the address of your Channel Manager service
export KEY=cm_prod_ab12cd34_0123456789abcdef0123456789abcdef # your API key
curl -s -X PUT "$CHANNEL_MANAGER/v1/properties/$PROPERTY_ID/booking-engine" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: be-1" \
-d @- <<EOF
{
"enabled": true,
"slug": "villa-sunrise",
"title": "Villa Sunrise",
"accent": "#0a7d5a",
"welcome": "Book direct and get a free breakfast.",
"cancellation_policy": "Free cancellation until 3 days before arrival.",
"terms": "Check-in from 2 pm, check-out until 11 am.",
"max_nights": 14,
"max_rooms": 3,
"advance_days": 365,
"min_advance_days": 1,
"same_day_until": null,
"fees": [
{
"name": "VAT",
"kind": "percent",
"basis_points": 1000
},
{
"name": "Cleaning fee",
"kind": "per_stay",
"amount": 2500
}
]
}
EOFimport os
import requests
CHANNEL_MANAGER = os.environ["CHANNEL_MANAGER"] # the address of your Channel Manager service
KEY = os.environ["KEY"] # your API key
r = requests.put(
f"{CHANNEL_MANAGER}/v1/properties/{PROPERTY_ID}/booking-engine",
headers={"Authorization": f"Bearer {KEY}", "Idempotency-Key": "be-1"},
json={
"enabled": True,
"slug": "villa-sunrise",
"title": "Villa Sunrise",
"accent": "#0a7d5a",
"welcome": "Book direct and get a free breakfast.",
"cancellation_policy": "Free cancellation until 3 days before arrival.",
"terms": "Check-in from 2 pm, check-out until 11 am.",
"max_nights": 14,
"max_rooms": 3,
"advance_days": 365,
"min_advance_days": 1,
"same_day_until": None,
"fees": [
{
"name": "VAT",
"kind": "percent",
"basis_points": 1000,
},
{
"name": "Cleaning fee",
"kind": "per_stay",
"amount": 2500,
},
],
},
)
r.raise_for_status()
print(r.status_code, r.text)// Node.js 18 or newer (fetch is built in); save as a .mjs file
const CHANNEL_MANAGER = process.env.CHANNEL_MANAGER; // the address of your Channel Manager service
const KEY = process.env.KEY; // your API key
let r; // the last answer
r = await fetch(`${CHANNEL_MANAGER}/v1/properties/${PROPERTY_ID}/booking-engine`, {
method: "PUT",
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json", "Idempotency-Key": "be-1" },
body: JSON.stringify({
enabled: true,
slug: "villa-sunrise",
title: "Villa Sunrise",
accent: "#0a7d5a",
welcome: "Book direct and get a free breakfast.",
cancellation_policy: "Free cancellation until 3 days before arrival.",
terms: "Check-in from 2 pm, check-out until 11 am.",
max_nights: 14,
max_rooms: 3,
advance_days: 365,
min_advance_days: 1,
same_day_until: null,
fees: [
{
name: "VAT",
kind: "percent",
basis_points: 1000,
},
{
name: "Cleaning fee",
kind: "per_stay",
amount: 2500,
},
],
}),
});
if (!r.ok) throw new Error(await r.text());
console.log(r.status, await r.text());<?php
$CHANNEL_MANAGER = getenv("CHANNEL_MANAGER"); // the address of your Channel Manager service
$KEY = getenv("KEY"); // your API key
$ch = curl_init("{$CHANNEL_MANAGER}/v1/properties/{$PROPERTY_ID}/booking-engine");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer {$KEY}", "Content-Type: application/json", "Idempotency-Key: be-1"],
CURLOPT_POSTFIELDS => json_encode([
"enabled" => true,
"slug" => "villa-sunrise",
"title" => "Villa Sunrise",
"accent" => "#0a7d5a",
"welcome" => "Book direct and get a free breakfast.",
"cancellation_policy" => "Free cancellation until 3 days before arrival.",
"terms" => "Check-in from 2 pm, check-out until 11 am.",
"max_nights" => 14,
"max_rooms" => 3,
"advance_days" => 365,
"min_advance_days" => 1,
"same_day_until" => null,
"fees" => [
[
"name" => "VAT",
"kind" => "percent",
"basis_points" => 1000,
],
[
"name" => "Cleaning fee",
"kind" => "per_stay",
"amount" => 2500,
],
],
]),
]);
$out = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 400) { throw new RuntimeException($out); }
echo $status, " ", $out, "\n";| Field | |
|---|---|
slug | the address: /book/<slug>. 3 to 40 of a-z, 0-9 and -, not starting or ending with -, unique on the whole server (409 slug_taken). Capitals are made small |
enabled | while false the address answers 404, like one that never existed |
title, welcome, cancellation_policy, terms | what guests read. If terms is set, a guest must accept it to book |
accent | the colour of buttons, #rrggbb |
max_nights, max_rooms, advance_days | what a guest may ask: longest stay (1 to 90), most rooms in a booking (1 to 10), how far ahead (1 to 540 days) |
fees | taxes and fees, up to five lines, shown to guests and added to the price (see below) |
guest_change_days | how long a guest may change or cancel their own booking: until this many days before arrival (0 to 60, left out = 3); null = never online. See The guest's own page |
min_advance_days, same_day_until | how soon: at least this many days ahead (0 = a stay may start today); and for a stay that starts today, the time of day (HH:MM, the property's own time) after which it can no longer be booked. Over either, the page says so (too_soon, same_day_closed) |
#The guest's own page
The confirmation email has a link, https://<your Antero Connect>/book/<slug>#manage=kmb_…. With it a guest sees their booking, changes their own details and cancels, until the day the hotel set (guest_change_days: that many days before arrival; the default is 3, null means never online). After that day, the page says to contact the hotel.
What a guest can change is only how they are reached and what they said: name, phone, notes and their answers to the questions. Dates, rooms, number of guests, email address and price cannot be changed by the guest, because those move rooms and prices; the hotel does that. A cancellation gives the rooms back everywhere at once, tells the hotel like any cancellation, and emails the guest.
The secret in the link is kept only as a hash. It is after the #, so it never reaches a log or a referrer. Every wrong secret answers the same 404. Calls (no key): POST /book-api/<slug>/my-booking, …/my-booking-change, …/my-booking-cancel, each with token. The secret is given once, as manage_token in the answer that made the booking; when the hotel sends the confirmation again (POST /v1/reservations/{id}/send-confirmation) the booking gets a new secret and the old link stops working. Only bookings the hotel made itself have a link, not a channel's.
#Questions
The page can ask every guest up to five questions of the hotel's own (questions on PUT …/booking-engine, or Settings › Booking engine): a line of text, or a choice of 2 to 8 options, each required or not. The server gives them the ids q1, q2, … in order. A guest's booking carries answers ({"q1": "about 3 pm"}); a required question left empty, a choice that is not one of its options, or an answer longer than 500 characters is refused (400 answers_invalid, and the booking page asks again).
A booking keeps each question as it was asked beside the answer, so changing a question later never rewrites an old booking. The reservation shows answers only to a caller who may see personal data (read:reservations.personal), the hotel's notification email carries them, and erasing the guest (guest-data/erase) erases them.
#Promo codes
A guest can type a code on the booking page and the stay costs less. The hotel makes them with POST /v1/properties/{id}/promo-codes (or in Settings › Promo codes): a percentage (basis_points, 1000 = 10.00%) or an amount off the whole stay, optionally only for stays that arrive in a period (arrive_from, arrive_to), for at least min_nights, and for at most max_uses bookings. The code is kept in capitals; a guest's capitals do not matter.
The discount comes off the rooms; taxes and fees are worked out on what is left. It is the first of lines, negative, so total is already what the guest pays. In a quote, promo says whether the code was used and, if not, why (reason); a code that cannot be used leaves the price as it is. A booking with a code that cannot be used is refused (409 promo_invalid) and books nothing. The use is counted in the same transaction as the booking, so the last use of a code goes to one guest only; a retry of the same attempt is the same booking and counts once. A booking keeps the discount it was priced with, so switching a code off later changes nothing already booked. To stop a code, set active: false.
The whole document is sent each time. The page is then at https://<your Antero Connect>/book/<slug>; Antero Connect panel's Settings › Booking engine does all this with a form, and shows the link and the snippet below.
#Put it on your own website
Use the page in a frame:
<iframe src="https://api.anteromas.com/book/villa-sunrise" title="Book a room" width="100%" height="900" style="border:0;max-width:760px"></iframe>Only the booking page may be framed by other sites; the management panel never can.
#Build your own page
The page is a client of a public API. You can build your own page against it. No key is needed, so the calls can come straight from a guest's browser (any origin is allowed), and they are held to limits per address.
In the samples below SLUG is the address you chose (villa-sunrise in the example above).
| Call | Does |
|---|---|
GET /book-api/{slug} | the name, colour, texts, currency, today in the property's time zone, the limits and the rooms that can be booked |
POST /book-api/{slug}/quote | for the dates and guests, an offer for each room: bookable and the total |
POST /book-api/{slug}/reservations | books it |
curl -s -X POST "$CHANNEL_MANAGER/book-api/$SLUG/quote" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"arrival": "2027-03-11",
"departure": "2027-03-13",
"rooms": 1,
"adults": 2
}
EOFr = requests.post(
f"{CHANNEL_MANAGER}/book-api/{SLUG}/quote",
json={
"arrival": "2027-03-11",
"departure": "2027-03-13",
"rooms": 1,
"adults": 2,
},
)
r.raise_for_status()
print(r.status_code, r.text)r = await fetch(`${CHANNEL_MANAGER}/book-api/${SLUG}/quote`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
arrival: "2027-03-11",
departure: "2027-03-13",
rooms: 1,
adults: 2,
}),
});
if (!r.ok) throw new Error(await r.text());
console.log(r.status, await r.text());$ch = curl_init("{$CHANNEL_MANAGER}/book-api/{$SLUG}/quote");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"arrival" => "2027-03-11",
"departure" => "2027-03-13",
"rooms" => 1,
"adults" => 2,
]),
]);
$out = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 400) { throw new RuntimeException($out); }
echo $status, " ", $out, "\n";{"arrival": "2027-03-11", "departure": "2027-03-13", "rooms": 1, "offers": [{"room_type_id": "…", "bookable": true, "total": 24000, "currency": "USD", "per_night": [12000, 12000]}]}bookable is true only when the room is free every night, priced every night, and the guests fit. How many rooms are left is never told.
curl -s -X POST "$CHANNEL_MANAGER/book-api/$SLUG/reservations" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"room_type_id": "$ROOM_TYPE_ID",
"arrival": "2027-03-11",
"departure": "2027-03-13",
"rooms": 1,
"adults": 2,
"token": "c1b2a3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"locale": "en",
"guest": {
"name": "Maria Silva",
"email": "maria.silva@example.com",
"phone": "+55 11 5550 0123"
},
"notes": "Quiet room please",
"website": ""
}
EOFr = requests.post(
f"{CHANNEL_MANAGER}/book-api/{SLUG}/reservations",
json={
"room_type_id": f"{ROOM_TYPE_ID}",
"arrival": "2027-03-11",
"departure": "2027-03-13",
"rooms": 1,
"adults": 2,
"token": "c1b2a3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"locale": "en",
"guest": {
"name": "Maria Silva",
"email": "maria.silva@example.com",
"phone": "+55 11 5550 0123",
},
"notes": "Quiet room please",
"website": "",
},
)
r.raise_for_status()
print(r.status_code, r.text)r = await fetch(`${CHANNEL_MANAGER}/book-api/${SLUG}/reservations`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
room_type_id: `${ROOM_TYPE_ID}`,
arrival: "2027-03-11",
departure: "2027-03-13",
rooms: 1,
adults: 2,
token: "c1b2a3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
locale: "en",
guest: {
name: "Maria Silva",
email: "maria.silva@example.com",
phone: "+55 11 5550 0123",
},
notes: "Quiet room please",
website: "",
}),
});
if (!r.ok) throw new Error(await r.text());
console.log(r.status, await r.text());$ch = curl_init("{$CHANNEL_MANAGER}/book-api/{$SLUG}/reservations");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"room_type_id" => "{$ROOM_TYPE_ID}",
"arrival" => "2027-03-11",
"departure" => "2027-03-13",
"rooms" => 1,
"adults" => 2,
"token" => "c1b2a3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"locale" => "en",
"guest" => [
"name" => "Maria Silva",
"email" => "maria.silva@example.com",
"phone" => "+55 11 5550 0123",
],
"notes" => "Quiet room please",
"website" => "",
]),
]);
$out = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 400) { throw new RuntimeException($out); }
echo $status, " ", $out, "\n";{"status": "confirmed", "reference": "KN-Q37KA9", "room": "Deluxe", "arrival": "2027-03-11", "departure": "2027-03-13", "rooms": 1, "total": 24000, "currency": "USD", "pay": "at_property", "email_sent": true}#Three rules of a good booking page
- Make a
tokenonce per attempt, when the guest reaches the details, and send the same one on every retry of that attempt. Pressing the button twice, or a retry after a timeout, then returns the first booking (200instead of201) and sends no second email. Make a new token for a new booking. - Include the field
website, empty, and hide it from people (off screen, notdisplay:none, and out of the tab order). Only a robot fills it in. A booking that fills it is told it worked and nothing is booked. - Say kindly when a room is gone. Two guests can ask for the last room: the second gets
409 no_availability. Offer other dates; do not show the raw message.
#Taxes and fees
Each line of fees is one of four kinds, and is either added to the total or only shown as included (when the room price already has it in):
kind | Works out as |
|---|---|
percent (basis_points: 1000 is 10.00%) | a share of the room price. Added: 10% of the price. Included: the part of the price that is tax, price × p ÷ (1 + p) |
per_stay (amount) | once for the stay, however many rooms |
per_night | for each room and night |
per_adult_night | for each adult and night (tourism taxes) |
Every offer of a quote carries subtotal (the rooms), lines (what each line came to) and total (what the guest pays: the subtotal plus the lines that are added), and the booking is made at exactly that total, so the page and the booking cannot disagree. A booking keeps the lines it was priced with (price_lines on the reservation), so changing the settings later never rewrites an old booking. A quote made with a key for the hotel itself stays the room price only: a person at the desk sets their own total. Rounding is to the nearest unit, half up.
#What comes back, and what does not
email_sent says whether the confirmation could be sent; the booking stands either way, so show the reference. The guest's email is not returned. The email says what was booked, in locale (en or id).
#Limits and abuse
The hotel's own rules hold too: a stay that breaks a restriction (minimum stay, closed to arrival, stop sell) is refused with 409 not_sellable, and the quote says which rule a room breaks, so a page can tell the guest what to change.
Looking (page, quote) is limited to 300 an hour per address; booking to 10 an hour per address and 5 an hour per guest email, over which the answer is 429 too_many_attempts with Retry-After. The page is off while enabled is false, and for a suspended organization, with the same 404 as a page that never existed.
Be aware: a booking that pays at the property holds rooms. The limits make careless abuse hard, not impossible. The hotel sees every booking made on the page (
booked_via: engine) and can cancel it.
#In the feed
A booking from the page is source: manual, booked_via: engine. In a property run by your system it is held and goes in the feed as created, like a channel booking.