# Book

Perform a booking by providing the product, interval, occupancy and form values. If the booking is successful, a reference and booking ID will be returned. If a payment URL is included in the response, the user should be redirected to that URL to complete the booking.

## Body

`coupon_codes` `required` `Array<string>`

The coupon codes entered for the booking.

`currency` `required` `Currency | null`

The currency to use for the booking. Defaults to the product's currency. See [the widget docs](https://www.bookingmood.com/docs/widgets/embed-customization) for the allowed values.

`failure_url` `required` `string`

The URL to redirect the user to when a booking payment fails. Defaults to the booking page.

`form_values` `required` `Record<string, string | number | boolean | null | Record<string, string | null>>`

Values for each of the form fields. The keys refer to `services.id`, the values should be valid values for each of these services.

`interval` `required` `{ start: string, end: string }`

The interval to book.

`language` `Language`

The user's preferred language.

`occupancy` `required` `Record<uuid, integer>`

The occupancy for each capacity group. The keys refer to `capacity_groups.id`, the values are the number of guests for that group.

`product_id` `required` `uuid`

The identifier of the product to book.

`redirect_url` `required` `string | null`

The URL to redirect the user to after the booking is completed.

`show_pending_as` `required` `"CONFIRMED" | "TENTATIVE" | "CANCELLED"`

How to interpret pending events when checking if the booking is possible. Defaults to `TENTATIVE`

## Responses

`201`

Information identifying the booking. If a payment URL is set, the user should be redirected to that URL to complete the booking.

TypeScript

```
{
  booking_id: uuid;
  payment_expiry_timestamp: number | null;
  payment_url: string | null;
  reference: string;
  secret: string;
}
```

`POST /book`

```
curl -X POST "https://api.bookingmood.com/v1/book" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "form_values": {
      "00000000-0000-0000-0000-000000000000": {
        "first_name": "John",
        "last_name": "Doe"
      },
      "00000000-0000-0000-0000-000000000001": {
        "city": "Anytown",
        "country": "US",
        "street": "123 Main St",
        "zip": "12345"
      },
      "00000000-0000-0000-0000-000000000002": "+31612345678"
    },
    "interval": {
      "start": "2026-10-30",
      "end": "2026-11-03"
    },
    "occupancy": {
      "00000000-0000-0000-0000-000000000000": 1
    },
    "product_id": "00000000-0000-0000-0000-000000000000"
  }'
```

Example response

JSON

```
{
  "booking_id": "00000000-0000-0000-0000-000000000000",
  "payment_url": null,
  "reference": "ABC123",
  "secret": "SECRET"
}
```
