> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eat-now.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting a PMS

> What EatNow needs from a hotel property management system: capabilities, errors, events, and how a hotel connects from the PMS's catalogue.

A restaurant or a spa inside a hotel can connect the hotel's PMS to EatNow (see
the [guide for venues](https://docs.eat-now.io/pms/overview.md)). Nothing in EatNow is reserved to one
PMS: each PMS is an **adapter** behind a neutral port, and only what it can do
is used. NowOS Stay is the first adapter.

## Capabilities

| Capability | Required | What EatNow does with it |
| - | - | - |
| Stay directory | Yes | Lists outlets, searches in-house stays, reads one stay. |
| Posting | Yes | Posts a charge once, finds it by its key, reads what remains. |
| Posting reversal | Yes | Reverses all of a charge, or part of a line. |
| Expected stays | No | Finds a stay before its arrival, by reference and day. |
| Booking mirror | No | Shows the venue's bookings on the stay. |
| Webhook subscription | No | Declares its webhooks. Without it, the venue pastes the URL. |
| Managed connection | No | Reads what the hotel gave the key, and withdraws it. |

## Errors

EatNow classifies a failure on the PMS's own answer, never on the HTTP status.
A problem says whether the same request may succeed later (`retryable`) and
carries a stable `code`.

* **Retryable, or no answer:** the outcome is unknown. EatNow replays the same
  key and the same bytes, after looking the charge up by its key.
* **Anything else is final:** the line goes back as it was. No refusal leaves a
  charge in flight.

An invalid key is how EatNow learns of a disconnection.

## Events

Events are thin: they say what to read again, and arrive unordered. EatNow
rereads the stay or the charge, keeps the greatest `version`, and decides from
what it reads. A stay carries no contact: a name while in house, a reference
before.

## From the PMS's catalogue

A hotel connects from the PMS. EatNow is the authorization server: each PMS is
registered there as an OAuth client, by EatNow, with its `client_id`, its
`client_secret` and its exact return URI.

1. The PMS sends the browser to `/api/auth/oauth2/authorize` with
   `response_type=code`, `client_id`, `redirect_uri`, `state`, `code_challenge`
   and `code_challenge_method=S256`.
2. The hotel signs in and ticks its venues.
3. The PMS exchanges the code at `/api/auth/oauth2/token`, form-encoded, with
   `client_id`, `client_secret` and `code_verifier`.
4. `GET /api/integrations/pms/places`, with that token, lists what it opens:
   `{ account: { name }, places: [{ id, label, kind, currency }] }`.
5. `POST /api/integrations/pms/connections`, with that token, hands a key over:
   `{ placeId, apiUrl, propertyId, outletId, apiKey }`, answered
   `{ connectionId }`.

`apiUrl` must be on the client's registered origin. A handover replaces: the
same place keeps its connection and its id, even after an accepted handover
whose answer was lost. `403` covers a place outside the authorization and a
place already connected elsewhere, without saying which. EatNow then reads the
key's scopes and declares its webhooks with the key, for those scopes only. The
token is not kept.

## Connecting by hand

A PMS without a catalogue is connected from **Settings → Integrations** with its
address, a property id, a key and a webhook secret.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.