# Booking endpoints

The endpoints a guest-facing page calls: what a stay costs, which nights are open, a search across a group site, and the handoff to checkout. They are what Haven's own booking widget is built on.

```
https://www.bookwithhaven.com/api/v1/public
```

**No key, and callable from a browser.** Every endpoint here sends `Access-Control-Allow-Origin: *` and answers only what a signed-out visitor to the listing's own Haven page can already see. That is the difference from the account API under `/api/public/v1`, which needs a credential and has no CORS.

Use these from your own site, in the guest's browser or from your server. They are the right tool for a custom booking card or calendar. If you want no code at all, the [booking widget](https://www.bookwithhaven.com/help/add-haven-to-existing-website) does the same job in one tag.

## Conventions on this page

They differ from the account API in two ways. Read them once.

- **Amounts are in major units.** `195.5` is $195.50. Format with the response's `currencyCode`. (The account API uses integer minor units.)
- **Responses are the object itself,** not the `{ success, value, error }` envelope. An error is a JSON object with a `message`, and the HTTP status says what kind.

Dates are `YYYY-MM-DD`. A stay is `start` (check-in) to `end` (check-out); the night of `end` is not part of it.

A listing is addressed by its reference code, the eight-character code in its Haven URL. The Build MCP server's `list_listings` returns the codes for your account.

## Quote a stay

```
GET /properties/{code}/quote?start=2027-07-01&end=2027-07-04&adults=2&children=1&pets=0
```

What one stay costs and whether it can be booked. This is the number to show beside your Book button. Call it whenever the guest changes dates or guests.

| Parameter  | Required | Meaning                       |
| ---------- | -------- | ----------------------------- |
| `start`    | Yes      | Check-in date                 |
| `end`      | Yes      | Check-out date, after `start` |
| `adults`   | Yes      | At least 1                    |
| `children` | No       | Defaults to 0                 |
| `pets`     | No       | Defaults to 0                 |

```json
{
  "code": "a1b2c3d4",
  "propertyId": 4821,
  "start": "2027-07-01",
  "end": "2027-07-04",
  "nights": 3,
  "adults": 2,
  "children": 1,
  "pets": 0,
  "available": true,
  "unavailableReason": null,
  "stayLimitNights": null,
  "bookable": true,
  "bookingMode": "instant",
  "currencyCode": "USD",
  "total": 612.5,
  "taxesAtCheckout": true,
  "tax": 61.25,
  "nightlyRate": 180,
  "lineItems": [
    { "name": "3 nights", "amount": 540, "isDiscount": false },
    { "name": "Cleaning fee", "amount": 72.5, "isDiscount": false }
  ],
  "payNowPercent": 50,
  "listingUrl": "https://stay.example.com",
  "bookingUrl": "https://stay.example.com?scroll=booking&from=2027-07-01&to=2027-07-04&guests=3"
}
```

The total comes from Haven's pricing engine: nightly rates, seasonal and holiday prices, length-of-stay and promotional discounts, and fees. It is the same figure Haven's own booking panel shows. **Show it as returned. Do not add to it, round it or recompute it.**

How to read it:

- **`available: false`** means the stay cannot be booked. `unavailableReason` says why in a word you can turn into a sentence: `not_available`, `minimum_stay`, `maximum_stay`, `too_many_guests`, `no_pets`, `no_check_in`, `no_check_out` or `outside_booking_window`. With a minimum or maximum stay, `stayLimitNights` is the limit. The reason never says what holds the dates or who.
- **`total: null` with `available: true`** means the stay is open but Haven holds no price for it, which is the case when a connected property management system prices and charges the stay. Link to `bookingUrl` rather than showing a number. Haven never returns a stand-in price.
- **`taxesAtCheckout: true`** means tax is added at checkout and is not in `total`. Label the figure "before taxes". `tax` is the estimate.
- **`bookable: false`** means the listing itself is not taking bookings yet (the host has setup left to do). Show the price; hide the Book button.
- **`bookingMode`** is `instant` when the guest pays and is confirmed, `request` when the host approves first. It decides the `intent` you send to the checkout handoff below.
- **`bookingUrl`** is the listing's own page with the stay filled in and the booking panel open. It is a plain link, so it works with no JavaScript. `null` when the stay is not available.

At most 366 nights per quote.

## Nightly prices and availability

```
GET /properties/{code}/night-prices?start=2027-07-01&end=2027-08-01&guests=2
```

One row per night, for drawing a calendar. `end` is exclusive. All three parameters are required.

```json
{
  "code": "a1b2c3d4",
  "currencyCode": "USD",
  "guests": 2,
  "bookable": true,
  "nights": [
    { "date": "2027-07-01", "available": true, "nightlyPrice": 180 },
    { "date": "2027-07-02", "available": false, "nightlyPrice": 180 }
  ]
}
```

`available` means a guest can pick that day as a check-in: it is free, inside the booking window, and starts a free run at least the minimum stay long. `nightlyPrice` is what the listing's booking calendar shows for that night, after its direct-booking discount, and is `null` when Haven holds no figure.

These are per-night figures with no fees or taxes. For what a stay costs, use the quote.

## Search a group site

```
GET /groups/{groupCode}/search?adults=2&children=0&pets=0&from=2027-07-01&to=2027-07-04
```

Every listing on a group site for one stay: which are open, and the price of each. `adults`, `children` and `pets` are required. `from` and `to` go together or not at all; without them the result lists every listing with no prices.

```json
{
  "nights": 3,
  "guests": 2,
  "petsAllowed": true,
  "childrenAllowed": true,
  "maxGuests": 10,
  "nightlyPrices": true,
  "listings": [
    {
      "code": "a1b2c3d4",
      "title": "The Clementine",
      "location": "Asheville, North Carolina",
      "imageUrl": "https://…",
      "maxGuests": 6,
      "bedrooms": 3,
      "bathrooms": 2,
      "href": "https://stay.example.com/stays/the-clementine?from=2027-07-01&to=2027-07-04&guests=2",
      "available": true,
      "unavailableReason": null,
      "stayTotal": 612.5,
      "currencyCode": "USD",
      "taxesAtCheckout": true,
      "nightlyRate": 180
    }
  ]
}
```

Matching listings come first. `href` is each listing's page with the search carried over.

## Start checkout

```
POST https://www.bookwithhaven.com/api/v1/embed/holds
```

Holds the dates and returns the URL of Haven's checkout for that stay. Send the guest there. Haven takes payment through Stripe, collects the rental agreement and any ID check, and the guest lands in their guest portal.

```
Content-Type: application/json
X-Haven-Client-Id: 5b1c2d3e-4f5a-4b6c-8d7e-9f0a1b2c3d4e
```

`X-Haven-Client-Id` is a UUID you generate once per visitor and keep, for example in `localStorage`. It is an anonymous id, not a credential.

```json
{
  "propertyId": 4821,
  "startDate": "2027-07-01",
  "endDate": "2027-07-04",
  "numberOfGuests": 3,
  "numberOfChildren": 1,
  "hasPets": false,
  "numberOfPets": 0,
  "intent": "book"
}
```

`propertyId` is the quote's `propertyId`. `numberOfGuests` is adults plus children. `intent` is `book` when the quote's `bookingMode` is `instant`, and `request` when it is `request`. An optional `discountCode` is applied at checkout.

```json
{
  "holdCode": "9f8e7d6c",
  "claim": "…",
  "bookUrl": "https://www.bookwithhaven.com/book/9f8e7d6c?intent=book&claim=…",
  "checkoutOrigin": "https://www.bookwithhaven.com"
}
```

Set `window.location.href` to `bookUrl`. A `409` means the dates were just taken: quote again and tell the guest. Errors on this endpoint are `{ "error": "…" }`.

There is no call that creates a paid booking directly, by design. Payment, the agreement and the ID check live in the checkout.

## The flow, end to end

1. The guest picks dates and guests. Optionally you drew the calendar from night prices.
2. You call the quote and show its total and line items.
3. On Book, you call the checkout handoff and redirect to `bookUrl`.

In code, with the client the Build MCP server hands out:

```ts
const quote = await getQuote('a1b2c3d4', {
  start: '2027-07-01',
  end: '2027-07-04',
  adults: 2,
});
if (quote.available && quote.bookable) {
  window.location.href = await startCheckout(quote);
}
```

## Errors and limits

| Status | Meaning                                                                                   |
| ------ | ----------------------------------------------------------------------------------------- |
| 400    | A parameter is missing, malformed or unknown, or the dates are outside the booking window |
| 404    | No such listing, or it is not public yet                                                  |
| 409    | Checkout handoff only: the dates are no longer available                                  |
| 429    | Too many requests from one address. Wait `Retry-After` seconds                            |

A `404` for a listing you own almost always means it is not published. The Build MCP server's `check_go_live` says what is left.

The quote and the night-prices endpoints each allow 600 requests per ten minutes from one address. That is far more than a guest uses and well short of what a loop does: do not call these from a render loop, and do not prefetch a quote for every date on a calendar.

Do not cache a quote or a calendar for more than a minute or two. Availability changes when a guest books anywhere.

## What these endpoints do not return

Anything about a guest, a reservation or a host's account. Why a night is taken, or by whom. Wi-Fi, door codes or any arrival detail. For your own account's data, use the account API with an [API key](../00-start-here/05-api-keys.md).
