Authentication

One header, `x-api-key`, for both APIs.

3 min read

One header, on every request: x-api-key. There is no login step and no token to refresh. A key can still stop working: when it is revoked, when it reaches a validity date set when it was issued, or — for a key that answers in plain JSON — when that scheme is retired.

API keys

A key is issued for one property: by one of its admins in the PMS, or — for a partner — when the property activates the partner’s integration in its Marketplace. A key may be limited to the endpoints chosen when it was issued. That is why a call can fail with 403 on a key that reads bookings perfectly well: the key is fine, but it was not granted that endpoint, and the 403 names it. A property’s own key also answers 403 when the property has no active API subscription.

Never ship a key to a browser

An API key can read and write a property. It belongs on your server or in a secret store — never in front-end code, a mobile bundle, or a repository. If one leaks, revoke it and issue another. Limit what a leaked key can do by granting only the endpoints you use; an encrypted key is useless without its private key, which lives on your server too.

When it fails

json
1{
2 "message": "Invalid ApiKey",
3 "error": "Unauthorized",
4 "statusCode": 401
5}
Invalid ApiKey covers an unknown key and a key that belongs to a different property than the pcode in the path — check the pcode first, it is the usual one. Without the header at all, the message is No valid API key or JWT token provided. A key past its date, a retired plain-JSON key, and a partner connection that is paused or suspended each answer 401 with a message of their own that says so.