# Ressera Customer API: full guide

Version 1.1.0. Base URL: https://ressera.com

This API lets a venue website list bookable start times and get server-calculated price quotes. It is read-and-quote only. A quote does not reserve capacity, create a booking or take payment. To book, send the customer to the venue's booking page.

## Aurora Lasergame Kladno

- Channel ID: `6be97a91-c55a-44b6-a32e-ceafedcfb2ae`
- Approved origins: `https://aurorakladno.cz`, `https://www.aurorakladno.cz`
- Base path: `https://ressera.com/api/v1/customer/channels/6be97a91-c55a-44b6-a32e-ceafedcfb2ae`

## Rules

- Every request needs an approved Origin. Browsers send it automatically. Server-side callers, scripts and AI agents must send `Origin: https://aurorakladno.cz` (or another approved origin) explicitly.
- No API key or login is needed. Never embed a Supabase key, staff session or any secret in a website.
- Money is an integer in minor units. For CZK, divide by 100 (19900 means 199 Kč).
- `amounts.serviceTotal` = `voucherTender` + `dueNow` + `dueLater`. A nonzero `dueNow` does not mean money was collected.
- Show all times in `catalog.timezone`.
- Responses are `Cache-Control: no-store`. Do not cache quotes. A quote expires 15 minutes after `issuedAt`.
- Treat the API as the source of truth for prices. Never calculate prices in the browser.

## Steps

1. `GET /catalog`: pick a `standard` offering and keep `version`.
2. `GET /starts`: list start times for a date range of at most 31 days.
3. `POST /quotes`: send the selection with a fresh `Idempotency-Key` and show the returned price.

## Endpoints

### GET /api/v1/customer/channels/{channelId}/catalog

What the venue sells through this channel.

- Returns `version` (UUID), `venueName`, `locale`, `timezone` (IANA, e.g. Europe/Prague), `currency` (ISO 4217) and `offerings[]`.
- Each offering has `id`, `name`, `type` (`standard` | `package` | `duration`), `minPlayers` and `maxPlayers`.
- Only `standard` offerings can be quoted today. Skip other types.
- Keep `version`; every quote must send it back as `catalogVersion`.

### GET /api/v1/customer/channels/{channelId}/starts?offeringId={id}&from=YYYY-MM-DD&through=YYYY-MM-DD

Bookable start times for one offering.

- `from` is required. `through` is inclusive and defaults to `from`. Ask for at most 31 dates per request.
- Dates are calendar days in `catalog.timezone`, not in the visitor device zone.
- Each item has `start` (ISO 8601 instant) and `confirmation`: `instant` (confirmed on booking) or `request` (venue confirms manually).
- Starts reflect published opening hours and advance-booking rules. Live occupancy is only checked when a booking is placed.

### POST /api/v1/customer/channels/{channelId}/quotes

Server-calculated price for a selection. Valid for 15 minutes.

- Headers: `Content-Type: application/json` and `Idempotency-Key: <fresh UUID>`. Body at most 16 KiB.
- Body: `catalogVersion`, `offeringId`, `playerCount` (within the offering range) and `startTimes` (1–48 unique, chronological, future instants taken from /starts).
- Do not send `durationMinutes`, `addOns` or `voucherCode` yet. They are reserved for later releases. Unknown fields are rejected.
- Returns `id`, `issuedAt`, `expiresAt`, `currency`, `amounts` and `visit[]` (each with `kind`, `start` and `end`).
- A quote does not reserve capacity, create a booking or take payment.

## Examples

### Catalog

```bash
curl -s "https://ressera.com/api/v1/customer/channels/6be97a91-c55a-44b6-a32e-ceafedcfb2ae/catalog" \
  -H "Origin: https://aurorakladno.cz"
```

```json
{
  "channelId": "6be97a91-c55a-44b6-a32e-ceafedcfb2ae",
  "version": "0b7c…",
  "venueName": "Aurora Lasergame Kladno",
  "locale": "cs-CZ",
  "timezone": "Europe/Prague",
  "currency": "CZK",
  "offerings": [
    { "id": "5f1e…", "name": "Regular game", "type": "standard",
      "minPlayers": 1, "maxPlayers": 20 }
  ]
}
```

### Starts

```bash
curl -s "https://ressera.com/api/v1/customer/channels/6be97a91-c55a-44b6-a32e-ceafedcfb2ae/starts?offeringId=<OFFERING_ID>&from=2026-12-05&through=2026-12-06" \
  -H "Origin: https://aurorakladno.cz"
```

```json
{
  "channelId": "6be97a91-c55a-44b6-a32e-ceafedcfb2ae",
  "catalogVersion": "0b7c…",
  "offeringId": "5f1e…",
  "from": "2026-12-05",
  "through": "2026-12-06",
  "starts": [
    { "start": "2026-12-05T09:00:00.000Z", "confirmation": "instant" },
    { "start": "2026-12-05T09:20:00.000Z", "confirmation": "request" }
  ]
}
```

### Quote

```bash
curl -s -X POST "https://ressera.com/api/v1/customer/channels/6be97a91-c55a-44b6-a32e-ceafedcfb2ae/quotes" \
  -H "Origin: https://aurorakladno.cz" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "catalogVersion": "<CATALOG_VERSION>",
    "offeringId": "<OFFERING_ID>",
    "playerCount": 8,
    "startTimes": ["2026-12-05T15:00:00+01:00"]
  }'
```

```json
{
  "id": "c3a9…",
  "channelId": "6be97a91-c55a-44b6-a32e-ceafedcfb2ae",
  "catalogVersion": "0b7c…",
  "offeringId": "5f1e…",
  "issuedAt": "2026-11-28T10:00:00.000Z",
  "expiresAt": "2026-11-28T10:15:00.000Z",
  "currency": "CZK",
  "amounts": { "serviceTotal": 159200, "voucherTender": 0,
               "dueNow": 0, "dueLater": 159200 },
  "visit": [ { "kind": "game", "start": "2026-12-05T14:00:00.000Z",
               "end": "2026-12-05T14:20:00.000Z" } ]
}
```

### Browser (served from an approved origin)

```js
const API = 'https://ressera.com/api/v1/customer/channels/6be97a91-c55a-44b6-a32e-ceafedcfb2ae'

const catalog = await (await fetch(`${API}/catalog`)).json()
const game = catalog.offerings.find((o) => o.type === 'standard')

const day = '2026-12-05' // a date in catalog.timezone
const { starts } = await (await fetch(
  `${API}/starts?offeringId=${game.id}&from=${day}&through=${day}`
)).json()

const key = crypto.randomUUID() // keep it for retries of this exact request
const res = await fetch(`${API}/quotes`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'Idempotency-Key': key },
  body: JSON.stringify({
    catalogVersion: catalog.version,
    offeringId: game.id,
    playerCount: Math.max(8, game.minPlayers),
    startTimes: [starts[0].start],
  }),
})
const quote = await res.json() // on error: { code: '...' }
const price = new Intl.NumberFormat(catalog.locale, {
  style: 'currency', currency: quote.currency,
}).format(quote.amounts.serviceTotal / 100)
```

Sample IDs ending in "…" are shortened. Always use real values from your own responses.

## Errors

Every error body has the form `{ "code": "<code>" }`.

| HTTP | code | What to do |
|---|---|---|
| 400 | `invalid_request` | Fix the input, media type or Idempotency-Key. Do not retry unchanged. |
| 403 | `origin_denied` | Stop. Your Origin is not approved for this channel. Ask the venue to add it. |
| 404 | `channel_unavailable` | Stop. Check the channel ID and that you sent an approved Origin header. A missing Origin also returns this code. |
| 409 | `stale_catalog` | The venue published a change. Reload the catalog and starts, then quote again. |
| 409 | `idempotency_conflict` | This key was used for a different request. Send a fresh UUID. |
| 422 | `offering_unavailable` | This offering cannot be quoted. Offer another. |
| 422 | `unavailable_start` | The start time is past, unpublished or overlaps another. Reload starts. |
| 422 | `invalid_voucher` | Vouchers are not accepted on this API yet. Remove voucherCode. |
| 429 | `rate_limited` | Back off and retry later. The limit is about 120 new quotes per channel per minute. |
| 503 | `temporarily_unavailable` | Retry with the same body and the same Idempotency-Key, with backoff. Never show a price. |

A blocked browser request (403) may show only a CORS error in the console.

## Retries and idempotency

- Make a new UUID for each distinct quote request.
- After a timeout, network failure or 503, resend the identical body with the same key. You get the original quote back; its expiry is not extended.
- If the player count, start or offering changes, use a new key. Reusing a key for different input returns `idempotency_conflict`.

## Not available yet

Bookings, payments, vouchers, add-ons, packages, duration products and customer accounts are not available through this API. Do not invent endpoints for them. Use only the three endpoints above.

## Schema

The full JSON Schema for every request and response is at https://ressera.com/api/v1/customer/openapi
