@zimmerstack/connect 0.7.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/AGENTS.md +305 -25
  2. package/README.md +572 -56
  3. package/dist/cjs/client.d.ts +528 -13
  4. package/dist/cjs/client.js +778 -46
  5. package/dist/cjs/doctor.d.ts +86 -0
  6. package/dist/cjs/doctor.js +689 -0
  7. package/dist/cjs/errors.d.ts +6 -2
  8. package/dist/cjs/errors.js +7 -2
  9. package/dist/cjs/generated.d.ts +2873 -203
  10. package/dist/cjs/generated.js +222 -8
  11. package/dist/cjs/grid.d.ts +6 -1
  12. package/dist/cjs/grid.js +8 -0
  13. package/dist/cjs/index.d.ts +14 -5
  14. package/dist/cjs/index.js +41 -1
  15. package/dist/cjs/key.d.ts +39 -0
  16. package/dist/cjs/key.js +85 -0
  17. package/dist/cjs/money.d.ts +81 -0
  18. package/dist/cjs/money.js +172 -0
  19. package/dist/cjs/notices.d.ts +44 -0
  20. package/dist/cjs/notices.js +64 -0
  21. package/dist/cjs/shownOnce.d.ts +42 -0
  22. package/dist/cjs/shownOnce.js +83 -0
  23. package/dist/cjs/webhooks.d.ts +182 -3
  24. package/dist/cjs/webhooks.js +75 -1
  25. package/dist/esm/client.d.ts +528 -13
  26. package/dist/esm/client.js +776 -46
  27. package/dist/esm/doctor.d.ts +86 -0
  28. package/dist/esm/doctor.js +685 -0
  29. package/dist/esm/errors.d.ts +6 -2
  30. package/dist/esm/errors.js +7 -2
  31. package/dist/esm/generated.d.ts +2873 -203
  32. package/dist/esm/generated.js +221 -7
  33. package/dist/esm/grid.d.ts +6 -1
  34. package/dist/esm/grid.js +7 -0
  35. package/dist/esm/index.d.ts +14 -5
  36. package/dist/esm/index.js +8 -3
  37. package/dist/esm/key.d.ts +39 -0
  38. package/dist/esm/key.js +81 -0
  39. package/dist/esm/mcp/cli.js +95 -11
  40. package/dist/esm/mcp/reference.generated.js +5741 -1008
  41. package/dist/esm/mcp/server.d.ts +14 -6
  42. package/dist/esm/mcp/server.js +451 -25
  43. package/dist/esm/money.d.ts +81 -0
  44. package/dist/esm/money.js +161 -0
  45. package/dist/esm/notices.d.ts +44 -0
  46. package/dist/esm/notices.js +56 -0
  47. package/dist/esm/shownOnce.d.ts +42 -0
  48. package/dist/esm/shownOnce.js +77 -0
  49. package/dist/esm/webhooks.d.ts +182 -3
  50. package/dist/esm/webhooks.js +69 -0
  51. package/package.json +2 -2
package/README.md CHANGED
@@ -4,30 +4,39 @@ Add a channel manager to your hotel software. This package sends a hotel's rooms
4
4
  Booking.com, Airbnb, Expedia, Agoda, MakeMyTrip and the other booking sites, and brings their bookings
5
5
  back to you.
6
6
 
7
- - **Free to build.** You get a practice hotel the moment you sign up. Nothing you do there reaches a
8
- real booking site.
7
+ - **Free to build.** You get a sandbox with a practice hotel the moment you sign up, and your software
8
+ can create more. Nothing you do there reaches a real booking site.
9
9
  - **Public prices.** A fixed price for each live property a month, on one invoice. A partner in India
10
10
  pays the price plus GST. A partner outside India pays its own price, with nothing added. You accept
11
11
  it in the partner portal. Going live has a one-time onboarding fee of $50, paid once in the portal
12
- before your live key. No call needed: <https://docs.zimmerstack.com/pricing>
12
+ before your live key. The price list: <https://docs.zimmerstack.com/pricing>
13
13
  - **Made for AI coding tools.** The package carries its own rules file and a helper your coding agent
14
14
  can ask. See [For AI coding agents](#for-ai-coding-agents).
15
15
 
16
- [Docs](https://docs.zimmerstack.com) · [Quickstart](https://docs.zimmerstack.com/quickstart) ·
16
+ [Docs](https://docs.zimmerstack.com) · [Quickstart](https://docs.zimmerstack.com/partner/first-call) ·
17
17
  [Pricing](https://docs.zimmerstack.com/pricing) · [Partner portal](https://partner.zimmerstack.com/login) ·
18
18
  [Starter app](https://github.com/zimmerstack/connect-starter) ·
19
19
  [Source](https://github.com/zimmerstack/connect-node) ·
20
20
  [Changelog](https://docs.zimmerstack.com/changelog) · <support@zimmerstack.com>
21
21
 
22
- ## Start in five minutes
22
+ ## Start here
23
+
24
+ You learn the API in the order a hotel is made: the hotel, its room types, its rate plans, then its
25
+ rooms and prices. All of it happens in your sandbox, with a test key. Nothing reaches a real booking
26
+ site and nothing is billed.
23
27
 
24
28
  **1. Sign up.** It is free and takes one emailed code:
25
- <https://www.zimmerstack.com/partners/pms-companies#join>. Your practice hotel is made for you. We call
26
- it a sandbox. Working for one hotel only? Its owner makes your key in Admin → Developers → API keys, and
27
- you can skip to step 3.
29
+ <https://www.zimmerstack.com/partners/pms-companies#join>. You get a sandbox: the place where your test
30
+ hotels live. A test hotel is a practice hotel that no booking site ever sees. One example test hotel is
31
+ made for you. Working for one hotel only? Its owner makes your key in Admin → Developers → API keys.
32
+ You join at step 3 and skip step 6, because your hotel is already there. Where a later step says
33
+ `hotel`, use `zs`.
28
34
 
29
35
  **2. Make a test key.** Open the [partner portal](https://partner.zimmerstack.com/login), then
30
- Developers, then Create key. A test key starts with `zsk_test_`. It works on your practice hotel only.
36
+ Developers, then **Create company key**. Under **Reaches**, choose **Your sandbox (zsk_test_)**. Keep
37
+ **Also add and remove hotels** ticked, then press **Create company key**. The key starts with
38
+ `zsk_test_` and is shown once, so copy it now. It is one key for all your test hotels, so each call
39
+ says which hotel it is for.
31
40
 
32
41
  **3. Install the package.** It needs Node 20 or newer.
33
42
 
@@ -42,22 +51,85 @@ npm install @zimmerstack/connect
42
51
  ZIMMERSTACK_CONNECT_KEY=zsk_test_…
43
52
  ```
44
53
 
45
- **5. Make your first call.**
54
+ **5. Make your first call.** Ask which hotels your key reaches.
46
55
 
47
56
  ```ts
48
57
  import { ZimmerStack } from "@zimmerstack/connect";
49
58
 
50
59
  const zs = new ZimmerStack(); // reads ZIMMERSTACK_CONNECT_KEY. Make one and reuse it.
51
60
 
52
- // Which hotel is this?
53
- const hotel = await zs.property.get();
54
- console.log(hotel.name, hotel.currency, hotel.timezone);
61
+ const { properties } = await zs.properties.list();
62
+ for (const p of properties) console.log(p.id, p.name, p.currency, p.sandbox);
63
+ ```
55
64
 
56
- // The rate calendar for two weeks: rooms down the side, nights across the top.
57
- const grid = await zs.grid.load("2026-12-01", "2026-12-14");
58
- console.log(grid.rows.length, "room types");
65
+ The list holds the example test hotel from step 1. Next, your software makes a hotel itself.
66
+
67
+ **6. Create a hotel.** With a test key, this call makes a hotel in your sandbox. With a live key, the same call adds a real hotel. The request is
68
+ checked exactly as for a real hotel, but nobody is emailed and nothing is billed. You can hold up to
69
+ five test hotels at one time, the example included.
70
+
71
+ ```ts
72
+ const made = await zs.properties.create({
73
+ name: "The Lantern House",
74
+ owner: { name: "Asha Rao", email: "asha@lanternhouse.example", phone: "+91 98765 43210" },
75
+ address: { line1: "14 Hill Road", city: "Shimla", country: "IN" },
76
+ roomTypes: [{ ref: "rt-deluxe", name: "Deluxe Room", roomCount: 10, defaultRate: 4500 }],
77
+ });
78
+
79
+ const hotel = zs.forProperty(made.id); // the same client, working on this hotel
80
+ ```
81
+
82
+ The request needs at least one room type. So the hotel is born with its first room type, and with one
83
+ room-only rate plan for it at `defaultRate`: 4500 means 4,500.00 in the hotel's own currency.
84
+
85
+ **7. Create room types.** A room type is a kind of room the hotel sells. This hotel has the Deluxe Room
86
+ already, so add a second one. `ref` is your own id for it.
87
+
88
+ ```ts
89
+ const suite = await hotel.roomTypes.save({ ref: "rt-suite", name: "Suite", roomCount: 2, adults: 3 });
90
+ suite.id; // ZimmerStack's id for it: name it when you set the rooms left to sell
91
+ ```
92
+
93
+ **8. Create rate plans.** A rate plan is one way to sell a room type. Prices belong to rate plans. Add
94
+ breakfast to the Deluxe Room, and give the Suite its first rate plan.
95
+
96
+ ```ts
97
+ const breakfast = await hotel.ratePlans.save({ ref: "rp-bb", roomTypeRef: "rt-deluxe", name: "Bed and breakfast", mealPlan: "CP", defaultRate: 5000 });
98
+ await hotel.ratePlans.save({ ref: "rp-suite", roomTypeRef: "rt-suite", name: "Room only", mealPlan: "EP", defaultRate: 9000 });
99
+ breakfast.id; // name it when you set prices and stay rules
100
+ ```
101
+
102
+ **9. Send availability and rates.** Availability is the rooms left to sell on each night. A rate is the
103
+ price of one rate plan on each night. Send both for three nights.
104
+
105
+ ```ts
106
+ // Rooms left to sell name a room type's id. The Deluxe Room was born with the hotel, so read its id.
107
+ const deluxe = (await hotel.roomTypes.list()).find((room) => room.ref === "rt-deluxe")!;
108
+ await hotel.availability.set([{ roomTypeId: deluxe.id, dateFrom: "2026-12-24", dateTo: "2026-12-26", available: 3 }]);
109
+
110
+ // Prices name a rate plan's id.
111
+ const accepted = await hotel.rates.set([{ ratePlanId: breakfast.id, dateFrom: "2026-12-24", dateTo: "2026-12-26", rate: 5500 }]);
112
+
113
+ // Accepted means ZimmerStack has saved it. On a test hotel a change lands within a minute and stops there.
114
+ const batch = await hotel.batches.wait(accepted[0]!.batchId);
115
+ console.log(batch.status); // "landed"
59
116
  ```
60
117
 
118
+ Each step has its own page in the docs, with every field explained:
119
+ [get a test key](https://docs.zimmerstack.com/partner/test-key) ·
120
+ [make your first call](https://docs.zimmerstack.com/partner/first-call) ·
121
+ [create a hotel](https://docs.zimmerstack.com/partner/create-hotel) ·
122
+ [create room types](https://docs.zimmerstack.com/partner/room-types) ·
123
+ [create rate plans](https://docs.zimmerstack.com/partner/rate-plans) ·
124
+ [send availability and rates](https://docs.zimmerstack.com/partner/send-availability-and-rates).
125
+
126
+ **Next: receive a booking, then go live.** Your test hotel can now take a test booking.
127
+ [Receive a booking](https://docs.zimmerstack.com/partner/receive-booking) shows how to add your webhook
128
+ address and pretend a booking came in; the short version is in [Receive bookings](#receive-bookings)
129
+ below. Then [accept the price](https://docs.zimmerstack.com/partner/price) and
130
+ [add your first hotel](https://docs.zimmerstack.com/partner/first-hotel) with a live key. The calls
131
+ stay the same: with a live key they work on real hotels.
132
+
61
133
  Want a working app to start from? The [starter app](https://github.com/zimmerstack/connect-starter) has
62
134
  a one-click Deploy button.
63
135
 
@@ -70,7 +142,7 @@ calls ZimmerStack.
70
142
  - Never put the key in a `VITE_`, `NEXT_PUBLIC_`, `REACT_APP_` or `EXPO_PUBLIC_` variable. Those are
71
143
  sent to every visitor's browser.
72
144
  - Your app has no server (a Vite, Lovable or Bolt page)? The docs show the smallest one:
73
- <https://docs.zimmerstack.com/sdk#no-server>
145
+ <https://docs.zimmerstack.com/guides/node-package#no-server>
74
146
 
75
147
  ## What you can do
76
148
 
@@ -82,26 +154,73 @@ calls ZimmerStack.
82
154
  | Save what a person changed in it | `zs.grid.save(edits)` |
83
155
  | Set the rooms left to sell | `zs.availability.set(updates)` |
84
156
  | Set prices | `zs.rates.set(updates)` |
85
- | Close a night, or ask for a minimum stay | `zs.restrictions.set(updates)` |
157
+ | Stop selling one rate plan on a night, or ask for a minimum stay | `zs.restrictions.set(updates)` |
158
+ | Close a room type on some nights, everywhere, and keep it closed | `zs.availability.close({ roomTypeId, dateFrom, dateTo })` · `zs.availability.reopen(body)` |
159
+ | See what a change would do before I send it | `zs.rates.dryRun(updates)` · `zs.availability.dryRun(updates)` · `zs.restrictions.dryRun(updates)` |
160
+ | Read what a change did not do | `noticesOf(accepted)` |
161
+ | Find out why a night is not selling as I sent it | `zs.explain.night({ roomTypeId, date })` |
86
162
  | List a hotel's room types and rate plans | `zs.roomTypes.list()` · `zs.ratePlans.list()` |
87
163
  | Create or change a room type or a rate plan | `zs.roomTypes.save(roomType)` · `zs.ratePlans.save(ratePlan)` |
88
164
  | Delete a room type or a rate plan | `zs.roomTypes.delete(idOrRef)` · `zs.ratePlans.delete(idOrRef)` |
89
165
  | Charge a different price on one booking site | `zs.channels.setModifier(channelId, steps)` |
90
166
  | Read the bookings the booking sites sent | `zs.channelBookings.list()`, or a webhook |
167
+ | Read every booking and channel event, in order, from where I stopped | `zs.events.all({ after })` |
91
168
  | Read the bookings made on the hotel's own website | `zs.directBookings.list()` |
92
169
  | Pretend a booking came in (practice hotel only) | `zs.sandbox.bookings.create(booking)` |
170
+ | Pretend a no-show, or a channel problem (practice hotel only) | `zs.sandbox.bookings.noShow(bookingId)` · `zs.sandbox.syncEvents.create(body)` |
171
+ | Make the practice hotel's booking site refuse a price, or go down | `zs.sandbox.faults.set(body)` · `zs.sandbox.faults.clear()` |
172
+ | Create and manage my webhook addresses from code | `zs.webhookEndpoints.create(body)` and the rest |
173
+ | See how much of each limit is left | `zs.limits.get()` |
174
+ | See which of my calls were refused, and from which address they came | `zs.requests.list({ status: "errors" })` |
175
+ | Find out what is wrong | `npx @zimmerstack/connect doctor` |
93
176
  | Check that a change reached the booking sites | `zs.batches.wait(batchId)` · `zs.sync.get()` |
94
177
  | Create a booking from your own booking engine | `zs.bookings.create(booking)` |
95
178
  | Work with many hotels on one key | `zs.forProperty(propertyId)` |
96
179
  | Add a hotel | `zs.properties.create(hotel)` |
180
+ | Change a hotel | `zs.properties.update(propertyId, changes)` |
97
181
  | Remove a hotel I added | `zs.properties.delete(propertyId, { confirm })` |
182
+ | Let a hotel connect a booking site itself | `zs.connectLinks.create({ propertyId, channel })` |
183
+ | Check that a hotel is ready, and make my software its source of truth | `zs.readiness.get()` · `zs.readiness.goLive()` |
184
+ | Make, replace and revoke the keys I made on a hotel | `zs.hotelKeys.create(propertyId, body)` · `zs.hotelKeys.rotate(propertyId, keyId)` · `zs.hotelKeys.revoke(propertyId, keyId, { reason })` |
185
+ | Read my bills and how many hotels I may still add | `zs.billing.get()` · `zs.billing.invoices()` · `zs.billing.nextInvoice()` |
186
+ | Open a support ticket and read the answer | `zs.supportTickets.create(body)` · `zs.supportTickets.get(ticketId)` |
187
+ | See whether something is wrong on ZimmerStack's side | `zs.status.get()` |
98
188
 
99
189
  Every call and every answer is typed, with the meaning of each field shown in your editor.
100
190
 
101
- **Money.** You send a price as a normal number: `4500` means 4,500.00 in the hotel's own currency. When
102
- you read prices one by one with `zs.rates.get()`, they come back in the smallest unit (`rateMinor`:
103
- `450000` is 4,500.00). The calendar helpers `zs.grid.load()` and `zs.grid.save()` always use normal
104
- numbers.
191
+ **Money.** A price goes up and comes back in the same shape: the hotel's own currency, with that
192
+ currency's own decimals. You send a normal number or a decimal string (`4500.50` or `"4500.50"`) and it
193
+ is kept exactly; `zs.rates.get()` returns `rate: "4500.50"` beside `currency` and `decimals`. The
194
+ calendar helpers `zs.grid.load()` and `zs.grid.save()` always use normal numbers.
195
+
196
+ | Currency | Decimals (ISO 4217) | You send | You read `rate` | `rateMinor` |
197
+ |---|---|---|---|---|
198
+ | Rupee, euro, dollar, dirham, rupiah | 2 | `4500.50` | `"4500.50"` | `450050` |
199
+ | Yen, won, dong | 0 | `15000` | `"15000"` | `1500000` |
200
+ | Kuwaiti, Bahraini, Omani, Jordanian, Tunisian, Libyan dinar | 3 | `45.75` | `"46.000"` | `4600` |
201
+
202
+ `rateMinor` is still returned, and is always hundredths of the currency's unit: that is paise or cents
203
+ where a currency has two decimals, and it is not yen (`1500000` is 15,000 yen). Read `rate` and you never
204
+ divide. A number with more decimals than the currency has (`4500.505` in rupees) is rounded and named in
205
+ the answer's `rounded` list, and so is a fraction in a currency that has none, so nothing changes
206
+ without the answer saying so. A decimal string takes at most two decimals: one with more
207
+ (`"4500.505"`) is refused with a 400 `VALIDATION` error and nothing is saved. It is never rounded for
208
+ you. A three-decimal currency is kept as a whole amount for now.
209
+
210
+ The package has helpers for money, so you never do the arithmetic on floats (from 0.9.0). They take and
211
+ return the same decimal strings, and `decimals` comes from the API's own answer:
212
+
213
+ ```ts
214
+ import { addAmounts, amountFromHundredths, amountFromMinorUnits, formatAmount, multiplyAmount, toAmount } from "@zimmerstack/connect";
215
+
216
+ const { currency, decimals } = await zs.property.get(); // "INR", 2 · "JPY", 0
217
+ toAmount(4500.5, decimals); // "4500.50": the shape the API reads and writes
218
+ multiplyAmount("4500.50", 3, decimals); // "13501.50": three nights, exact
219
+ addAmounts("0.10", "0.20", decimals); // "0.30", not 0.30000000000000004
220
+ amountFromMinorUnits(450050, decimals); // "4500.50": from a ledger that stores whole paise or cents
221
+ amountFromHundredths(1500000, 0); // "15000": from a rateMinor, in any currency
222
+ formatAmount("4500.50", { currency, decimals, locale: "en-IN" }); // "₹4,500.50", for a person to read
223
+ ```
105
224
 
106
225
  **Dates.** A date is a plain calendar day, `YYYY-MM-DD`, on the hotel's own clock.
107
226
 
@@ -116,18 +235,99 @@ const accepted = await zs.grid.save({
116
235
  { ratePlanId: 901, date: "2026-12-24", rate: 5200 },
117
236
  { ratePlanId: 901, date: "2026-12-25", rate: 5200 },
118
237
  ],
119
- restrictions: [{ ratePlanId: 901, date: "2026-12-31", stopSell: true }], // close a night. Never send a price of zero.
238
+ restrictions: [{ ratePlanId: 901, date: "2026-12-31", stopSell: true }], // stop selling this rate plan that night. Never send a price of zero.
120
239
  });
121
240
 
122
241
  // Accepted means ZimmerStack has saved it and is sending it to the booking sites.
123
- const batch = await zs.batches.wait(accepted[0]!.batchId); // "landed", or still "pending" after five minutes
242
+ const batch = await zs.batches.wait(accepted[0]!.batchId); // "landed", "failed", or still "pending" after five minutes
124
243
  ```
125
244
 
245
+ `stopSell` closes one rate plan on that night. The room type's other rate plans keep selling. To stop
246
+ selling a room type on a night on every booking site, send its room count as 0 with
247
+ `zs.availability.set()` or `grid.save({ availability })`.
248
+
249
+ **Sent is not held: read the answer.** "Accepted" means saved by ZimmerStack, not yet on the booking
250
+ sites. Three things can still happen, and each one is told to you:
251
+
252
+ - A booking site's side refuses a value. The batch then reads `failed` with `parkedCells` and
253
+ `lastError`: the value is held and not sent again. Send a corrected value for those nights.
254
+ - A write names a room type or rate plan that reaches no booking site. The batch lists it under
255
+ `unreachable`.
256
+ - A price is kept differently from how you sent it. The write's answer lists it under `rounded`.
257
+
258
+ And later, someone can change a price on a booking site's side. A check that runs every night finds it,
259
+ sends your value again and tells you: see [Receive bookings](#receive-bookings) for `channel.drift.detected`.
260
+
126
261
  Room counts usually reach the booking sites in seconds. A full calendar of prices can take minutes.
127
262
  Inside a short-lived function (Vercel, Netlify), show the `batchId` and read `zs.sync.get()` later
128
263
  instead of waiting.
129
264
 
130
- Guide: <https://docs.zimmerstack.com/rate-grid>
265
+ Guide: <https://docs.zimmerstack.com/guides/rate-grid>
266
+
267
+ ## See what a change will do, and read what it did not do
268
+
269
+ "Accepted" means ZimmerStack saved your change. It does not say the change does what you meant. Three
270
+ things do (from 0.9.0).
271
+
272
+ **1. Ask first: a dry run.** The same updates, checked exactly as the real change, and nothing is saved.
273
+
274
+ ```ts
275
+ const [preview] = await zs.restrictions.dryRun([{ ratePlanId: 901, dateFrom: "2026-12-31", dateTo: "2026-12-31", stopSell: true }]);
276
+ preview.verdict; // "would-write", "nothing-to-write", or "would-refuse" with the refusal you would get
277
+ ```
278
+
279
+ A dry run answers a `WritePreview`, and `set` answers a `WriteAccepted`: two types, so your code cannot
280
+ mistake one for the other. A dry run counts against the per-minute limits like the change it previews,
281
+ so it is not a way to read the calendar.
282
+
283
+ **2. Read the notices.** Every answer of `set`, and every dry run, can carry notices: one plain sentence
284
+ each, about what the change did **not** do, with what to do about it.
285
+
286
+ ```ts
287
+ import { findNotice, noticesOf } from "@zimmerstack/connect";
288
+
289
+ const accepted = await zs.restrictions.set([{ ratePlanId: 901, dateFrom: "2026-12-31", dateTo: "2026-12-31", stopSell: true }]);
290
+ for (const notice of noticesOf(accepted)) show(notice.level, notice.message, notice.action); // warnings first
291
+ findNotice(accepted, "ROOM_STILL_ON_SALE"); // the room still sells through its other rate plans
292
+ ```
293
+
294
+ The two that explain most surprises:
295
+
296
+ - **Stop-sell is a switch on one rate plan.** The room keeps selling through its other rate plans, and
297
+ through a rate a booking site makes on its own side (`ROOM_STILL_ON_SALE`).
298
+ - **A room count of 0 is a count, not a switch.** It closes the room everywhere, but a cancellation at a
299
+ booking site puts a room back, and your next count replaces it (`COUNT_ZERO_IS_NOT_STOP_SELL`).
300
+
301
+ A notice is never an error: the change was saved. Decide on `notice.code` (`NOTICES` lists every code),
302
+ and show `message` and `action` to the person who saved.
303
+
304
+ **3. Close a room type everywhere, in one call.** Its count goes to 0 **and** stop-sell is switched on
305
+ for every one of its rate plans, so it is closed and stays closed.
306
+
307
+ ```ts
308
+ const closed = await zs.availability.close({ roomTypeId: 412, dateFrom: "2026-12-30", dateTo: "2027-01-02" });
309
+ closed.notReached; // read this: what the close could not reach, and why
310
+ await zs.availability.reopen({ roomTypeId: 412, dateFrom: "2026-12-30", dateTo: "2027-01-02", available: 3 });
311
+ ```
312
+
313
+ `reopen` undoes exactly what `close` did. Pass `available` when your software knows how many rooms are
314
+ free now; without it each night gets back the count it held before. `closeDryRun` and `reopenDryRun`
315
+ show what each would do.
316
+
317
+ **Why is this night not selling as I sent it?** One read tells the night's whole story:
318
+
319
+ ```ts
320
+ const night = await zs.explain.night({ roomTypeId: 412, date: "2026-12-31" });
321
+ night.summary; // plain sentences, most important first: show them to the person who asked
322
+ ```
323
+
324
+ It answers what your software last sent, what ZimmerStack holds and who set it, and what the channel
325
+ manager was last seen holding, with any value it refused in its own words. It cannot see a booking
326
+ site's own screen: it reads the channel manager's copy, as last seen. "What your software last sent" is
327
+ there for changes made after this feature shipped.
328
+
329
+ Guides: <https://docs.zimmerstack.com/guides/dry-run> · <https://docs.zimmerstack.com/guides/notices> ·
330
+ <https://docs.zimmerstack.com/guides/close-and-reopen> · <https://docs.zimmerstack.com/guides/explain-one-night>
131
331
 
132
332
  ## Set up a hotel's rooms: create, change, delete
133
333
 
@@ -138,7 +338,8 @@ sell it, like "Bed and breakfast". Prices belong to rate plans.
138
338
  // `ref` is your own id for the room type.
139
339
  const room = await zs.roomTypes.save({ ref: "deluxe", name: "Deluxe Room", roomCount: 8, adults: 2 });
140
340
 
141
- // `defaultRate` is the plan's usual price: 4500 means 4,500.00.
341
+ // `defaultRate` is the plan's real price for a night: 4500 means 4,500.00. A new rate plan needs it:
342
+ // every date of the plan can be sold at this price until you send the price of each night.
142
343
  const plan = await zs.ratePlans.save({ ref: "deluxe-bb", roomTypeRef: "deluxe", name: "Bed and breakfast", mealPlan: "CP", defaultRate: 4500 });
143
344
 
144
345
  room.id; // name it when you set the rooms left to sell
@@ -159,7 +360,7 @@ await zs.roomTypes.delete("deluxe"); // its rate plans are deleted with it
159
360
  - Call a delete only when a person chose to delete that one thing. Never from a loop or a clean-up
160
361
  script.
161
362
 
162
- Guide: <https://docs.zimmerstack.com/channel-manager>
363
+ Guide: <https://docs.zimmerstack.com/reference>
163
364
 
164
365
  ## Receive bookings
165
366
 
@@ -190,9 +391,61 @@ real, signed message:
190
391
  await zs.sandbox.bookings.create({ roomTypeId: 412, checkIn: "2026-12-05", nights: 2, rooms: 1, adults: 2, guestName: "Asha Verma", otaName: "Booking.com", paidByOta: false });
191
392
  ```
192
393
 
193
- No database yet? Read the bookings back any time with `zs.channelBookings.list()`. To catch up after
194
- your server was down, `zs.channelBookings.all({ since })` gives every booking changed since a time you
195
- choose.
394
+ **The webhook is the nudge. The event log is the truth** (from 0.9.0). A webhook can arrive twice, late,
395
+ out of order, or not at all when your server is down for a day. So every event of a hotel also has a
396
+ place in one ordered list: its `sequence`, one higher than the hotel's last event. Save the last
397
+ sequence you applied, and read from there:
398
+
399
+ ```ts
400
+ // Run this when a webhook arrives, on a schedule, and when your server starts.
401
+ for await (const event of zs.events.all({ after: await loadPlace(hotelId) })) {
402
+ await apply(event); // the same shape the webhook carries
403
+ await savePlace(hotelId, event.sequence); // your new place
404
+ }
405
+ ```
406
+
407
+ Built this way, nothing depends on a webhook having arrived. Events stay in the log for 90 days. If you
408
+ were away for longer, pass `onGap` to hear of it, then read each booking's latest state with
409
+ `zs.channelBookings.all({ since })` and `zs.directBookings.all({ since })`. A booking also carries a
410
+ `version` (1, 2, 3 and so on): a higher version is a later state, whatever order things arrived in.
411
+
412
+ Besides bookings, your address can receive five more kinds of message, each only when it lists the
413
+ type. Narrow them with `isSyncEvent`, `isDriftEvent`, `isConnectEvent`, `isIncidentEvent` and
414
+ `isSupportTicketEvent`:
415
+
416
+ - `channel.sync.alert` and `channel.sync.recovered`: a problem with a booking site began (a refused
417
+ value, a disconnect, prices or room counts that stopped going out) and ended.
418
+ - `channel.drift.detected` and `channel.drift.healed`: the nightly check found a booking site's side
419
+ holding something other than what you sent, sent your value again, and later found them agreeing.
420
+ - `channel.connect.completed` and `channel.connect.expired`: a connect link you made ended. The hotel
421
+ started selling on the booking site, or the link ran out first.
422
+ - `platform.incident.opened`, `.updated` and `.resolved`: ZimmerStack recorded a problem on its own
423
+ side that touches your hotels, and later ended it.
424
+ - `support.ticket.replied` and `support.ticket.closed`: ZimmerStack answered your support ticket.
425
+
426
+ The last two kinds are about your account, not one hotel. They have **no `event.property`** and no
427
+ `sequence`, and they are not in the event log. Check `isIncidentEvent` and `isSupportTicketEvent` before
428
+ any code that reads `event.property`.
429
+
430
+ **A guest's phone and email.** A webhook carries them only while your address has guest contact
431
+ switched on. A read by API returns them until 30 days after checkout; after that they are `null` and
432
+ `guest.contactWithheld` says `"retention"`. Every read that returned contact is logged, and the hotel's
433
+ owner can see the list. Copy what you need when the booking arrives.
434
+
435
+ **Your webhook addresses, from code** (from 0.9.0). A company key with the permission `webhooks:manage`
436
+ (tick **Also manage webhooks** when you make the key) creates and looks after them without the portal:
437
+
438
+ ```ts
439
+ const { endpoint, secret } = await zs.webhookEndpoints.create({ url: "https://pms.example/zimmerstack", dataAck: true });
440
+ // `secret` is shown this once. Store it in your server's settings now.
441
+ await zs.webhookEndpoints.test(endpoint.id, { eventType: "channel.booking.created" }); // a signed sample
442
+ await zs.webhookEndpoints.pause(endpoint.id); // before planned downtime: events are held
443
+ await zs.webhookEndpoints.resume(endpoint.id); // they go out, oldest first
444
+ ```
445
+
446
+ Also there: `update` (the address, the event types, the guest-contact switch), `rotateSecret`,
447
+ `recover(id, since)`, `delete`, and `deliveries.list`, `deliveries.get` and `deliveries.redeliver` for the
448
+ delivery log.
196
449
 
197
450
  Hotels outside India (from 0.7.0): a booking carries `taxes`, the hotel's own tax lines, wherever the
198
451
  hotel has confirmed them. When a booking site sends a booking in another currency than the hotel's,
@@ -201,7 +454,7 @@ hotel `zs.bookings.create` also takes `nightlyRateIncludesTaxes`; `false` is ref
201
454
  `TAXES_NOT_CONFIGURED` where the hotel has confirmed no lines, and `TAXES_INSIDE_RATES` where all its
202
455
  taxes sit inside its prices.
203
456
 
204
- Guide: <https://docs.zimmerstack.com/webhooks>
457
+ Guide: <https://docs.zimmerstack.com/guides/webhooks>
205
458
 
206
459
  ## A different price on each booking site
207
460
 
@@ -232,7 +485,7 @@ automatically.
232
485
  One call to `zs.channels.setModifier()` moves every price on that booking site. Call it when a person
233
486
  saved the setting. Never from a loop, a timer or a set-up script.
234
487
 
235
- Guide: <https://docs.zimmerstack.com/per-ota>
488
+ Guide: <https://docs.zimmerstack.com/guides/price-per-ota>
236
489
 
237
490
  ## Many hotels on one key
238
491
 
@@ -244,11 +497,13 @@ const hotel = zs.forProperty(properties[0]!.id); // the same client, working on
244
497
  await hotel.grid.load("2026-12-01", "2026-12-14");
245
498
  ```
246
499
 
247
- - A **test** company key reaches your practice hotels. While you have only one, the package finds it by
248
- itself, so the Start example works unchanged. With several, name one.
500
+ - A **test** company key reaches all your practice hotels. While you have only one, the package finds it
501
+ by itself. With several, name one, as the Start does from step 6.
249
502
  - A **live** key never guesses. Always name the hotel.
250
503
  - An app that serves one hotel can name it once: `ZIMMERSTACK_PROPERTY_ID=61` on the server, or
251
504
  `new ZimmerStack({ propertyId: 61 })`.
505
+ - Each hotel has its own queue (from 0.8.0). One hotel that is close to its limit waits by itself; the
506
+ others keep going. What all your hotels share, your company's limit, is kept for all of them together.
252
507
 
253
508
  ## Add a hotel, remove a hotel
254
509
 
@@ -272,12 +527,22 @@ const hotel = zs.forProperty(added.id);
272
527
  await hotel.roomTypes.save({ ref: "rt-river", name: "River View Room", roomCount: 6, adults: 2 });
273
528
  ```
274
529
 
275
- The hotel works at once and joins your monthly invoice on the next 1st. Its first room types put it on
276
- the channel manager; then you connect its booking sites in the partner portal.
530
+ The hotel works at once and joins your monthly invoice on the next 1st. It is put on the channel manager
531
+ when its billing starts, with the room types you sent; then you connect its booking sites in the partner
532
+ portal.
533
+
534
+ ```ts
535
+ // Change a hotel you added: its name, its address, or both. Only what you send changes.
536
+ const changed = await zs.properties.update(added.id, { name: "Ganga Riverside Guest House", address: { line1: "16 Assi Ghat Road" } });
537
+ changed.changed; // ["name", "address.line1"]
538
+ ```
539
+
540
+ It never changes the hotel's country, currency, time zone, owner or tax id. It changes the hotel in
541
+ ZimmerStack, not the name of its listing on a booking site.
277
542
 
278
543
  ```ts
279
- // Remove a hotel you added. confirm is the hotel's exact name, so a wrong id never removes a hotel.
280
- const gone = await zs.properties.delete(added.id, { confirm: added.name });
544
+ // Remove a hotel you added. confirm is the hotel's exact name as it is now, so a wrong id never removes a hotel.
545
+ const gone = await zs.properties.delete(added.id, { confirm: changed.name });
281
546
  gone.channelManager.state; // "REMOVED", or "RETRYING" while one step is still finishing
282
547
  ```
283
548
 
@@ -292,7 +557,96 @@ package waits up to a minute and a half for these two calls. If no answer arrive
292
557
  error), you can safely call `delete` again: a hotel that is already gone answers `replay: true`, and
293
558
  one that is still being removed answers `PROPERTY_BUSY` (wait, then ask again).
294
559
 
295
- Guide: <https://docs.zimmerstack.com/hotels>
560
+ Guide: <https://docs.zimmerstack.com/guides/add-and-remove-hotels>
561
+
562
+ ## Connect a booking site, go live, and a hotel's keys
563
+
564
+ A software company's **company key** can do three more things without the partner portal (from 0.9.0).
565
+ Each needs its own permission, ticked when the key is made.
566
+
567
+ **A connect link.** The hotel's own person connects a booking site. Only Airbnb is connected from
568
+ the link alone: the host signs in on Airbnb's own page. Every other booking site must first accept
569
+ our connectivity partner for the hotel, in its extranet or through its support. That step can take
570
+ days, and no call does it: `hotelStep` in the answer says how.
571
+
572
+ ```ts
573
+ import { shownOnce } from "@zimmerstack/connect";
574
+
575
+ const made = await zs.connectLinks.create({ propertyId: 61, channel: "bookingcom" });
576
+ await tellTheHotel(made.hotelStep); // the step at the booking site, first (null for Airbnb)
577
+ await sendOnceTheStepIsDone(shownOnce(made)); // then the link
578
+ ```
579
+
580
+ The hotel's person opens the link on ZimmerStack's page and types the hotel's id at the booking site
581
+ (MakeMyTrip and Goibibo also ask for the access token they give). Then they confirm each room and
582
+ rate match, and press Start selling. You then receive `channel.connect.completed`. No call takes the
583
+ booking site's details or a match. A link is made with a **live** key only: a practice hotel has no
584
+ booking site to connect. Permission: `channels:connect`.
585
+
586
+ **Readiness and go-live.** A hotel you add is yours from the first day. A hotel that let you in with
587
+ your vendor code is not, until it goes live.
588
+
589
+ ```ts
590
+ const hotel = zs.forProperty(61);
591
+ const report = await hotel.readiness.get(); // four checks, each with what to do
592
+ await hotel.rates.set(aYearOfPrices, { beforeGoLive: true }); // stored, and waits for go-live
593
+ if ((await hotel.readiness.get()).ready) await hotel.readiness.goLive();
594
+ await hotel.availability.set(aYearOfCounts); // right after going live: your room counts
595
+ ```
596
+
597
+ `beforeGoLive: true` says you know the hotel is not live yet. **Prices and stay rules sent this way are
598
+ stored and wait.** The readiness report asks for a price for every rate plan and night of the year
599
+ ahead.
600
+
601
+ **Room counts are different.** Until the hotel is live, a room count may only **lower** what is on sale.
602
+ A lower count goes to the booking sites at once, because a count that waited could sell a room twice. A
603
+ count that **raises** what is on sale is refused (it comes back in the answer's `rejected` list),
604
+ because the hotel's own people may still be running its counts. So send your room counts again right
605
+ after going live.
606
+
607
+ **A hotel's keys.** Make, replace and revoke the keys you made on a hotel you added. Permission:
608
+ `keys:manage`.
609
+
610
+ ```ts
611
+ import { shownOnce, withoutShownOnce } from "@zimmerstack/connect";
612
+
613
+ const minted = await zs.hotelKeys.create(61, { name: "Night audit job", scopes: ["ari:read"] });
614
+ await secrets.put("zimmerstack/hotel-61", shownOnce(minted)); // the key is in this answer only
615
+ console.log(withoutShownOnce(minted)); // safe to log: the key is not in it
616
+ ```
617
+
618
+ **Shown once.** A key, a connect link and a webhook secret are each in one answer and nowhere else.
619
+ `shownOnce(answer)` returns the value. If the answer is a repeat of an earlier request, the value is not
620
+ in it: `shownOnce` then throws an error that names the call that gets you a new one. It never hands you
621
+ an empty value to store by mistake.
622
+
623
+ Guides: <https://docs.zimmerstack.com/guides/connect-an-ota> · <https://docs.zimmerstack.com/partner/go-live> ·
624
+ <https://docs.zimmerstack.com/guides/keys-and-scopes#hotel-keys>
625
+
626
+ ## Your bills, support and status
627
+
628
+ Also for a company key, each with its own permission (from 0.9.0):
629
+
630
+ ```ts
631
+ const bill = await zs.billing.get(); // what is owed, your hotel quota, money paid ahead (billing:read)
632
+ const next = await zs.billing.nextInvoice(); // what the next invoice is made of, hotel by hotel
633
+
634
+ const ticket = await zs.supportTickets.create({ severity: "many_hotels", subject: "Prices are not going out", message: "Since 08:10 UTC …", propertyIds: [61, 62] }); // support:write
635
+
636
+ const { incidents } = await zs.status.get(); // is something wrong on ZimmerStack's side? Any key.
637
+ ```
638
+
639
+ - Billing is **read only**: nothing pays or changes anything. `atCost` lists what the channel manager
640
+ charged above the room types and rate plans a hotel includes, passed on at cost. A line marked
641
+ `RECORDED` is not on an invoice yet.
642
+ - A ticket has three levels. `many_hotels` (two or more hotels cannot sell or take bookings) gets a first
643
+ reply within the hour, 9:00 to 21:00 India time, every day; the other two within one working day.
644
+ ZimmerStack attaches what its own records show, so never paste a key or a guest's details.
645
+ - `zs.status.get()` lists the incidents that touch your hotels. During one, keep what your people
646
+ changed and send it when it ends.
647
+
648
+ Guides: <https://docs.zimmerstack.com/guides/bills-by-api> · <https://docs.zimmerstack.com/guides/support> ·
649
+ <https://docs.zimmerstack.com/guides/status-and-incidents>
296
650
 
297
651
  ## Bookings from the hotel's own website
298
652
 
@@ -350,10 +704,11 @@ answers `replay: true` and moves no money. Your own cancel comes back to you as
350
704
  own cancel button, never from a background job.
351
705
 
352
706
  To try it with a test key, call `zs.sandbox.bookings.create({ …, otaName: "Website" })` and then cancel
353
- that booking. The nights come back and no money moves. A test key cannot pretend a no-show: press Test on
354
- your address and choose `direct.booking.modified` to receive its sample.
707
+ that booking. The nights come back and no money moves. To try a no-show, call
708
+ `zs.sandbox.bookings.noShow(bookingId)` on that booking: your address receives the real
709
+ `direct.booking.modified`, and `{ undo: true }` takes it back.
355
710
 
356
- Guide: <https://docs.zimmerstack.com/website-bookings>
711
+ Guide: <https://docs.zimmerstack.com/guides/website-bookings>
357
712
 
358
713
  ## When the API says no
359
714
 
@@ -367,6 +722,8 @@ try {
367
722
  err.code; // never changes: "RATE_OUT_OF_BAND", "SCOPE_MISSING", "RATE_LIMITED". Decide on this.
368
723
  err.message; // a sentence for the person at the screen. Show it.
369
724
  err.retryAfterSeconds; // set when you hit a limit: how long to wait
725
+ err.freesAt; // the same as a moment (a Date): when to send it again
726
+ err.scope; // which limit said no: "writes", "cells-hour", "rate-resends-day"
370
727
  err.retryable; // false means the request itself is wrong. Fix it. Do not send it again.
371
728
  }
372
729
  ```
@@ -374,22 +731,169 @@ try {
374
731
  The package has already waited and tried again where that could help. Do not put its calls in a retry
375
732
  loop of your own.
376
733
 
377
- Every code, what it means and what to do: <https://docs.zimmerstack.com/errors>
734
+ A limit that frees within two minutes is waited out for you. A longer one (a limit per hour or per day)
735
+ comes straight back as a `RATE_LIMITED` error that says when it frees, so a person is not left waiting.
736
+ A job that may wait can say so, and the package holds the call and tells you when it lands:
737
+
738
+ ```ts
739
+ const zs = new ZimmerStack({ onEvent: (e) => e.type === "wait" && console.log(e.message) });
740
+ await zs.rates.set(updates, { maxWaitSeconds: 3600 }); // "PUT /rates lands in about 25 minutes (waiting for the cells-hour budget)."
741
+ ```
742
+
743
+ Every code, what it means and what to do: <https://docs.zimmerstack.com/guides/errors>
744
+
745
+ ## When something is wrong: the doctor
746
+
747
+ One command looks at your whole integration and says what to fix (from 0.9.0):
748
+
749
+ ```bash
750
+ npx @zimmerstack/connect doctor
751
+ ```
752
+
753
+ It reads the key from `ZIMMERSTACK_CONNECT_KEY` (the environment, or your project's `.env.local` or
754
+ `.env`), and checks, in order:
755
+
756
+ | It checks | What it tells you |
757
+ |---|---|
758
+ | The key | Whether it is the right shape, before anything is sent. A key that was mistyped or cut short is caught by its own checksum. Then whether it answers: revoked, expired, or called from an address that is not on its list. |
759
+ | Is it ZimmerStack | The open incidents on ZimmerStack's side that touch your hotels, with what was last said. |
760
+ | Hotels and permissions | Which hotels the key reaches, and what it may do on each. For a hotel that is not live yet, which readiness checks have not passed and what to do. |
761
+ | Limits | Every limit and how full it is, and whether the integration is paused. |
762
+ | Refused calls | The last day's refused calls, grouped by reason, with what to do about each and the last request id. |
763
+ | Webhook addresses | Whether each one is being answered, and its last failures. If your server answers 401, it says to check how you verify the signature. |
764
+ | Sync and drift | Whether what you sent reached the booking sites, which values were refused, and what the nightly check found changed on a booking site's side. |
765
+
766
+ It only reads, with a test key or a live key, and it never prints the key. It exits with 0 when nothing
767
+ needs attention and 1 when something does, so you can run it after a deploy. `--property <id>` looks at
768
+ one hotel of a company key; `--json` prints the report for a script. The same checks from your own
769
+ code: `diagnose()` and `formatDoctorReport(report)`.
770
+
771
+ Name a night and it explains that night too:
772
+
773
+ ```bash
774
+ npx @zimmerstack/connect doctor --room-type 412 --night 2026-12-31
775
+ ```
776
+
777
+ ## Keys
778
+
779
+ - A key made since 22 Nov 2026 is `zsk_live_` (or `zsk_test_`), 40 letters and digits, then 6
780
+ characters that are a checksum of the rest. `checkKey(value)` tells a real key from a mistyped one
781
+ without sending it anywhere; use it where a person pastes a key. A key made before that day keeps
782
+ working until it is rotated.
783
+ - **Rotate** a key in the screen where it was made (the partner portal, or the hotel owner's Developers
784
+ screen). The new key is shown once and the old one keeps working for 24 hours, so you can swap with
785
+ no downtime. Company keys can be rotated too. A person does this for a hotel's own key and for a
786
+ company key. The keys a software company made on a hotel can also be made, rotated and revoked by
787
+ API (`zs.hotelKeys`, above).
788
+ - **A key found in a public place** (a public repository, for example) is revoked at once and its holder
789
+ is emailed. Calls then answer `API_KEY_REVOKED`: make a new key and keep it in your server's settings,
790
+ never in code.
791
+ - **What a key did** is kept for 7 days: `zs.requests.list()` gives the time, the route, the status, the
792
+ error code, the address and the request id of each call, never a body. An address you do not
793
+ recognise is the first sign of a leaked key.
794
+
795
+ Guide: <https://docs.zimmerstack.com/guides/keys-and-scopes>
378
796
 
379
797
  ## What the package does for you
380
798
 
381
799
  | The rule | What the package does |
382
800
  |---|---|
383
801
  | The key stays on a server | Refuses to start in a browser or a mobile app. Sends the key to ZimmerStack only. Never prints it. |
384
- | You may make only so many calls a minute | Watches the limit and slows down before it is reached. |
385
- | Changes go out in order | Sends one change at a time, in the order you made them. Reads go up to four at once. |
386
- | Try again only when that can help | Tries again after a "slow down" answer, a fault on our side or a network failure. Any other "no" comes straight back to you. |
802
+ | You may make only so many calls a minute | Reads every limit from every answer (the key's, the hotel's, your company's) and slows down before one is reached. |
803
+ | Changes go out in order | Sends one hotel's changes one at a time, in the order you made them. Each hotel has its own queue, so one hotel never holds up another. At most four calls at once. |
804
+ | Try again only when that can help | Tries again after a "slow down" answer, always. Tries again after a fault on our side or a network failure only when sending twice cannot apply the change twice: a read, or a change that carries its own id (next row). Any other "no" comes straight back to you. |
805
+ | A limit per hour or per day | Waits when the wait is under two minutes. Otherwise gives you the "no" at once with when it frees, and stops sending calls that would only be refused again. |
387
806
  | A retry must not save twice | Gives each change its own id and reuses it when it tries again, so the same change is never saved twice. A call that cannot be safely repeated, such as a delete, is not sent again when its result is unknown. |
388
807
  | A request has a size limit | Splits a save at 1,000 updates or 5,000 night cells. |
389
808
  | A refused key is not tried again | After a key is refused, it stops calling. |
390
809
  | A test must not touch a real hotel | Refuses to change anything with a `zsk_live_` key while your tests run. |
391
810
 
392
- Limits in full: <https://docs.zimmerstack.com/limits>
811
+ Limits in full: <https://docs.zimmerstack.com/guides/rate-limits>
812
+
813
+ ## Limits
814
+
815
+ Every limit the API holds you to, from the one table the server enforces. You do not need to learn it:
816
+ the package reads the limits from every answer and keeps inside them. It is here so you can size a job.
817
+ `zs.limits.get()` (from 0.8.0) answers the same rows for your key, with what is left of each and when it
818
+ refills:
819
+
820
+ ```ts
821
+ const { budgets, shield } = await zs.limits.get();
822
+ const today = shield?.budgets.find((b) => b.scope === "cells-day");
823
+ console.log(today?.remaining, "changed cells left today; room again in", today?.resetSeconds, "s");
824
+ ```
825
+
826
+ A write is every call that is not a read. An IPv6 /56 counts as one address. A key that has just worked
827
+ from your address is counted against its own limits, not the address's, so many hotels behind one
828
+ office address are not held to the address's limit.
829
+
830
+ <!-- limits-table:begin (generated from connectApiLimitsTable.ts; run `pnpm --dir apps/backend exec tsx ts/scripts/connect-api-limits-doc.ts`) -->
831
+ **Budgets the key guard and the routes measure (429 `RATE_LIMITED`).**
832
+
833
+ | `data.scope` | In `RateLimit` as | Per | Window | Quota | Counts |
834
+ |---|---|---|---|---|---|
835
+ | `api-address` | `api-address` | address, on each API machine | 60 s fixed | 1,200 | every request to any ZimmerStack API route from one address (an IPv6 /56 counts as one address), counted on each API machine: the guard in front of everything, the Connect API included |
836
+ | `ip` | `ip` | address | 60 s sliding | 240 | requests from one address (an IPv6 /56 counts as one address) that carry no key verified from it in the last ten minutes, checked before the key is read. A key that has authenticated from that address is counted against its own budgets, not here |
837
+ | `ip-auth` | `ip-auth` | address | 60 s sliding | 20 | 401 answers, and 403 IP_NOT_ALLOWED, to one address; past it the address's unverified requests are refused before any lookup. A key that authenticated from that address in the last ten minutes keeps working |
838
+ | `key-auth` | `key-auth` | address and key | 60 s sliding | 5 | 401 and 403 IP_NOT_ALLOWED answers to one key (its first twelve characters) from one address; past it that key is refused from that address before any lookup, so one revoked key never uses up its address's budget |
839
+ | `global-unauthenticated` | `global-unauthenticated` | everyone without a verified key | 60 s sliding | 1,200 | requests from every address together that carry no recently verified key and so cost a key lookup: the most a flood of made-up keys can ask of the database |
840
+ | `requests` | `key` | key | 60 s sliding | 120 | every request on one key |
841
+ | `writes` | `key-writes` | key | 60 s sliding | 30 | every request on one key that is not a GET (PUT, POST and DELETE); a dry run (dryRun: true) is a write here |
842
+ | `property` | `property` | property (all its keys) | 60 s sliding | 300 | every request on all of a property's keys together (five keys are not five budgets) |
843
+ | `property-writes` | `property-writes` | property (all its keys) | 60 s sliding | 60 | every request that is not a GET on all of a property's keys together |
844
+ | `cells` | `cells` | property (all its keys) | 60 s sliding | 20,000 | cells a property's writes name after range expansion, charged before anything is read or written. A dry run is charged the same cells as the write it previews; a close or a reopen (POST /availability/close) is charged the room type's count and each of its rate plans for every night |
845
+ | `company` | `company` | company key (all its hotels) | 60 s sliding | 1,200 | every request on one company key, across all its hotels (each hotel keeps its own key and property budgets too) |
846
+ | `global` | `global` | everyone | 60 s sliding | 3,000 | every authenticated request on the Connect API, all keys together; test keys count in a ceiling of their own of the same size, so a sandbox never spends what live hotels use |
847
+ | `bookings` | `bookings` | key | 60 s sliding | 20 | POST /bookings on one key |
848
+ | `property-bookings` | `property-bookings` | property (all its keys) | 60 s sliding | 40 | POST /bookings on all of a property's keys together |
849
+ | `property-bookings-day` | — | property (all its keys) | rolling 24 hours | 500 | POST /bookings per property per ROLLING 24 HOURS (not per minute); the owner can raise it per property |
850
+ | `direct-cancels` | `direct-cancels` | key | 60 s sliding | 10 | POST /direct-bookings/{bookingId}/cancel on one key (a replay is not counted) |
851
+ | `property-direct-cancels-day` | — | property (all its keys) | rolling 24 hours | 50 | POST /direct-bookings/{bookingId}/cancel per property per ROLLING 24 HOURS (not per minute) |
852
+
853
+ **Budgets over an hour and a day (429 `RATE_LIMITED`). "At least" is the least any property gets; `GET /limits` answers your own.**
854
+
855
+ | `data.scope` | In `RateLimit` as | Per | Window | Quota | Counts |
856
+ |---|---|---|---|---|---|
857
+ | `cells-hour` | — | property (all its keys) | one clock hour (UTC) | at least 10,000 | changed cells, all of a property's keys together. At least this many; a larger property gets two of its own full calendars an hour. A dry run changes nothing and is never counted here |
858
+ | `cells-day` | — | property (all its keys) | rolling 24 hours | at least 30,000 | changed cells, all of a property's keys together. At least this many; a larger property gets six of its own full calendars a day. A dry run changes nothing and is never counted here |
859
+ | `vendor-cells-day` | — | software vendor (all its hotels) | rolling 24 hours | at least 150,000 | a software vendor's changed cells across all its hotels (company keys and keys it minted). At least this many, plus 15,000 for each hotel it serves; a sandbox is never counted here |
860
+ | `shield-lane` | — | property (all its keys) | one clock hour (UTC) | at least 500 | cells of writes that only close inventory, accepted while the property is out of budget or paused (the safety lane). At least this many; sixty nights of every room type |
861
+ | `structure-creates` | — | property | 60 s sliding | 20 | new room types and rate plans per property; a row already here that the write puts on the channel manager counts when it gets there, never when the answer's notice says it could not; also the most one request may create (TOO_MANY_NEW_ENTITIES) |
862
+ | `structure-creates-day` | — | property | rolling 24 hours | 300 | new room types and rate plans per property |
863
+ | `structure-edits-day` | — | property | rolling 24 hours | 300 | changed room types and rate plans per property |
864
+ | `structure-deletes-day` | — | property | rolling 24 hours | 60 | deleted room types and rate plans per property |
865
+ | `vendor-structure-creates-day` | — | software vendor (all its hotels) | rolling 24 hours | at least 500 | a software vendor's new room types and rate plans across all its hotels |
866
+ | `vendor-remote-properties-day` | — | software vendor | rolling 24 hours | 10 | hotels a software vendor puts on the channel manager for the first time |
867
+ | `vendor-property-removals-day` | — | software vendor | rolling 24 hours | 10 | hotels a software partner removes (DELETE /properties/{propertyId}, and Remove hotel in the partner portal); a sandbox is never counted |
868
+ | `partner-new-properties-hour` | — | software partner | one hour | 20 | hotels a partner adds, POST /properties and the partner portal's form together; a sandbox is never counted |
869
+ | `partner-new-sandboxes-hour` | — | software partner | rolling hour | 30 | sandboxes a partner makes with a test key (POST /properties), counted when one is made; the partner portal's own sandbox button is not counted |
870
+ | `connect-links-hour` | — | property | rolling hour | 10 | one-time connect links a software partner makes for one hotel (POST /connect-links), every booking site together; a link that was withdrawn or ran out still counts |
871
+ | `partner-connect-links-hour` | — | software partner | rolling hour | 120 | one-time connect links a software partner makes across all its hotels (POST /connect-links) |
872
+ | `modifier-changes-day` | — | property | rolling 24 hours | 6 | changes to a channel's price modifier per property (PUT /channels/{channelId}/modifier); steps the channel already holds are not counted |
873
+ | `rate-resends-day` | — | property | rolling 24 hours | 3 | times a property's prices are sent to the channels again (POST /rates/resend) |
874
+ | `partner-support-tickets-day` | — | software partner | rolling 24 hours | 20 | support tickets a partner opens (POST /support-tickets), both key modes together; a replayed idempotency key is not counted |
875
+ | `partner-support-messages-hour` | — | software partner | rolling hour | 60 | messages a partner adds to its support tickets (POST /support-tickets/{ticketId}/messages) |
876
+
877
+ **Caps: the most one request may carry, and the most of a thing that may exist (a 4xx of their own, never a 429).**
878
+
879
+ | `data.scope` | In `RateLimit` as | Per | Window | Quota | Counts |
880
+ |---|---|---|---|---|---|
881
+ | `maxUpdatesPerRequest` | — | request | one request | 1,000 | entries in one updates array (400 TOO_MANY_UPDATES past it) |
882
+ | `maxCellsPerRequest` | — | request | one request | 5,000 | cells (entity × night) one request may name after range expansion (400 TOO_MANY_CELLS past it) |
883
+ | `maxBodyBytes` | — | request | one request | 1,048,576 | the JSON body; larger is 413 PAYLOAD_TOO_LARGE before a byte is validated |
884
+ | `horizonDays` | — | request | one request | 500 | the last writable night and the last bookable arrival: today + this many, in the property's calendar (400 HORIZON past it) |
885
+ | `maxNightsPerBooking` | — | request | one request | 90 | nights in one POST /bookings |
886
+ | `newEntitiesPerRequest` | — | request | one request | 20 | new room types or rate plans one structure write may create (400 TOO_MANY_NEW_ENTITIES past it) |
887
+ | `maxRoomTypes` | — | property | one request | 18 | live room types on a hotel (a vacation rental has figures of its own, on GET /limits): 409 CATALOG_LIMIT_REACHED past it |
888
+ | `maxRatePlans` | — | property | one request | 180 | live rate plans on a hotel: 409 CATALOG_LIMIT_REACHED past it |
889
+ | `maxActiveKeysPerProperty` | — | property | one request | 5 | active hotel keys on one property (409 KEY_LIMIT past it) |
890
+ | `maxActiveCompanyKeys` | — | software partner | one request | 5 | active company keys of one software partner |
891
+ | `maxSandboxes` | — | software partner | one request | 5 | sandboxes one software partner may hold at once |
892
+ | `maxAllowedCidrs` | — | key | one request | 20 | entries in one key's address allowlist |
893
+ | `idempotencyRetentionDays` | — | key | one request | 7 | how long an x-idempotency-key replays its first answer |
894
+ | `maxSupportMessageChars` | — | request | one request | 5,000 | characters in one support ticket message, the first included (400 VALIDATION past it) |
895
+ | `maxSupportTicketProperties` | — | request | one request | 200 | hotels one support ticket may name in propertyIds; past it send allProperties (400 VALIDATION) |
896
+ <!-- limits-table:end -->
393
897
 
394
898
  ## Options
395
899
 
@@ -399,8 +903,8 @@ new ZimmerStack({
399
903
  propertyId, // a company key's hotel. Default: ZIMMERSTACK_PROPERTY_ID (or use forProperty)
400
904
  timeoutMs: 30_000, // how long one try may take
401
905
  maxRetries: 3, // how many more tries, for what may pass later
402
- maxWaitSeconds: 120, // the longest it waits for a limit before giving you the "no"
403
- onEvent: (e) => log(e), // every answer, wait and retry, for your logs. Never carries the key.
906
+ maxWaitSeconds: 120, // the longest it holds a call for a limit before giving you the "no". Any call can pass its own.
907
+ onEvent: (e) => log(e), // every answer, wait and retry, for your logs ("lands in about 25 minutes"). Never carries the key.
404
908
  fetch, // a stand-in for tests
405
909
  });
406
910
  ```
@@ -408,10 +912,14 @@ new ZimmerStack({
408
912
  ## Test your integration
409
913
 
410
914
  Use a `zsk_test_` key, or pass a fake `fetch`. Nothing you do with a test key reaches a booking site,
411
- and `zs.sandbox.bookings.create()` sends your webhook a real message. A software company makes test keys
915
+ and `zs.sandbox.bookings.create()` sends your webhook a real message. A practice hotel can make a real
916
+ message of every type: a booking arriving, changing and cancelled, a cancellation with no booking before
917
+ it (`arrivesCancelled: true`), a website booking and its no-show, and a channel problem with its end
918
+ (`zs.sandbox.syncEvents.create()`). It can also be made to fail: `zs.sandbox.faults.set({ kind: "refuse" })`
919
+ makes its pretend booking site refuse the next price, so you can watch your software handle it. A software company makes test keys
412
920
  in the partner portal under Developers. A hotel's owner makes one in Admin → Developers → API keys.
413
921
 
414
- Guide: <https://docs.zimmerstack.com/sandbox>
922
+ Guide: <https://docs.zimmerstack.com/guides/sandbox>
415
923
 
416
924
  ## For AI coding agents
417
925
 
@@ -442,6 +950,14 @@ up any part of the API, and try a call on your practice hotel before it writes c
442
950
  | `zimmerstack_reference` | Any call, type, limit or error code, from the API's own contract. |
443
951
  | `zimmerstack_sandbox_read` | One read on your practice hotel: real ids and real shapes. |
444
952
  | `zimmerstack_sandbox_write` | One change on your practice hotel, to try a request before writing the code that sends it. |
953
+ | `zimmerstack_doctor` | The doctor's checks on your practice hotel's key: what is wrong, and what to do. |
954
+ | `zimmerstack_sandbox_limits` | Every limit of the key and how full it is. |
955
+ | `zimmerstack_sandbox_events` | The practice hotel's ordered event log, from a sequence: the exact body your webhook receives. |
956
+ | `zimmerstack_sandbox_simulate` | One real event of any type on your practice hotel: a booking arriving, changing, cancelled, a no-show, a channel problem and its end. |
957
+ | `zimmerstack_sandbox_dry_run` | What a change would do on your practice hotel, with nothing saved, and its notices. |
958
+ | `zimmerstack_sandbox_explain` | One night's whole story on your practice hotel. |
959
+ | `zimmerstack_sandbox_close` | Close a room type everywhere on your practice hotel, or reopen it. |
960
+ | `zimmerstack_sandbox_fault` | Make the practice hotel's pretend booking site refuse a price, slow down or go down, so your handling can be tried. |
445
961
 
446
962
  ```bash
447
963
  # Claude Code
@@ -459,15 +975,15 @@ test key only and refuses a live one, so an agent cannot change a real hotel thr
459
975
  the rules and the lookups still work.
460
976
 
461
977
  The whole API in one file an agent can read: <https://docs.zimmerstack.com/llms-full.txt>.
462
- More: <https://docs.zimmerstack.com/ai>
978
+ More: <https://docs.zimmerstack.com/guides/build-with-ai>
463
979
 
464
980
  ## Words used here
465
981
 
466
982
  | Word | What it means |
467
983
  |---|---|
468
984
  | Booking site | A website that sells the hotel's rooms: Booking.com, Airbnb, Expedia and the rest. Travel people say OTA. The API calls each one a channel. |
469
- | Sandbox | Your practice hotel. It behaves like a real one, but no booking site ever sees it. |
470
- | Key | A password for your software. `zsk_test_` works on a sandbox, `zsk_live_` on a real hotel. |
985
+ | Sandbox | Where your practice hotels live. The docs call one a test hotel. It behaves like a real hotel, but no booking site ever sees it. |
986
+ | Key | A password for your software. `zsk_test_` works in your sandbox, `zsk_live_` on a real hotel. |
471
987
  | Company key | One key for all of a software company's hotels. Each call says which hotel it is for. |
472
988
  | Room type | A kind of room the hotel sells, like "Deluxe Room". |
473
989
  | Rate plan | One way to sell a room type, like "Bed and breakfast". Prices belong to rate plans. |
@@ -475,14 +991,14 @@ More: <https://docs.zimmerstack.com/ai>
475
991
  | Webhook | A message ZimmerStack sends to your server when something happens, such as a new booking. |
476
992
  | Permission | What a key may do, like `catalog:write` for changing room types and rate plans. The API calls it a scope. |
477
993
 
478
- More words: <https://docs.zimmerstack.com/glossary>
994
+ More words: <https://docs.zimmerstack.com/words>
479
995
 
480
996
  ## Find everything
481
997
 
482
998
  | Where | What is there |
483
999
  |---|---|
484
1000
  | <https://docs.zimmerstack.com> | The guides and the full reference |
485
- | <https://docs.zimmerstack.com/quickstart> | The first calls, step by step |
1001
+ | <https://docs.zimmerstack.com/partner/first-call> | The first calls, step by step |
486
1002
  | <https://docs.zimmerstack.com/pricing> | What a live property costs a month |
487
1003
  | <https://www.zimmerstack.com/partners/pms-companies#join> | Sign up, free |
488
1004
  | <https://partner.zimmerstack.com/login> | The partner portal: your practice hotels, keys, webhooks, hotels and bills |