Keys
Every call carries a key in the X-Api-Key header. A key belongs to one club and has a label
(site, agent, ...) chosen when it is issued; the label only groups the usage records.
Publishable keys
Prefix lb_pk_. For web pages.
- Accepted only when the request's
Originheader is on the key's allowlist. The browser setsOriginitself and a page cannot change it, which is what makes the key safe to publish in your page. - An origin is a scheme, host and port, for example
https://www.example-bowls.org. A page onhttps://example-bowls.org(nowww) is a different origin and needs its own entry. - Tell lovebowls every origin you need, including a staging site. Local development on
http://localhost:3000is an origin too. - A request with no
Originheader (curl, a server) is not accepted with a publishable key.
Server keys
Prefix lb_sk_. For servers, scripts and AI agents. The key has the same rights as a publishable one but
no origin check, so it must stay secret.
- Keep it in an environment variable or your host's secret store. Never in source control, a web page, a mobile app or a chat.
- A server key is refused if it arrives with an
Originheader (403 server_key_in_browser). Browsers send one on a cross-site call, so this catches the mistake early. If you see that error, the key is already exposed to whoever can read that page: ask for it to be rotated. - Calls from a server do not send
Origin, so the SDK and curl work as normal there.
Rotation
Ask lovebowls to rotate a key whenever it may have leaked, when someone who knew it leaves, or on a schedule
you set. Rotation issues a new key and revokes the old one at once, so deploy the new key straight away.
A revoked key answers 401 api_key_invalid, the same as a key that never existed.
What the answers mean
| Status | code | Meaning and what to do |
|---|---|---|
| 401 | api_key_missing | No X-Api-Key header. Send one. |
| 401 | api_key_invalid | Not a lovebowls key, unknown, or revoked. Check for a copy and paste slip, then ask for a new key. |
| 403 | origin_not_allowed | A publishable key from an origin that is not on its list. Ask for the origin to be added. |
| 403 | server_key_in_browser | A server key sent with an Origin header. Move the call to a server, use a publishable key in the browser, and rotate the server key. |
| 403 | club_mismatch | The {clubId} in the path is not the key's club. Use the id of the club the key was issued for. |
| 403 | feature_not_in_plan | The operation's group is switched off for the club. Not used today, but handle it. |
Cross-origin calls (CORS)
The API answers the browser's preflight request itself, and allows only the origins on the calling key's list. If a browser reports a CORS failure, the cause is almost always the origin list or a wrong key.