# window.sharepaTermine

Interface for bookings in the browser. sharepa adds it to every page whose code uses it. It only talks to /__sharepa/termine at the page's own address, never directly to Google.

Source: https://sharepa.ai/en/docs/reference/bookings

## Readiness

The script may load after your code. First check whether `window.sharepaTermine` exists, otherwise wait for the event `sharepaTermine` on `document`.

If the interface is still missing after 5 seconds, show "Bookings are not set up for this page yet."

```js
function ready(fn) {
  if (window.sharepaTermine) fn();
  else document.addEventListener("sharepaTermine", fn, { once: true });
}
```

## typen()

`sharepaTermine.typen()`

Returns the booking types of this page.

### Return value

- `types[].id` (Text): Short name, for example `erstgespraech`.
- `types[].name` (Text): Display name.
- `types[].description` (Text or null)
- `types[].duration` (Minutes)
- `types[].locations` (List): `meet`, `telefon`, `vorort` or `link`.
- `timezone` (Text): Your time zone, such as `Europe/Zurich`.

Return value:

```json
{
  "types": [{
    "id": "erstgespraech",
    "name": "First call",
    "description": null,
    "duration": 20,
    "locations": ["meet"]
  }],
  "timezone": "Europe/Zurich"
}
```

## zeiten()

`sharepaTermine.zeiten(type, from, to)`

Returns free start times in UTC. Takes your calendar, buffers, notice and daily limits into account.

### Parameters

- `type` (Text, Required): Short name of the type.
- `from` (YYYY-MM-DD, Required): First day, in your time zone.
- `to` (YYYY-MM-DD, Required): Last day, included. At most 31 days after `from`.

```js
const { slots } = await sharepaTermine.zeiten(
  "erstgespraech", "2026-11-23", "2026-12-04"
);
// ["2026-11-23T08:00:00Z", "2026-11-23T08:30:00Z", …]
```

## buchen()

`sharepaTermine.buchen(details)`

Books a time and returns `{ start, end }` in UTC. A short security check from sharepa appears first; you do not build anything for it.

### Parameters

- `type` (Text, Required)
- `start` (Text, Required): Exactly one value from `slots`.
- `name` (Text, Required)
- `email` (Text, Required)
- `location` (Text, Required): One of the type's `locations`.
- `phone` (Text): Only with `location: "telefon"`.
- `answers` (Object): The page's own questions, flat, field names in lowercase and without a leading underscore.

```js
try {
  await sharepaTermine.buchen({
    type: "erstgespraech",
    start: "2026-11-23T08:00:00Z",
    location: "meet",
    name: "Anna Muster",
    email: "anna@example.com",
    answers: { topic: "Website for my practice" },
  });
} catch (e) {
  if (e.code === "termine.belegt") reloadTimes();
}
```

## Error codes

Errors are `Error` objects with the fields `code` and `status`.

| Code | Status | Meaning | What the page should do |
|---|--:|---|---|
| `termine.aus` | 404 | The page has no active booking type. | "Bookings are not set up for this page yet." |
| `termine.belegt` | 409 | The time was just taken. | Reload the times. |
| `termine.turnstile` | 403 | The security check failed. | Let the visitor try again. |
| `formular.heikel` | 422 | Answers look like password, payment or health data. | Point this out. |
| `termine.ungueltig` | 400 | Details are missing or wrong, such as a time that does not exist. | General error message. |
| `termine.langsam` | 429 | Too many requests or bookings in a short time. | Let the visitor try again later. |
| `formular.grenze` | 429 | The entry limit is reached. | General error message. |
| `termine.gesperrt` | 401 | The page has a password, and the visitor has not unlocked it. | General error message. |
| `termine.nicht_verfuegbar` | 503 | Bookings are not possible right now, for example because the calendar is disconnected. | General error message. |
| `termine.fehler` | 502 | Unexpected error. | General error message. |

## Related guides

- [Bookings on your page, with Google Calendar](https://sharepa.ai/en/guides/bookings)
- [Publishing from the chat](https://sharepa.ai/en/guides/mcp-connector)
