# Security

What may go in your HTML, what never may, and what to do if a key is abused.

## A key in a static page: is that safe?

Yes. The publishable key (`cal_pk_live_…`) is **public by nature**, like Stripe's publishable key or a Google Maps key. Anyone can read it in the page source; that has been accounted for.

What a publishable key **can** do: exactly what an anonymous visitor can do with the Callyndar widget.

- read the venue, services, staff members, open days and free times;
- hold a time, start a deposit and make a booking.

What it **cannot** do:

- read guest details or customer lists;
- retrieve, change or cancel bookings (the guest does that through the link in their email);
- reach another venue (the key determines the venue);
- bypass a deposit, or manipulate price, duration or staff member (the server takes those from the database).

## Layers of defense (all server-side)

1. **One venue per key.** Guessing venue IDs is pointless.
2. **Domain list.** Another website cannot use your key in the browser of its visitors (`403 forbidden_origin`). Origin is not a password (a script outside the browser can forge it); hence the following layers. One exception: Callyndar's own origin is accepted for every key, so **Try it** in these docs works; that is not another website.
3. **All rules enforced again on the server**: opening hours, blocks, holidays, capacity, service rules and deposits, on every hold and every booking.
4. **Limits** per key and per visitor IP, across all servers, plus a maximum number of simultaneous holds.
5. **Bots**: your own captcha or Turnstile on the form (your responsibility as the site builder), and optionally per key Callyndar's Turnstile on booking and paying.
6. **Revoking takes effect immediately**: a revoked key returns `401` on the next call.

## What may go in your HTML/JS

- The publishable key `cal_pk_live_…`.
- The Turnstile site key (if the key asks for it) and the Stripe publishable key from the API responses.
- The site key of your own captcha or Turnstile (its secret key belongs on your own server, never in the HTML).

## What never goes in

- No other keys or secrets (no Stripe secret key, no passwords, no tokens from other services).
- Don't store guest details in `localStorage`, cookies or your own database. The guest fills them in, you send them to the API once, done. Only the `session_id` may go in `sessionStorage`.
- Don't store or log a payment's `client_secret`.
- Don't put API data into the page with `innerHTML`: use `textContent` (service names come from the venue, not from you).
- Don't send guest details or request bodies to analytics or error-logging tools.

## Maintaining the domain list

- Put only the site's own domains on the key, with `https://`.
- Use `https://*.domein.be` only if you really have multiple subdomains.
- Turn off "Allow localhost" (*Localhost toestaan*) as soon as the site is live.

## Abuse? Rotate the key

If you see bookings with source "API" in the calendar that don't belong there, or the owner reports spam:

1. Go to `/integrations` → **API & own website** (*API & eigen website*) → **Rotate** (*Roteren*).
2. Put the new key in the site and publish.
3. Revoke the old key (or let it expire by itself after 24 hours).

"Last used" and "last origin" on the card show whether the key is still being used anywhere.

## Privacy (GDPR)

The venue is the data controller, Callyndar is the processor. If you build the site on behalf of the venue, you also work on its behalf. Always show the privacy and terms links (`privacy_url`, `terms_url`) next to the booking button.
