> Full index: https://docs.buchungapp.com/llms.txt
> Early access. Use the API base, channel key and allowed origins supplied by Buchung before running examples.

# Data model and filtering

```text
Activity UUID → activity availabilities (AAs) / booking options → returned SKU + quantity
             → signed checkout seed → hosted checkout → booking after confirmation
Activity UUID → public facts & customFacts (including PDF downloads)
Operator      → site identity, supported locales, locations, trust signals and legal links
```

## Which resource should I query? [#which-resource-should-i-query]

**Activities** (`GET /activities`) hold localized content, categories, media and typed public facts. An activity-only filter can match activities with no upcoming availabilities; occurrence constraints require at least one qualifying availability. `totalCount` counts distinct matching activities, even when several availabilities match the same activity.

**Activity Availabilities / AAs** (`GET /availabilities`) browse concrete scheduled options of listed activities. Each AA carries its own UUID (`id`), `activityId`, `eventId`, `variationId`, opaque `sku`, effective start/end instants, `status`, `timeZone`, nullable `description`, `locations` and facts. `totalCount` counts matching AA IDs, not people, departures or inventory units.

**Activity-scoped AAs** (`GET /activities/{id}/availabilities`) run the same typed query inside one explicit activity UUID, including an unlisted activity. A valid activity with no matches returns an empty page; absent, draft, archived or foreign activities return `404`. Broad discovery filters never surface unlisted activities.

Grouping matching AAs into event or week cards is optional presentation and owns no bookable identity, facts or capacity total. Keep differing schedules and prices on each option, and do not add non-matching AAs into a filtered group.

## Presentation keys, locations and trust signals [#presentation-keys-locations-and-trust-signals]

`Activity.description`, `Activity.html` and `Activity.usps` stay top-level
projections of platform-declared presentation definitions `_bg:meta`,
`_bg:content` and `_bg:usps`, respectively. A theme or operator may leave any of
these definitions unused, and a frontend may ignore any of the projections.
`html` is rich text cleaned with the storefront read policy for operator rich
text (scripts, event handlers, embeds and images are removed) and may be null;
`usps` may be empty for themed operators. `title` remains activity identity.

For operator places, departure/arrival timezones and server-resolved trust signals (`Site.locations`, `Availability.locations`, `Activity.trustSignals`, `Site.trustSignals`), see [site metadata, locations & trust](/docs/developers/site-metadata).

## UUIDs, handles and hidden activities [#uuids-handles-and-hidden-activities]

Use `GET /activities/{id}` for UUID lookup and `GET /activities/by-handle/{handle}` for handle lookup. Handles can change; retain the returned UUID for durable references. `GET /availabilities/{id}` addresses an AA by UUID. Identifiers are invariant across locales.

**Hidden** means unlisted in broad discovery, including its facet counts, and bookable by direct link under normal rules. Direct detail, scoped availabilities, booking options and public facts work for published and unlisted activities. Draft, archived, absent and foreign activities return `404 not_found`.

## Prices, units and remaining capacity [#prices-units-and-remaining-capacity]

Money arrives as `{ amount, currency }` where `amount` is an integer in minor units (`15000` EUR = €150.00). Advertised prices are from-prices: base price plus compulsory upsells included in advertising, with applicable automatic promotions applied. They are snapshots, not checkout quotes. Booking-options `from` is the cheapest open option that is not sold out, or `null`.

`remaining` belongs to a single AA in its capacity unit (`null` means uncapped). **Never sum, take the maximum of, or aggregate `remaining` values across options:** two alternative AAs can draw from the same underlying pool (for example ten places in one boat fleet) without representing twenty places.

Non-upcoming AAs (`in_progress` or `past`) return `price: null`, `remaining: 0` and `soldOut: true`. Use `status` to distinguish them from upcoming sold-out AAs. `includePast` defaults to `false`.

One quantity unit is a unit of the selected sellable (for example a boat or room), not necessarily one person. Render quantity labels from `bookingUnitNounForms`: preserve entry order, evaluate each entry with its own locale's CLDR cardinal plural rules (`one`, `other`, etc.), and pick the first non-blank value.

## How the contract grows [#how-the-contract-grows]

A `sku` is an opaque sellable reference minted by the server. Never parse or construct it from a resource `id`. Today a SKU names one activity availability; future releases can represent series cohorts or on-demand booking windows using the same opaque field.

Today `BookingOptions.options` lists dated sellables and `from` covers those dated options. Undated sellables (passes, vouchers) and date-range availability searches (stays, bespoke rentals) are planned additive extensions, so do not treat an empty dated-options list as a universal claim that an activity cannot be booked.

Only the following response vocabularies are **open** (new string values may arrive within v1; accept unknown values with the fallback below):

| Open vocabulary | Client fallback |
| --- | --- |
| `CheckoutHandoff.warnings[].code` | Show a generic warning; keep the successful handoff. |
| `TrustSignal.kind` | Render unfamiliar evidence with a fallback; only `review_score` requires a snapshot. |
| `TrustSignal.source` | Preserve unfamiliar provenance without rejecting the signal. |
| `TrustSignal.renderingShape` | Use a fallback for an unknown presentation hint. |
| `TrustSignal.surfaces[]` | Ignore surfaces the frontend does not implement. |
| `CatalogueReference.kind` | Preserve the opaque entity identity and render a fallback label. |
| `Site.locations[].channels[].type` | Skip unsupported contact channels. |

All other enums (including `Fact.kind`, `PublicCustomFact.type`, `Media.type`, location kinds, itinerary roles, availability statuses, query grammar and error codes) are **closed** within v1.

## Typed filters (`where`) [#typed-filters-where]

Activity lists, AA lists and activity-scoped AA lists accept `where` and `facets` as JSON-string GET parameters (encode once with `JSON.stringify` + `URLSearchParams`) or decoded JSON in POST queries. Direct `where` filters work independently of collections. Include `collectionId` whenever you send `facets`.

Every leaf has one top-level key (`activity`, `availability` or `fact`) and one operator (a `from`/`to` pair counts as one range operator):

| Leaf | Operators and values |
| --- | --- |
| `activity: { id: … }` | `eq` UUID or `in` UUID list |
| `activity: { categories: … }` | `containsAny` or `containsAll` UUID list |
| `availability: { event: … }`, `availability: { variation: … }` | `eq` UUID or `in` UUID list |
| `availability: { startDate: … }` | Inclusive `from` and/or `to` `YYYY-MM-DD` dates in the operator timezone (`from ≤ to`) |
| `fact: { scope, set, field, … }` | Reference: `eq`/`in` UUIDs; set: `containsAny`/`containsAll` UUIDs; boolean: `eq`; choice: `eq`/`in` keys; number: finite `eq`/`in` or inclusive `from`/`to`; date: inclusive `from`/`to` |

`fact` filters target the operator's configured filterable fact sets (`scope` is `activity` or `availability`). There are no free-text filters, and `customFacts` are not filterable through `where` yet.

Compose leaves with non-empty `all`, `any`, or `not`. Every occurrence predicate in a combined match constrains the **same AA** before activity deduplication: preserve `(week 1 AND option A) OR (week 2 AND option B)` as two conjunctions rather than flattening ID lists.

Use category, event and variation UUIDs available to the public query. Unavailable references return the same `400 validation_failed` response as unknown ones. Refresh the values from the catalogue or remove the rejected filter. For malformed conditions and selections, use the message and path in [validation details](/docs/developers/errors#catalogue-query-errors).

## Discovery templates [#discovery-templates]

The `CatalogueAttributeDiscovery` schema describes filterable platform and configured fact fields via `scope`, `field`, `type`, `operators` and `template` (plus `set` for fact entries). No discovery HTTP endpoint exists yet; Buchung provides per-operator discovery templates during onboarding.

This synthetic discovery payload advertises a configured boolean field:

```json
{
  "attributes": [
    {
      "scope": "availability",
      "set": "features",
      "field": "enabled",
      "type": "boolean",
      "operators": ["eq"],
      "template": { "fact": { "scope": "availability", "set": "features", "field": "enabled" } }
    }
  ]
}
```

Turn a template into a condition by keeping its keys and adding an advertised operator:

```js
const discoveredAttribute = discovery.attributes[0];
const url = new URL('availabilities', apiBase);
url.searchParams.set('where', JSON.stringify({
  all: [
    { availability: { startDate: { from: '2027-01-01', to: '2027-12-31' } } },
    { fact: { ...discoveredAttribute.template.fact, eq: true } },
  ],
}));
const response = await fetch(url, {
  headers: {
    'X-Buchung-Channel-Key': channelKey,
    'Buchung-Locale': supportedLocale,
  },
});
const page = await response.json();
if (!response.ok) throw new Error(page.error.message);
```

## POST queries for larger filters [#post-queries-for-larger-filters]

Use GET for compact queries. When filters or facet selections approach the 8 KiB URL ceiling, use the matching POST endpoint:

| GET list | POST query | Operation |
| --- | --- | --- |
| `/activities` | `/activities/query` | `activities.query` |
| `/availabilities` | `/availabilities/query` | `availabilities.query` |
| `/activities/{id}/availabilities` | `/activities/{id}/availabilities/query` | `availabilities.queryForActivity` |

Send decoded JSON fields (`where` object, `facets` array, `includePast` boolean, `limit` number, `collectionId`/`cursor` strings). An empty `{}` body uses the GET defaults (`limit: 20`, `includePast: false`). POST queries are read-only, share the GET read rate-limit bucket, return `Cache-Control: private, no-store`, and accept up to 16 KiB JSON bodies.

```js
const response = await fetch(new URL('availabilities/query', apiBase), {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Buchung-Channel-Key': channelKey,
    'Buchung-Locale': supportedLocale,
  },
  body: JSON.stringify({
    where: { fact: { ...discoveredAttribute.template.fact, eq: true } },
    limit: 20,
  }),
});
const page = await response.json();
if (!response.ok) throw new Error(page.error.message);
```

## Configured facets and collections [#configured-facets-and-collections]

A collection returns the activities it selects without exposing its selection criteria.

Get the collection UUID from your storefront setup. Pass it as `collectionId` on an activity or availability list request. Activity lists return eligible activities in the collection, and availability lists return eligible dates for those activities. An activity-scoped availability request for an eligible activity outside the collection returns `200 OK` with empty `items` and `totalCount: 0`.

The `collection` field contains the public ID, handle, title and description. Without `collectionId` the API returns `collection: null` and `facets: []`. An unavailable collection returns `404 not_found`. Check its UUID and booking channel, then ask your Buchung contact to check its storefront setup if it still fails. See [catalogue query errors](/docs/developers/errors#catalogue-query-errors).

The response includes the collection's configured `facets` before you select any options. Select options using the returned opaque `facetId` and `optionIds`:

```js
url.searchParams.set('collectionId', configuredCollectionId);
url.searchParams.set('facets', JSON.stringify([
  { facetId: returnedFacetId, match: 'any', optionIds: [returnedOptionId] },
]));
```

Each facet option also echoes `input`, the exact condition you can pass directly inside `where`. The selection must satisfy the collection, direct `where` clauses and every selected facet, with same-AA matching. Check `supportedMatches` on each facet (`any` or `all`).

```json
{
  "id": "features",
  "title": "Features",
  "description": null,
  "defaultOpen": false,
  "match": "any",
  "supportedMatches": ["any", "all"],
  "optionsTruncated": false,
  "selectedOptionIds": [],
  "options": [
    {
      "id": "enabled",
      "title": "Enabled",
      "description": null,
      "count": 0,
      "input": { "fact": { "scope": "availability", "set": "features", "field": "enabled", "eq": true } }
    }
  ]
}
```

## Query limits [#query-limits]

| Input | Limit | Error on overflow |
| --- | --- | --- |
| Full GET request URL | Strictly below 8 KiB (8,192 bytes) | `414` (code `validation_failed`; use POST `/query`) |
| POST query JSON body | At most 16 KiB (16,384 bytes) | `413 payload_too_large` |
| Condition tree | Max depth 6, max 64 nodes | `400 validation_failed` |
| `in` / `containsAny` / `containsAll` lists | 1–100 values (subject to total query complexity) | `400 validation_failed` |
| Option IDs per facet selection | At most 100 | `400 validation_failed` |
| Combined filters and selections | Depends on the number and size of the conditions used to count facet options | `400 validation_failed` (simplify filters or remove selections) |
| Page size (`limit`) | 1–100 (default 20) | `400 validation_failed` |
| Cursor | At most 4 KiB | `400 validation_failed` |

## Exact totals and facet counts [#exact-totals-and-facet-counts]

Every list response returns exact `totalCount` and facet option counts from a single request snapshot (`evaluatedAt`). In `any` mode, each option's `count` is an alternative count (what matches if only that option were selected in this facet, keeping all other facets and `where` conditions). In `all` mode, it reports the intersection with the other selected options.

Do not sum overlapping option counts into `totalCount`. Automatic event facets draw their options from eligible availabilities for the collection. Facets set `optionsTruncated: true` when the configured cap (up to 200 options) or the query budget limits the options shown. You can add one shown option to your current filters and selections within the request limits. Use the new response to render the controls, since it may show fewer other options. Counts for shown options and `totalCount` stay exact. If exact counting exceeds its time budget, retry `503 count_timeout` with backoff.

## Custom facts and public PDFs [#custom-facts-and-public-pdfs]

Each `Activity` carries `customFacts`, a record of typed `PublicCustomFact` values (`text`, `text_list`, `boolean`, `number`, `choice`, `json`, `pdf`). Localized `text`, `text_list` and `json` values fall back from request locale to operator default; `pdf` requires an exact locale match and carries `{ url, mimeType, size, fileName }`. Use the returned storefront document URL unchanged (it redirects with a `302` to a short-lived signed file URL while published).

```json
{
  "customFacts": {
    "meeting_point": { "type": "text", "value": "Harbour gate", "locale": "en" },
    "difficulty": { "type": "choice", "value": { "key": "easy", "label": "Easy" } },
    "trip_notes": {
      "type": "pdf",
      "locale": "en",
      "value": { "url": "https://storefront.example.com/documents/b06dc7ef-df9c-4e94-a04a-b763ea06782e/trip-notes-en.pdf", "mimeType": "application/pdf", "size": 48213, "fileName": "trip-notes-en.pdf" }
    }
  }
}
```

Structured `facts` use the closed `Fact.kind` set (`reference`, `references`, `text`, `number`, `boolean`, `choice`, `media`, `link`). Reference values carry `{ id, kind }` where `kind` is an open vocabulary:

```json
{
  "facts": {
    "related": {
      "primary": { "label": "Related activity", "kind": "reference", "value": { "id": "a13b8d21-923e-4fe7-bfe2-fdd803abac91", "kind": "activity" } },
      "others": { "label": "Related entities", "kind": "references", "value": [{ "id": "b06dc7ef-df9c-4e94-a04a-b763ea06782e", "kind": "future_entity" }] }
    }
  }
}
```

To create or sync custom definitions, translations and PDFs from a backend, see the [Management API](/docs/developers/management-api).

## How should I render media? [#how-should-i-render-media]

`Activity.media` holds the activity's featured media in display order (events, availabilities and variations carry no media of their own). Media also appears inside `media` facts, trust-signal logos and brand logos.

An activity's `media` array may be empty: render a neutral labelled placeholder or a text-only card, never a broken image or a guessed URL.

```json
{
  "id": "b06dc7ef-df9c-4e94-a04a-b763ea06782e",
  "type": "image",
  "url": "https://media.example.com/activity.jpg",
  "srcSet": [{ "url": "https://media.example.com/activity-640.jpg", "width": 640 }],
  "width": 1280,
  "height": 720,
  "alt": "Illustrative outdoor activity",
  "position": 0
}
```

Rules for Buchung's media pipeline:

- **Treat every image URL as opaque:** most URLs are signed; modifying query parameters or widths breaks the signature.
- **Use only returned `srcSet` entries:** widths typically cover 320, 640, 1200 and 1920 up to the source width, but there may be fewer entries or none. `url` is the widest entry up to 1200.
- **Videos and files:** a `video` entry's `url` is HLS (`.m3u8`) when `muxPlaybackId` is present, otherwise a direct file URL, with optional `posterUrl`. A `file` entry carries `mimeType`, `size` and `fileName`.

```js
function imageAttributes(media, sizes = '(min-width: 1024px) 50vw, 100vw') {
  return {
    src: media.url,
    srcset: media.srcSet.length
      ? media.srcSet.map(({ url, width }) => `${url} ${width}w`).join(', ')
      : undefined,
    sizes,
    alt: media.alt ?? '',
    width: media.width,
    height: media.height,
  };
}
```

