# Booking Slots Calculator API

> Free appointment slots from working hours, busy events (JSON or ICS), duration, step, buffers, notice, capacity, time zones and public holidays.

- Endpoint: `GET | POST https://apibox.io.vn/v1/booking-slots`
- Category: Data & JSON
- HTML docs: https://apibox.io.vn/docs/booking-slots/ (Vietnamese: https://apibox.io.vn/vi/docs/booking-slots/)
- Online tool: https://apibox.io.vn/tools/booking-slots/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Give the working hours (`working_hours`: `{"mon-fri":"08:00-12:00,13:30-17:30","sat":"08:00-12:00"}` or the text `"mon-fri 08:00-12:00,13:30-17:30; sat 08:00-12:00"`), the service `duration` and the grid `step` in minutes, and the date range (`from` / `to` or `days`, up to 62 days). Busy time comes from `busy` (a list of `{start, end}` or `{start, duration}`, with an offset or in the provider zone, optional `seats`) and / or calendars: `ics` text, `ics_url` / `ics_urls` (Google, Outlook, Apple calendar links; recurring events are expanded) or an uploaded .ics `file`. Cancelled and "free" (transparent) events are ignored.

Rules: `buffer_before` / `buffer_after` around each booking, `min_notice` (minutes before the earliest slot), `capacity` (parallel seats: rooms, staff, chairs) with `seats_left`, `max_per_day`, `closed_dates`, special hours per date (`date_overrides`), and public holidays (`holidays=VN` uses the official Vietnamese days off; any other country code uses the holidays dataset; `open_dates` reopens a holiday). Times use the provider `timezone` (IANA, default Asia/Ho_Chi_Minh, daylight saving handled); `customer_timezone` adds the customer’s local times.

The answer lists the slots per day, the first available slot and the holidays in range. `hold_start` checks one slot and returns a tentative iCalendar event (`format=ics` returns the .ics file) to hold it while the customer confirms. Nothing is stored: keep bookings in your own calendar and send them as busy time.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `working_hours` | body|query | object | no | `mon-fri 08:00-12:00,13:00-17:00` | Weekly hours: object by weekday (`mon`…`sun`, `mon-fri`, `weekend`, `daily`) or the text form. |
| `duration` | body|query | number | no | `30` | Service length in minutes (5–1440). |
| `step` | body|query | number | no | `15` | Grid step between slot starts, minutes. |
| `from` | body|query | string | no |  | First date (YYYY-MM-DD, default today); `to` or `days` (default 7, max 62). |
| `timezone` | body|query | string | no | `Asia/Ho_Chi_Minh` | Provider IANA time zone. |
| `customer_timezone` | body|query | string | no |  | Adds customer_start / customer_end in this zone. |
| `busy` | body | array | no |  | Busy intervals `{start, end \| duration, seats?}`. |
| `ics` | body | string | no |  | iCalendar text with busy events (or `ics_url`, `ics_urls`, an .ics `file`). |
| `buffer_before` | body|query | number | no | `0` | Minutes kept free before each booking (`buffer_after` after). |
| `min_notice` | body|query | number | no | `0` | Minimum minutes between now and a slot. |
| `capacity` | body|query | number | no | `1` | Parallel seats (rooms, staff). |
| `max_per_day` | body|query | number | no |  | Maximum slots offered per day. |
| `holidays` | body|query | string | no | `none` | `VN`, another country code, or `none`. `open_dates` reopens dates. |
| `closed_dates` | body|query | array | no |  | Dates closed (YYYY-MM-DD). |
| `date_overrides` | body | object | no |  | Special hours per date, e.g. `{"2026-12-24":"08:00-12:00"}`. |
| `hold_start` | body|query | string | no |  | Slot start to hold: adds a tentative .ics (`format=ics` returns the file). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/booking-slots" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"timezone":"Asia/Ho_Chi_Minh","from":"2026-11-23","to":"2026-11-24","working_hours":"mon-fri 08:00-12:00,13:30-17:30; sat 08:00-12:00","duration":60,"step":30,"buffer_after":15,"holidays":"VN","busy":[{"start":"2026-11-23T09:00","end":"2026-11-23T10:30"}],"max_per_day":4}'
```

## Example response

```json
{
  "timezone": "Asia/Ho_Chi_Minh",
  "from": "2026-11-23",
  "to": "2026-11-24",
  "rules": {
    "duration_minutes": 60,
    "step_minutes": 30,
    "buffer_before_minutes": 0,
    "buffer_after_minutes": 15,
    "min_notice_minutes": 0,
    "capacity": 1,
    "max_per_day": 4,
    "holidays": "VN",
    "now": "2026-11-16T10:00:00+07:00"
  },
  "busy_intervals": 1,
  "total_slots": 4,
  "truncated": false,
  "first_available": {
    "date": "2026-11-23",
    "start": "2026-11-23T10:30:00+07:00",
    "end": "2026-11-23T11:30:00+07:00"
  },
  "days": [
    {
      "date": "2026-11-23",
      "weekday": "mon",
      "weekday_vi": "Thứ Hai",
      "open": true,
      "hours": [
        "08:00-12:00",
        "13:30-17:30"
      ],
      "slots_count": 4,
      "slots": [
        {
          "start": "2026-11-23T10:30:00+07:00",
          "end": "2026-11-23T11:30:00+07:00"
        },
        {
          "start": "2026-11-23T11:00:00+07:00",
          "end": "2026-11-23T12:00:00+07:00"
        },
        {
          "start": "2026-11-23T13:30:00+07:00",
          "end": "2026-11-23T14:30:00+07:00"
        },
        {
          "start": "2026-11-23T14:00:00+07:00",
          "end": "2026-11-23T15:00:00+07:00"
        }
      ]
    },
    {
      "date": "2026-11-24",
      "weekday": "tue",
      "weekday_vi": "Thứ Ba",
      "open": false,
      "reason": "holiday: Vietnamese Culture Day",
      "slots": []
    }
  ],
  "holidays_in_range": [
    {
      "date": "2026-11-24",
      "name": "Vietnamese Culture Day"
    }
  ]
}
```

## Use cases

- Offer free times in a Zalo or Messenger booking bot for a spa, clinic or salon
- Show available appointment times on a landing page or WordPress site
- Find free slots in a staff Google Calendar from an n8n or Make flow
- Book rooms or chairs with several parallel seats

## FAQ

### How do buffers work?

buffer_before and buffer_after are added around each candidate slot; the slot is offered only if the slot plus its buffers does not overlap busy time. The slot itself must fit inside the working hours.

### Can it read my Google Calendar?

Yes, through the secret iCal address of the calendar (ics_url). The calendar is read for this request only and not stored.

### Are Vietnamese holidays included?

With holidays=VN the official days off (Tết, Giỗ Tổ, 30/4–1/5, 2/9, 24/11) are closed on weekdays; open_dates reopens a date and date_overrides sets special hours.
