Keys and authentication

Every request carries a key that belongs to one property. Publishable keys read from the browser; secret keys do everything else from your server.

Two kinds of key#

Key types
TypePrefixLives inScopes
Secrettulo_sk_Your website's server onlyread, bookings.read, bookings.write
Publishabletulo_pub_The visitor's browser, bound to your originsread

A key identifies its property, so no URL carries a property id. Tulo stores keys hashed and shows the full key once, when it is created. Store a secret key like a password.

New secret keys start tulo_sk_ (from 1.4.1). tulo_pk_ is the legacy secret prefix: secret keys created before 1.4.1 keep it, keep working and are treated as secret keys everywhere. There is no need to replace them.

Sending a key#

  • Authorization: Bearer <key> or X-Api-Key: <key>, for either type. This is the recommended way, from your server and (from 1.4.1) from the browser.
  • The key query parameter, for a publishable key only, as a fallback. A secret key in a URL is refused with 401 unauthorized, whichever prefix it has.
# Secret key, from your server: either header works.
curl https://api.tulo.homes/partner/v1/place -H "Authorization: Bearer $TULO_SECRET_KEY"
curl https://api.tulo.homes/partner/v1/place -H "X-Api-Key: $TULO_SECRET_KEY"

Scopes#

Every route needs one scope. A key without it gets 403 insufficient_scope.

Scopes
ScopeRoutesKey types
readGET /place, GET /calendar, GET /quoteSecret and publishable
bookings.readGET /bookings, GET /bookings/{id}Secret
bookings.writePOST /bookings, POST /bookings/{id}/cancelSecret

Every /bookings route also needs a signed request: see Signing requests. GET /signing-keys needs no key.

Allowed origins#

A publishable key is bound to a list of exact https origins (at most 10), such as https://hotel.example and https://www.hotel.example: scheme and host, no path, no wildcard. Its requests must carry one of those origins in the Origin header, which the browser sends for you. The response then allows exactly that origin (Access-Control-Allow-Origin).

CORS on the website API (from 1.4.1)
RequestAnswer
Preflight to /place, /calendar, /quote from an https origin204, that origin allowed, GET, headers Authorization, X-Api-Key, Content-Type, Idempotency-Key, cached 10 minutes
Preflight to /bookings or any other routeNo CORS headers: the browser stops there
Actual request with a publishable key from one of its originsThe answer, with that origin allowed
Actual request from any other origin, or none403 origin_not_allowed, no CORS header
  • A publishable key from any other origin, or with no Origin at all (from a server or curl without one), is refused with 403 origin_not_allowed.
  • A secret key sent with an Origin header, which means from a browser, is refused with 403 secret_key_in_browser. A secret key never belongs in front-end code.

Getting keys#

A manager or the owner of the property creates keys in the Tulo console under Settings, then API keys (front desk accounts never see keys). They name each key (for example "Main website") and pick its type: Secret, for your server, or Publishable, for your website's browser pages, with its allowed origins. The full key is shown once. The key list shows each key's type, origins and when it was created and last used.

The same screen registers your server's signing public key (see Registering a key) and shows where Tulo sends webhooks and Tulo's webhook signing keys. These console screens are available from 1.4.1; until then, and whenever the property prefers, Tulo issues keys and registers signing keys on the property's behalf: ask at support@mail.tulo.homes or WhatsApp +260 77 235 2417. A key may also carry an expiry date.

Rotating and revoking#

A revoked or expired key answers 401 unauthorized straight away. To rotate a secret key without downtime:

  1. 1.Create a new key next to the old one.
  2. 2.Deploy your server with the new key.
  3. 3.Revoke the old key in the console (Settings, then API keys, then Revoke).

Bookings are tied to the property, not to one key: every secret key of a property acts as the same website, so bookings made with a revoked key stay readable and cancellable with the new one. Rotating a signing key works the same way; see Registering a key.

Questions? Email support@mail.tulo.homes or WhatsApp +260 77 235 2417.