@zimmerstack/connect 0.2.0 → 0.3.0

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.
package/AGENTS.md CHANGED
@@ -64,6 +64,20 @@ https://docs.zimmerstack.com/llms-full.txt
64
64
  - Keep the grid on the price before any modifier; show a channel's price beside it with
65
65
  `channelPrice(rate, steps)`.
66
66
 
67
+ ## Website bookings: apply them before you push room counts
68
+
69
+ - When the hotel also sells on its own website through ZimmerStack's booking engine, those bookings
70
+ reach you as the webhooks `direct.booking.created` and `direct.booking.cancelled` (the endpoint must
71
+ list those two types) and by `zs.directBookings.all({ since })` (scope `direct-bookings:read`). They
72
+ are not OTA bookings: `isWebsiteBookingEvent(event)` tells them apart, `channel.otaName` is `"Website"`
73
+ and `finance` is null. There is no modified event.
74
+ - A website booking takes one room off the count the channels hold, at once. A PMS that pushes absolute
75
+ room counts must apply the booking to its own calendar BEFORE its next `zs.availability.set` or
76
+ `zs.grid.save`, or that push puts the sold room back on sale. Read `zs.directBookings.all` before a
77
+ full push. Nothing on our side stops the count from going up.
78
+ - You cannot cancel a website booking through this package: the guest cancels on the booking page, or
79
+ the hotel does in ZimmerStack.
80
+
67
81
  ## Errors
68
82
 
69
83
  ```ts
@@ -105,3 +119,4 @@ these tools.
105
119
  - [ ] Errors show `err.message` to the person and branch on `err.code`.
106
120
  - [ ] Tests run against a `zsk_test_` key or a fake `fetch`; none needs a live key.
107
121
  - [ ] Where a modifier is saved, the screen says when it takes effect, and the re-send is its own button.
122
+ - [ ] A PMS that pushes room counts applies every website booking to its own calendar before it pushes.
package/README.md CHANGED
@@ -86,7 +86,8 @@ zs.channels.setModifier(channelId, steps)
86
86
 
87
87
  zs.bookings.create(…) / .get(id) / .list(…) / .cancel(id) // your own booking engine
88
88
  zs.channelBookings.list(…) / .get(id) / .all(…) // what the booking sites sent
89
- zs.sandbox.bookings.create(…) / .cancel(id) / .modify(id, …) // pretend an OTA booked (test keys)
89
+ zs.directBookings.list(…) / .get(id) / .all(…) // what guests booked on the hotel's own website
90
+ zs.sandbox.bookings.create(…) / .cancel(id) / .modify(id, …) // pretend an OTA or the website booked (test keys)
90
91
 
91
92
  zs.request("GET /sync") // any operation of the contract by name, typed
92
93
  ```
@@ -160,13 +161,14 @@ loop of your own.
160
161
  ## Webhooks
161
162
 
162
163
  ```ts
163
- import { verifyWebhook } from "@zimmerstack/connect";
164
+ import { isOtaBookingEvent, isWebsiteBookingEvent, verifyWebhook } from "@zimmerstack/connect";
164
165
 
165
166
  export async function POST(request: Request) {
166
167
  // The body exactly as it arrived, before any JSON parsing.
167
168
  const event = await verifyWebhook(await request.text(), request.headers, process.env.ZIMMERSTACK_WEBHOOK_SECRET!);
168
169
  // Deliveries are at-least-once: remember event.id and skip one you have seen.
169
- if (event.type === "channel.booking.created") await save(event.data.booking);
170
+ if (isOtaBookingEvent(event)) await save(event.data.booking); // channel.booking.created, .modified, .cancelled
171
+ if (isWebsiteBookingEvent(event)) await applyToMyCalendar(event.data.booking); // direct.booking.created, .cancelled
170
172
  return new Response(null, { status: 204 });
171
173
  }
172
174
  ```
@@ -174,6 +176,28 @@ export async function POST(request: Request) {
174
176
  It throws `ZimmerStackWebhookError` for a delivery that is not ZimmerStack's or is older than five
175
177
  minutes: answer 400 and do not act on the body.
176
178
 
179
+ ## Bookings from the hotel's own website
180
+
181
+ A hotel that sells on its own website through ZimmerStack's booking engine, and keeps its own PMS,
182
+ gets those bookings in a family of their own: the webhooks `direct.booking.created` and
183
+ `direct.booking.cancelled` (the endpoint must list both types; one registered earlier receives none
184
+ until its owner ticks them), and `zs.directBookings` for the pull (scope `direct-bookings:read`). The
185
+ booking object is the one OTA bookings use. `channel.otaName` is `"Website"`, `finance` is null, and
186
+ `amounts.paid` is what the guest paid online. There is no modified event.
187
+
188
+ **Apply a website booking to your own calendar before your next push of room counts.** The booking
189
+ takes one room off the count the channels hold at once; a push of the old absolute count would put it
190
+ back on sale. Read `zs.directBookings.all` before a full push:
191
+
192
+ ```ts
193
+ for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
194
+ await zs.grid.save(edits); // only now
195
+ ```
196
+
197
+ A guest cancels on the booking page, or the hotel cancels in ZimmerStack; there is no way to cancel
198
+ one through the API yet. To try it with a test key, `zs.sandbox.bookings.create({ …, otaName: "Website" })`.
199
+ Guide: <https://docs.zimmerstack.com/website-bookings>
200
+
177
201
  ## Options
178
202
 
179
203
  ```ts
@@ -237,4 +261,5 @@ real hotel through it. Without a key the rules and the reference still work.
237
261
  - Guides and reference: <https://docs.zimmerstack.com>
238
262
  - Build a rate grid: <https://docs.zimmerstack.com/rate-grid>
239
263
  - Prices per channel: <https://docs.zimmerstack.com/per-ota>
264
+ - Bookings from the hotel's own website: <https://docs.zimmerstack.com/website-bookings>
240
265
  - Limits: <https://docs.zimmerstack.com/limits> · Errors: <https://docs.zimmerstack.com/errors>
@@ -231,10 +231,30 @@ export declare class ZimmerStack {
231
231
  */
232
232
  all: (query?: Omit<NonNullable<Op<"GET /channel-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
233
233
  };
234
+ readonly directBookings: {
235
+ /**
236
+ * Website bookings, in the webhook's shape (`direct.booking.*`), cancellations included. Scope
237
+ * `direct-bookings:read`. Follow `nextCursor`, or use `all`.
238
+ */
239
+ list: (query?: Op<"GET /direct-bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").ChannelBookingsList>;
240
+ get: (bookingId: number, options?: ReadOptions) => Promise<ChannelBooking>;
241
+ /**
242
+ * Every website booking changed since `since`, page by page. A PMS that pushes room counts reads this
243
+ * before a full push, so the sold rooms are in its own calendar first.
244
+ *
245
+ * @example
246
+ * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
247
+ */
248
+ all: (query?: Omit<NonNullable<Op<"GET /direct-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
249
+ };
234
250
  readonly sandbox: {
235
251
  bookings: {
236
252
  list: (options?: ReadOptions) => Promise<import("./generated.js").SandboxBookingsList>;
237
- /** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
253
+ /**
254
+ * Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint.
255
+ * With `otaName: "Website"` it pretends a guest booked on the hotel's own website instead, and the webhook
256
+ * is `direct.booking.created`.
257
+ */
238
258
  create: (body: SandboxBookingCreate, options?: WriteOptions) => Promise<import("./generated.js").SandboxBooking>;
239
259
  cancel: (bookingId: number, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
240
260
  modify: (bookingId: number, body: SandboxBookingModify, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
@@ -549,12 +549,30 @@ class ZimmerStack {
549
549
  * @example
550
550
  * for await (const booking of zs.channelBookings.all({ since: lastSeen })) save(booking);
551
551
  */
552
- all: (query, options) => this.#allChannelBookings(query, options),
552
+ all: (query, options) => this.#allPages((cursor) => this.channelBookings.list({ limit: 100, ...query, cursor }, options)),
553
553
  };
554
- async *#allChannelBookings(query, options) {
554
+ /* ── bookings guests made on the hotel's own website (our booking engine) ── */
555
+ directBookings = {
556
+ /**
557
+ * Website bookings, in the webhook's shape (`direct.booking.*`), cancellations included. Scope
558
+ * `direct-bookings:read`. Follow `nextCursor`, or use `all`.
559
+ */
560
+ list: (query, options) => this.request("GET /direct-bookings", { query, ...options }),
561
+ get: (bookingId, options) => this.request("GET /direct-bookings/{bookingId}", { path: { bookingId }, ...options }),
562
+ /**
563
+ * Every website booking changed since `since`, page by page. A PMS that pushes room counts reads this
564
+ * before a full push, so the sold rooms are in its own calendar first.
565
+ *
566
+ * @example
567
+ * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
568
+ */
569
+ all: (query, options) => this.#allPages((cursor) => this.directBookings.list({ limit: 100, ...query, cursor }, options)),
570
+ };
571
+ /** Follow a booking list's `nextCursor` to its last page. */
572
+ async *#allPages(read) {
555
573
  let cursor;
556
574
  do {
557
- const page = await this.channelBookings.list({ limit: 100, ...query, cursor }, options);
575
+ const page = await read(cursor);
558
576
  yield* page.items;
559
577
  cursor = page.nextCursor ?? undefined;
560
578
  } while (cursor);
@@ -563,7 +581,11 @@ class ZimmerStack {
563
581
  sandbox = {
564
582
  bookings: {
565
583
  list: (options) => this.request("GET /sandbox/bookings", options),
566
- /** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
584
+ /**
585
+ * Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint.
586
+ * With `otaName: "Website"` it pretends a guest booked on the hotel's own website instead, and the webhook
587
+ * is `direct.booking.created`.
588
+ */
567
589
  create: (body, options) => this.request("POST /sandbox/bookings", { body, ...options }),
568
590
  cancel: (bookingId, options) => this.request("POST /sandbox/bookings/{bookingId}/cancel", { path: { bookingId }, ...options }),
569
591
  modify: (bookingId, body, options) => this.request("POST /sandbox/bookings/{bookingId}/modify", { path: { bookingId }, body, ...options }),
@@ -1,5 +1,5 @@
1
1
  /** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
2
- export declare const SDK_VERSION = "0.2.0";
2
+ export declare const SDK_VERSION = "0.3.0";
3
3
  /** Where the API lives. The key is sent nowhere else. */
4
4
  export declare const API_ORIGIN = "https://api.zimmerstack.com";
5
5
  export declare const API_PREFIX = "/api/v1/connect-api/v1";
@@ -28,7 +28,7 @@ export declare const LIMITS: {
28
28
  export declare const ERROR_CODES: readonly ["API_KEY_INVALID", "API_KEY_REVOKED", "API_KEY_EXPIRED", "CONNECT_API_NOT_CONFIGURED", "IP_NOT_ALLOWED", "SCOPE_MISSING", "PROPERTY_UNAVAILABLE", "CHANNEL_MANAGER_DISABLED", "PMS_NOT_AVAILABLE", "VALIDATION", "RANGE_INVALID", "HORIZON", "TOO_MANY_UPDATES", "TOO_MANY_CELLS", "UNKNOWN_ROOM_TYPE", "UNKNOWN_RATE_PLAN", "CURRENCY_MISMATCH", "RATE_LIMITED", "NOTHING_ACCEPTED", "BATCH_NOT_FOUND", "IDEMPOTENCY_KEY_INVALID", "IDEMPOTENCY_KEY_REUSED", "IDEMPOTENCY_IN_FLIGHT", "STAY_INVALID", "UNKNOWN_ROOM_TYPE_FOR_PLAN", "OCCUPANCY_EXCEEDED", "NO_AVAILABILITY", "EXTERNAL_REFERENCE_REUSED", "PAYMENT_NOT_ALLOWED", "PAYMENT_EXCEEDS_TOTAL", "BOOKING_NOT_FOUND", "BOOKING_NOT_CANCELLABLE", "MODULE_NOT_ENTITLED", "SANDBOX_ONLY", "ROOM_TYPE_NOT_FOUND", "RATE_PLAN_NOT_FOUND", "CATALOG_CONFLICT", "CATALOG_BUSY", "CHANNEL_MANAGER_ERROR", "PROPERTY_REQUIRED", "PROPERTY_NOT_FOUND", "ARI_NOT_AUTHORITATIVE", "ROUTE_NOT_FOUND", "PAYLOAD_TOO_LARGE", "AUTH_BACKEND_UNAVAILABLE", "BOOKING_NOT_MODIFIABLE", "SANDBOX_NOT_FOUND", "SANDBOX_INCOMPLETE", "WRITES_FROZEN", "WRITES_SUSPENDED", "SHIELD_UNAVAILABLE", "CATALOG_LIMIT_REACHED", "TOO_MANY_NEW_ENTITIES", "RATE_OUT_OF_BAND", "CHANNEL_NOT_FOUND", "CHANNEL_SHARED", "MODIFIER_OUT_OF_BAND"];
29
29
  export type ErrorCode = (typeof ERROR_CODES)[number];
30
30
  /** What a key may do. The hotel's owner (or, for a vendor's key, the vendor) chose them when the key was made. */
31
- export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
31
+ export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "direct-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
32
32
  export type Scope = (typeof SCOPES)[number];
33
33
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
34
34
  export declare const MODIFIER_TAKES_EFFECT = "A modifier applies to prices sent to the channel after the change. Prices already on the channel stay as they are until those nights are sent again.";
@@ -585,9 +585,9 @@ export interface SandboxBookingCreate {
585
585
  adults?: number;
586
586
  /** The guest's name; default a fictional one */
587
587
  guestName?: string;
588
- /** The channel the booking pretends to arrive from; default Booking.com */
589
- otaName?: "Booking.com" | "Expedia" | "Agoda" | "Airbnb" | "MakeMyTrip" | "Goibibo";
590
- /** true = the channel collected the money, so totalPaid equals the total; default false (pay at the property) */
588
+ /** The channel the booking pretends to arrive from; default Booking.com. "Website" simulates a booking on the hotel's own website (our booking engine): it sends direct.booking.created and is listed by GET /direct-bookings, not GET /channel-bookings */
589
+ otaName?: "Booking.com" | "Expedia" | "Agoda" | "Airbnb" | "MakeMyTrip" | "Goibibo" | "Website";
590
+ /** true = the channel collected the money (for Website: the guest paid online), so totalPaid equals the total; default false (pay at the property) */
591
591
  paidByOta?: boolean;
592
592
  }
593
593
  export interface SandboxBookingModify {
@@ -872,13 +872,13 @@ export interface SandboxBooking {
872
872
  createdAt: string;
873
873
  /** What this call put on the wire for the sandbox's webhook endpoints */
874
874
  webhook: {
875
- eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled";
875
+ eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled" | "direct.booking.created" | "direct.booking.cancelled";
876
876
  /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */
877
877
  queued: boolean;
878
878
  };
879
879
  }
880
880
  export interface SandboxBookingsList {
881
- /** Simulated OTA bookings on the sandbox, newest first */
881
+ /** Simulated bookings on the sandbox (OTA and website), newest first */
882
882
  bookings: Array<{
883
883
  /** The PMS booking id, the one the webhook carries */
884
884
  bookingId: number;
@@ -905,7 +905,7 @@ export interface SandboxBookingsList {
905
905
  createdAt: string;
906
906
  /** What this call put on the wire for the sandbox's webhook endpoints */
907
907
  webhook: {
908
- eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled";
908
+ eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled" | "direct.booking.created" | "direct.booking.cancelled";
909
909
  /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */
910
910
  queued: boolean;
911
911
  };
@@ -1103,6 +1103,27 @@ export interface Operations {
1103
1103
  body: undefined;
1104
1104
  response: ChannelBooking;
1105
1105
  };
1106
+ /** The bookings guests made on the hotel's own website, in the webhook's shape */
1107
+ "GET /direct-bookings": {
1108
+ path: undefined;
1109
+ query: {
1110
+ since?: string;
1111
+ status?: "CONFIRMED" | "CANCELLED";
1112
+ limit?: number;
1113
+ cursor?: string;
1114
+ };
1115
+ body: undefined;
1116
+ response: ChannelBookingsList;
1117
+ };
1118
+ /** One website booking, the webhook's shape */
1119
+ "GET /direct-bookings/{bookingId}": {
1120
+ path: {
1121
+ bookingId: string | number;
1122
+ };
1123
+ query: undefined;
1124
+ body: undefined;
1125
+ response: ChannelBooking;
1126
+ };
1106
1127
  /** Simulated OTA bookings on the sandbox, newest first */
1107
1128
  "GET /sandbox/bookings": {
1108
1129
  path: undefined;
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.OPERATIONS = exports.MODIFIER_TAKES_EFFECT = exports.SCOPES = exports.ERROR_CODES = exports.LIMITS = exports.PROPERTY_HEADER = exports.IDEMPOTENCY_HEADER = exports.API_PREFIX = exports.API_ORIGIN = exports.SDK_VERSION = void 0;
6
6
  /** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
7
- exports.SDK_VERSION = "0.2.0";
7
+ exports.SDK_VERSION = "0.3.0";
8
8
  /** Where the API lives. The key is sent nowhere else. */
9
9
  exports.API_ORIGIN = "https://api.zimmerstack.com";
10
10
  exports.API_PREFIX = "/api/v1/connect-api/v1";
@@ -96,6 +96,7 @@ exports.SCOPES = [
96
96
  "catalog:write",
97
97
  "channel-modifiers:write",
98
98
  "channel-bookings:read",
99
+ "direct-bookings:read",
99
100
  "bookings:read",
100
101
  "bookings:write",
101
102
  "bookings:payments"
@@ -127,6 +128,8 @@ exports.OPERATIONS = {
127
128
  "POST /rates/resend": { idempotent: true, bodyRequired: false },
128
129
  "GET /channel-bookings": { idempotent: false, bodyRequired: false },
129
130
  "GET /channel-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
131
+ "GET /direct-bookings": { idempotent: false, bodyRequired: false },
132
+ "GET /direct-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
130
133
  "GET /sandbox/bookings": { idempotent: false, bodyRequired: false },
131
134
  "POST /sandbox/bookings": { idempotent: true, bodyRequired: true },
132
135
  "POST /sandbox/bookings/{bookingId}/cancel": { idempotent: false, bodyRequired: false },
@@ -10,7 +10,7 @@ export { ZimmerStackError, ZimmerStackUsageError } from "./errors.js";
10
10
  export type { LocalErrorCode } from "./errors.js";
11
11
  export { addDays, buildGrid, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
12
12
  export type { Grid, GridEdits, ModifierStep, Range, Restrictions } from "./grid.js";
13
- export { verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
14
- export type { WebhookEvent } from "./webhooks.js";
13
+ export { BOOKING_EVENT_TYPES, OTA_BOOKING_EVENT_TYPES, WEBSITE_BOOKING_EVENT_TYPES, isOtaBookingEvent, isWebsiteBookingEvent, verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
14
+ export type { BookingEvent, BookingEventType, OtaBookingEvent, OtaBookingEventType, WebhookEvent, WebhookEventType, WebsiteBookingEvent, WebsiteBookingEventType } from "./webhooks.js";
15
15
  export { ERROR_CODES, LIMITS, MODIFIER_TAKES_EFFECT, SCOPES, SDK_VERSION } from "./generated.js";
16
16
  export type * from "./generated.js";
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SDK_VERSION = exports.SCOPES = exports.MODIFIER_TAKES_EFFECT = exports.LIMITS = exports.ERROR_CODES = exports.ZimmerStackWebhookError = exports.verifyWebhook = exports.toRanges = exports.eachDate = exports.chunk = exports.channelPrice = exports.buildGrid = exports.addDays = exports.ZimmerStackUsageError = exports.ZimmerStackError = exports.ZimmerStack = void 0;
3
+ exports.SDK_VERSION = exports.SCOPES = exports.MODIFIER_TAKES_EFFECT = exports.LIMITS = exports.ERROR_CODES = exports.ZimmerStackWebhookError = exports.verifyWebhook = exports.isWebsiteBookingEvent = exports.isOtaBookingEvent = exports.WEBSITE_BOOKING_EVENT_TYPES = exports.OTA_BOOKING_EVENT_TYPES = exports.BOOKING_EVENT_TYPES = exports.toRanges = exports.eachDate = exports.chunk = exports.channelPrice = exports.buildGrid = exports.addDays = exports.ZimmerStackUsageError = exports.ZimmerStackError = exports.ZimmerStack = void 0;
4
4
  /**
5
5
  * @zimmerstack/connect: the ZimmerStack Connect API from your server.
6
6
  *
@@ -20,6 +20,11 @@ Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { r
20
20
  Object.defineProperty(exports, "eachDate", { enumerable: true, get: function () { return grid_ts_1.eachDate; } });
21
21
  Object.defineProperty(exports, "toRanges", { enumerable: true, get: function () { return grid_ts_1.toRanges; } });
22
22
  var webhooks_ts_1 = require("./webhooks.js");
23
+ Object.defineProperty(exports, "BOOKING_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.BOOKING_EVENT_TYPES; } });
24
+ Object.defineProperty(exports, "OTA_BOOKING_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.OTA_BOOKING_EVENT_TYPES; } });
25
+ Object.defineProperty(exports, "WEBSITE_BOOKING_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.WEBSITE_BOOKING_EVENT_TYPES; } });
26
+ Object.defineProperty(exports, "isOtaBookingEvent", { enumerable: true, get: function () { return webhooks_ts_1.isOtaBookingEvent; } });
27
+ Object.defineProperty(exports, "isWebsiteBookingEvent", { enumerable: true, get: function () { return webhooks_ts_1.isWebsiteBookingEvent; } });
23
28
  Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhooks_ts_1.verifyWebhook; } });
24
29
  Object.defineProperty(exports, "ZimmerStackWebhookError", { enumerable: true, get: function () { return webhooks_ts_1.ZimmerStackWebhookError; } });
25
30
  var generated_ts_1 = require("./generated.js");
@@ -3,11 +3,30 @@ import type { ChannelBooking } from "./generated.js";
3
3
  * Verifying a webhook ZimmerStack sent you (Standard Webhooks: the `webhook-id`, `webhook-timestamp` and
4
4
  * `webhook-signature` headers). Uses Web Crypto, so it runs on Node and on edge runtimes alike.
5
5
  */
6
+ /** An OTA booking arrived, changed or was cancelled (through the channel manager). */
7
+ export declare const OTA_BOOKING_EVENT_TYPES: readonly ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled"];
8
+ /**
9
+ * A guest booked, or cancelled, on the hotel's own website through ZimmerStack's booking engine. The same
10
+ * booking object as the OTA events, in a family of its own: an endpoint receives these only when it lists
11
+ * the two types. There is no modified event.
12
+ */
13
+ export declare const WEBSITE_BOOKING_EVENT_TYPES: readonly ["direct.booking.created", "direct.booking.cancelled"];
14
+ /** Every event whose `data.booking` is a booking, of either family. */
15
+ export declare const BOOKING_EVENT_TYPES: readonly ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled", "direct.booking.created", "direct.booking.cancelled"];
16
+ export type OtaBookingEventType = (typeof OTA_BOOKING_EVENT_TYPES)[number];
17
+ export type WebsiteBookingEventType = (typeof WEBSITE_BOOKING_EVENT_TYPES)[number];
18
+ export type BookingEventType = (typeof BOOKING_EVENT_TYPES)[number];
19
+ /** Every type an endpoint can receive. A newer API may add more: `WebhookEvent.type` stays a string. */
20
+ export type WebhookEventType = BookingEventType | "channel.sync.alert" | "channel.sync.recovered" | "zimmerstack.ping";
6
21
  /** What every delivery carries. Deliveries are at-least-once: dedupe on `id`, order on `occurredAt`. */
7
22
  export interface WebhookEvent {
8
23
  /** "evt_<uuid>", the same on every retry and on every endpoint. */
9
24
  id: string;
10
- /** channel.booking.created · channel.booking.modified · channel.booking.cancelled · channel.sync.* · zimmerstack.ping */
25
+ /**
26
+ * channel.booking.created · channel.booking.modified · channel.booking.cancelled (an OTA booking) ·
27
+ * direct.booking.created · direct.booking.cancelled (a booking on the hotel's own website) ·
28
+ * channel.sync.* · zimmerstack.ping. Narrow it with `isOtaBookingEvent` and `isWebsiteBookingEvent`.
29
+ */
11
30
  type: string;
12
31
  apiVersion: string;
13
32
  occurredAt: string;
@@ -30,6 +49,29 @@ export interface WebhookEvent {
30
49
  previous?: Record<string, unknown> | null;
31
50
  truncated?: boolean;
32
51
  }
52
+ /** An event whose `data.booking` is there: of either booking family. */
53
+ export type BookingEvent = WebhookEvent & {
54
+ type: BookingEventType;
55
+ data: {
56
+ booking: ChannelBooking;
57
+ [key: string]: unknown;
58
+ };
59
+ };
60
+ /** A booking a guest made on the hotel's own website. `finance` is null and `changes` and `previous` always are. */
61
+ export type WebsiteBookingEvent = BookingEvent & {
62
+ type: WebsiteBookingEventType;
63
+ };
64
+ /** A booking an OTA sent. */
65
+ export type OtaBookingEvent = BookingEvent & {
66
+ type: OtaBookingEventType;
67
+ };
68
+ /**
69
+ * True for `direct.booking.created` and `direct.booking.cancelled`: a booking made on the hotel's own
70
+ * website. A PMS that pushes room counts must put it in its own calendar before its next push.
71
+ */
72
+ export declare function isWebsiteBookingEvent(event: WebhookEvent): event is WebsiteBookingEvent;
73
+ /** True for `channel.booking.created`, `.modified` and `.cancelled`: a booking an OTA sent. */
74
+ export declare function isOtaBookingEvent(event: WebhookEvent): event is OtaBookingEvent;
33
75
  export declare class ZimmerStackWebhookError extends Error {
34
76
  /** Why the delivery was refused. Answer 400 and do not act on the body. */
35
77
  readonly reason: "missing_headers" | "stale_timestamp" | "bad_signature" | "bad_body";
@@ -1,7 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZimmerStackWebhookError = void 0;
3
+ exports.ZimmerStackWebhookError = exports.BOOKING_EVENT_TYPES = exports.WEBSITE_BOOKING_EVENT_TYPES = exports.OTA_BOOKING_EVENT_TYPES = void 0;
4
+ exports.isWebsiteBookingEvent = isWebsiteBookingEvent;
5
+ exports.isOtaBookingEvent = isOtaBookingEvent;
4
6
  exports.verifyWebhook = verifyWebhook;
7
+ /**
8
+ * Verifying a webhook ZimmerStack sent you (Standard Webhooks: the `webhook-id`, `webhook-timestamp` and
9
+ * `webhook-signature` headers). Uses Web Crypto, so it runs on Node and on edge runtimes alike.
10
+ */
11
+ /** An OTA booking arrived, changed or was cancelled (through the channel manager). */
12
+ exports.OTA_BOOKING_EVENT_TYPES = ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled"];
13
+ /**
14
+ * A guest booked, or cancelled, on the hotel's own website through ZimmerStack's booking engine. The same
15
+ * booking object as the OTA events, in a family of its own: an endpoint receives these only when it lists
16
+ * the two types. There is no modified event.
17
+ */
18
+ exports.WEBSITE_BOOKING_EVENT_TYPES = ["direct.booking.created", "direct.booking.cancelled"];
19
+ /** Every event whose `data.booking` is a booking, of either family. */
20
+ exports.BOOKING_EVENT_TYPES = [...exports.OTA_BOOKING_EVENT_TYPES, ...exports.WEBSITE_BOOKING_EVENT_TYPES];
21
+ const isType = (list, event) => typeof event?.type === "string" && list.includes(event.type);
22
+ /**
23
+ * True for `direct.booking.created` and `direct.booking.cancelled`: a booking made on the hotel's own
24
+ * website. A PMS that pushes room counts must put it in its own calendar before its next push.
25
+ */
26
+ function isWebsiteBookingEvent(event) {
27
+ return isType(exports.WEBSITE_BOOKING_EVENT_TYPES, event) && Boolean(event.data?.booking);
28
+ }
29
+ /** True for `channel.booking.created`, `.modified` and `.cancelled`: a booking an OTA sent. */
30
+ function isOtaBookingEvent(event) {
31
+ return isType(exports.OTA_BOOKING_EVENT_TYPES, event) && Boolean(event.data?.booking);
32
+ }
5
33
  class ZimmerStackWebhookError extends Error {
6
34
  /** Why the delivery was refused. Answer 400 and do not act on the body. */
7
35
  reason;
@@ -231,10 +231,30 @@ export declare class ZimmerStack {
231
231
  */
232
232
  all: (query?: Omit<NonNullable<Op<"GET /channel-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
233
233
  };
234
+ readonly directBookings: {
235
+ /**
236
+ * Website bookings, in the webhook's shape (`direct.booking.*`), cancellations included. Scope
237
+ * `direct-bookings:read`. Follow `nextCursor`, or use `all`.
238
+ */
239
+ list: (query?: Op<"GET /direct-bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").ChannelBookingsList>;
240
+ get: (bookingId: number, options?: ReadOptions) => Promise<ChannelBooking>;
241
+ /**
242
+ * Every website booking changed since `since`, page by page. A PMS that pushes room counts reads this
243
+ * before a full push, so the sold rooms are in its own calendar first.
244
+ *
245
+ * @example
246
+ * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
247
+ */
248
+ all: (query?: Omit<NonNullable<Op<"GET /direct-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
249
+ };
234
250
  readonly sandbox: {
235
251
  bookings: {
236
252
  list: (options?: ReadOptions) => Promise<import("./generated.js").SandboxBookingsList>;
237
- /** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
253
+ /**
254
+ * Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint.
255
+ * With `otaName: "Website"` it pretends a guest booked on the hotel's own website instead, and the webhook
256
+ * is `direct.booking.created`.
257
+ */
238
258
  create: (body: SandboxBookingCreate, options?: WriteOptions) => Promise<import("./generated.js").SandboxBooking>;
239
259
  cancel: (bookingId: number, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
240
260
  modify: (bookingId: number, body: SandboxBookingModify, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
@@ -546,12 +546,30 @@ export class ZimmerStack {
546
546
  * @example
547
547
  * for await (const booking of zs.channelBookings.all({ since: lastSeen })) save(booking);
548
548
  */
549
- all: (query, options) => this.#allChannelBookings(query, options),
549
+ all: (query, options) => this.#allPages((cursor) => this.channelBookings.list({ limit: 100, ...query, cursor }, options)),
550
550
  };
551
- async *#allChannelBookings(query, options) {
551
+ /* ── bookings guests made on the hotel's own website (our booking engine) ── */
552
+ directBookings = {
553
+ /**
554
+ * Website bookings, in the webhook's shape (`direct.booking.*`), cancellations included. Scope
555
+ * `direct-bookings:read`. Follow `nextCursor`, or use `all`.
556
+ */
557
+ list: (query, options) => this.request("GET /direct-bookings", { query, ...options }),
558
+ get: (bookingId, options) => this.request("GET /direct-bookings/{bookingId}", { path: { bookingId }, ...options }),
559
+ /**
560
+ * Every website booking changed since `since`, page by page. A PMS that pushes room counts reads this
561
+ * before a full push, so the sold rooms are in its own calendar first.
562
+ *
563
+ * @example
564
+ * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
565
+ */
566
+ all: (query, options) => this.#allPages((cursor) => this.directBookings.list({ limit: 100, ...query, cursor }, options)),
567
+ };
568
+ /** Follow a booking list's `nextCursor` to its last page. */
569
+ async *#allPages(read) {
552
570
  let cursor;
553
571
  do {
554
- const page = await this.channelBookings.list({ limit: 100, ...query, cursor }, options);
572
+ const page = await read(cursor);
555
573
  yield* page.items;
556
574
  cursor = page.nextCursor ?? undefined;
557
575
  } while (cursor);
@@ -560,7 +578,11 @@ export class ZimmerStack {
560
578
  sandbox = {
561
579
  bookings: {
562
580
  list: (options) => this.request("GET /sandbox/bookings", options),
563
- /** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
581
+ /**
582
+ * Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint.
583
+ * With `otaName: "Website"` it pretends a guest booked on the hotel's own website instead, and the webhook
584
+ * is `direct.booking.created`.
585
+ */
564
586
  create: (body, options) => this.request("POST /sandbox/bookings", { body, ...options }),
565
587
  cancel: (bookingId, options) => this.request("POST /sandbox/bookings/{bookingId}/cancel", { path: { bookingId }, ...options }),
566
588
  modify: (bookingId, body, options) => this.request("POST /sandbox/bookings/{bookingId}/modify", { path: { bookingId }, body, ...options }),
@@ -1,5 +1,5 @@
1
1
  /** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
2
- export declare const SDK_VERSION = "0.2.0";
2
+ export declare const SDK_VERSION = "0.3.0";
3
3
  /** Where the API lives. The key is sent nowhere else. */
4
4
  export declare const API_ORIGIN = "https://api.zimmerstack.com";
5
5
  export declare const API_PREFIX = "/api/v1/connect-api/v1";
@@ -28,7 +28,7 @@ export declare const LIMITS: {
28
28
  export declare const ERROR_CODES: readonly ["API_KEY_INVALID", "API_KEY_REVOKED", "API_KEY_EXPIRED", "CONNECT_API_NOT_CONFIGURED", "IP_NOT_ALLOWED", "SCOPE_MISSING", "PROPERTY_UNAVAILABLE", "CHANNEL_MANAGER_DISABLED", "PMS_NOT_AVAILABLE", "VALIDATION", "RANGE_INVALID", "HORIZON", "TOO_MANY_UPDATES", "TOO_MANY_CELLS", "UNKNOWN_ROOM_TYPE", "UNKNOWN_RATE_PLAN", "CURRENCY_MISMATCH", "RATE_LIMITED", "NOTHING_ACCEPTED", "BATCH_NOT_FOUND", "IDEMPOTENCY_KEY_INVALID", "IDEMPOTENCY_KEY_REUSED", "IDEMPOTENCY_IN_FLIGHT", "STAY_INVALID", "UNKNOWN_ROOM_TYPE_FOR_PLAN", "OCCUPANCY_EXCEEDED", "NO_AVAILABILITY", "EXTERNAL_REFERENCE_REUSED", "PAYMENT_NOT_ALLOWED", "PAYMENT_EXCEEDS_TOTAL", "BOOKING_NOT_FOUND", "BOOKING_NOT_CANCELLABLE", "MODULE_NOT_ENTITLED", "SANDBOX_ONLY", "ROOM_TYPE_NOT_FOUND", "RATE_PLAN_NOT_FOUND", "CATALOG_CONFLICT", "CATALOG_BUSY", "CHANNEL_MANAGER_ERROR", "PROPERTY_REQUIRED", "PROPERTY_NOT_FOUND", "ARI_NOT_AUTHORITATIVE", "ROUTE_NOT_FOUND", "PAYLOAD_TOO_LARGE", "AUTH_BACKEND_UNAVAILABLE", "BOOKING_NOT_MODIFIABLE", "SANDBOX_NOT_FOUND", "SANDBOX_INCOMPLETE", "WRITES_FROZEN", "WRITES_SUSPENDED", "SHIELD_UNAVAILABLE", "CATALOG_LIMIT_REACHED", "TOO_MANY_NEW_ENTITIES", "RATE_OUT_OF_BAND", "CHANNEL_NOT_FOUND", "CHANNEL_SHARED", "MODIFIER_OUT_OF_BAND"];
29
29
  export type ErrorCode = (typeof ERROR_CODES)[number];
30
30
  /** What a key may do. The hotel's owner (or, for a vendor's key, the vendor) chose them when the key was made. */
31
- export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
31
+ export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "direct-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
32
32
  export type Scope = (typeof SCOPES)[number];
33
33
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
34
34
  export declare const MODIFIER_TAKES_EFFECT = "A modifier applies to prices sent to the channel after the change. Prices already on the channel stay as they are until those nights are sent again.";
@@ -585,9 +585,9 @@ export interface SandboxBookingCreate {
585
585
  adults?: number;
586
586
  /** The guest's name; default a fictional one */
587
587
  guestName?: string;
588
- /** The channel the booking pretends to arrive from; default Booking.com */
589
- otaName?: "Booking.com" | "Expedia" | "Agoda" | "Airbnb" | "MakeMyTrip" | "Goibibo";
590
- /** true = the channel collected the money, so totalPaid equals the total; default false (pay at the property) */
588
+ /** The channel the booking pretends to arrive from; default Booking.com. "Website" simulates a booking on the hotel's own website (our booking engine): it sends direct.booking.created and is listed by GET /direct-bookings, not GET /channel-bookings */
589
+ otaName?: "Booking.com" | "Expedia" | "Agoda" | "Airbnb" | "MakeMyTrip" | "Goibibo" | "Website";
590
+ /** true = the channel collected the money (for Website: the guest paid online), so totalPaid equals the total; default false (pay at the property) */
591
591
  paidByOta?: boolean;
592
592
  }
593
593
  export interface SandboxBookingModify {
@@ -872,13 +872,13 @@ export interface SandboxBooking {
872
872
  createdAt: string;
873
873
  /** What this call put on the wire for the sandbox's webhook endpoints */
874
874
  webhook: {
875
- eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled";
875
+ eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled" | "direct.booking.created" | "direct.booking.cancelled";
876
876
  /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */
877
877
  queued: boolean;
878
878
  };
879
879
  }
880
880
  export interface SandboxBookingsList {
881
- /** Simulated OTA bookings on the sandbox, newest first */
881
+ /** Simulated bookings on the sandbox (OTA and website), newest first */
882
882
  bookings: Array<{
883
883
  /** The PMS booking id, the one the webhook carries */
884
884
  bookingId: number;
@@ -905,7 +905,7 @@ export interface SandboxBookingsList {
905
905
  createdAt: string;
906
906
  /** What this call put on the wire for the sandbox's webhook endpoints */
907
907
  webhook: {
908
- eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled";
908
+ eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled" | "direct.booking.created" | "direct.booking.cancelled";
909
909
  /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */
910
910
  queued: boolean;
911
911
  };
@@ -1103,6 +1103,27 @@ export interface Operations {
1103
1103
  body: undefined;
1104
1104
  response: ChannelBooking;
1105
1105
  };
1106
+ /** The bookings guests made on the hotel's own website, in the webhook's shape */
1107
+ "GET /direct-bookings": {
1108
+ path: undefined;
1109
+ query: {
1110
+ since?: string;
1111
+ status?: "CONFIRMED" | "CANCELLED";
1112
+ limit?: number;
1113
+ cursor?: string;
1114
+ };
1115
+ body: undefined;
1116
+ response: ChannelBookingsList;
1117
+ };
1118
+ /** One website booking, the webhook's shape */
1119
+ "GET /direct-bookings/{bookingId}": {
1120
+ path: {
1121
+ bookingId: string | number;
1122
+ };
1123
+ query: undefined;
1124
+ body: undefined;
1125
+ response: ChannelBooking;
1126
+ };
1106
1127
  /** Simulated OTA bookings on the sandbox, newest first */
1107
1128
  "GET /sandbox/bookings": {
1108
1129
  path: undefined;
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/generate.mjs from the Connect API's public contract (ZimmerStack Connect API v1).
2
2
  // Do not edit: change the contract, then run `pnpm --dir apps/connect-sdk run generate`.
3
3
  /** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
4
- export const SDK_VERSION = "0.2.0";
4
+ export const SDK_VERSION = "0.3.0";
5
5
  /** Where the API lives. The key is sent nowhere else. */
6
6
  export const API_ORIGIN = "https://api.zimmerstack.com";
7
7
  export const API_PREFIX = "/api/v1/connect-api/v1";
@@ -93,6 +93,7 @@ export const SCOPES = [
93
93
  "catalog:write",
94
94
  "channel-modifiers:write",
95
95
  "channel-bookings:read",
96
+ "direct-bookings:read",
96
97
  "bookings:read",
97
98
  "bookings:write",
98
99
  "bookings:payments"
@@ -124,6 +125,8 @@ export const OPERATIONS = {
124
125
  "POST /rates/resend": { idempotent: true, bodyRequired: false },
125
126
  "GET /channel-bookings": { idempotent: false, bodyRequired: false },
126
127
  "GET /channel-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
128
+ "GET /direct-bookings": { idempotent: false, bodyRequired: false },
129
+ "GET /direct-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
127
130
  "GET /sandbox/bookings": { idempotent: false, bodyRequired: false },
128
131
  "POST /sandbox/bookings": { idempotent: true, bodyRequired: true },
129
132
  "POST /sandbox/bookings/{bookingId}/cancel": { idempotent: false, bodyRequired: false },
@@ -10,7 +10,7 @@ export { ZimmerStackError, ZimmerStackUsageError } from "./errors.js";
10
10
  export type { LocalErrorCode } from "./errors.js";
11
11
  export { addDays, buildGrid, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
12
12
  export type { Grid, GridEdits, ModifierStep, Range, Restrictions } from "./grid.js";
13
- export { verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
14
- export type { WebhookEvent } from "./webhooks.js";
13
+ export { BOOKING_EVENT_TYPES, OTA_BOOKING_EVENT_TYPES, WEBSITE_BOOKING_EVENT_TYPES, isOtaBookingEvent, isWebsiteBookingEvent, verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
14
+ export type { BookingEvent, BookingEventType, OtaBookingEvent, OtaBookingEventType, WebhookEvent, WebhookEventType, WebsiteBookingEvent, WebsiteBookingEventType } from "./webhooks.js";
15
15
  export { ERROR_CODES, LIMITS, MODIFIER_TAKES_EFFECT, SCOPES, SDK_VERSION } from "./generated.js";
16
16
  export type * from "./generated.js";
package/dist/esm/index.js CHANGED
@@ -7,5 +7,5 @@
7
7
  export { ZimmerStack } from "./client.js";
8
8
  export { ZimmerStackError, ZimmerStackUsageError } from "./errors.js";
9
9
  export { addDays, buildGrid, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
10
- export { verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
10
+ export { BOOKING_EVENT_TYPES, OTA_BOOKING_EVENT_TYPES, WEBSITE_BOOKING_EVENT_TYPES, isOtaBookingEvent, isWebsiteBookingEvent, verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
11
11
  export { ERROR_CODES, LIMITS, MODIFIER_TAKES_EFFECT, SCOPES, SDK_VERSION } from "./generated.js";
@@ -2,7 +2,7 @@
2
2
  // Do not edit: change the contract, then run `pnpm --dir apps/connect-sdk run generate`.
3
3
  // What the package's MCP server (src/mcp) answers lookups from. It is not part of the client's own exports.
4
4
  /** The rules file this package ships (AGENTS.md), for the zimmerstack_rules tool. */
5
- export const RULES = "# Building on @zimmerstack/connect: rules for coding agents\n\nYou are writing code that calls the ZimmerStack Connect API through its official package. A write\nthrough it changes a real hotel's prices and rooms on every booking site it sells on. The package\nenforces most of the API's rules for you; this file is the rest. Keep it in the repository (as\nAGENTS.md or CLAUDE.md) and follow it. The whole API reference, in one file an agent can read:\nhttps://docs.zimmerstack.com/llms-full.txt\n\n## The key\n\n- It lives in the environment variable `ZIMMERSTACK_CONNECT_KEY` on a server. Never write it into a\n file that is committed, a log line, an error message, a URL, a test fixture or anything a browser\n or a mobile app receives. Never print it. `new ZimmerStack()` reads it by itself.\n- The package refuses to start in a browser or in React Native. Do not work around that: the\n person's own frontend calls their own server, and the server calls ZimmerStack. Never put the key in\n a variable a bundler sends to the browser (`VITE_`, `NEXT_PUBLIC_`, `REACT_APP_`, `EXPO_PUBLIC_`).\n An app with no server gets the smallest one: https://docs.zimmerstack.com/sdk#no-server. A plain\n `fetch` from a browser is refused too (\"Failed to fetch\"), on purpose.\n- `zsk_test_…` is a sandbox: nothing reaches a channel. Build and test with it. `zsk_live_…` is a real\n hotel. The package refuses to WRITE with a live key under a test runner; never switch that off to\n make a test pass.\n- A software vendor's company key acts on one hotel at a time: `zs.forProperty(propertyId)`\n (`zs.properties.list()` names them), or `ZIMMERSTACK_PROPERTY_ID` in the environment for an app that\n serves one hotel. A test company key that reaches one sandbox finds it by itself; with several,\n name one; a live key never guesses.\n- No key yet: a software company signs up, free, at https://www.zimmerstack.com/partners/pms-companies#join\n and makes test keys in the partner portal (Developers); a hotel's owner makes one in Admin →\n Developers → API keys.\n\n## Let the package pace; never work around it\n\n- It reads the `RateLimit` header and slows down before a budget runs out, sends writes one at a\n time, retries only what passes with time (429, 5xx, a network failure) under the same idempotency\n key, and gives up with a `ZimmerStackError` otherwise. Do not wrap its calls in your own retry\n loop, and never resend a 4xx other than 429: it is a verdict on the request. Fix the request.\n- Per minute: 120 requests and 30 writes per key; 300 and 60 for all of a hotel's keys together.\n A hotel also has budgets per hour and per day that count CHANGED cells (at least 10,000 an hour, 30,000\n a day). Hitting one is `error.code === \"RATE_LIMITED\"` with `error.retryAfterSeconds`: tell the\n person when to try again; do not sleep through an hour.\n- One instance per process (`new ZimmerStack()` once, in a module). Two instances do not share a pace.\n- Never write on a timer, in a loop over all nights, or \"to be safe\". Send what a person changed,\n when they changed it: `zs.grid.save(edits)` folds nights into ranges and splits a large save.\n- Do not poll faster than every 15 seconds (`zs.batches.wait` already does it right), and stop.\n\n## Money and dates\n\n- A price is SENT in major units (4500 = 4,500.00 of the hotel's own currency) with that currency, and READ in minor\n units (`rateMinor`). `zs.grid.load` gives major units; `zs.grid.save` takes them.\n- A date is a plain `YYYY-MM-DD` calendar day in the hotel's timezone. Never build one with\n `new Date()` arithmetic in local time; use `eachDate(from, to)`.\n- To close a night send `stopSell: true`. Never a zero price, never zero rooms as a substitute.\n- Writes may reach 365 days ahead. A write is accepted (202) when it is in ZimmerStack's record; it\n reaches the channels in seconds to minutes. `zs.sync.get()` says how far along it is.\n\n## A channel's price modifier\n\n- `zs.channels.setModifier(channelId, steps)` moves EVERY price sent to that channel from then on.\n Call it only when a person saved that setting on a screen. Never from a loop, a timer, a seed\n script or a test against a live key. A hotel may change modifiers 6 times a day.\n- A modifier applies to prices sent to the channel after the change. Prices already on the channel stay as they are until those nights are sent again.\n Show that sentence where the person saves (`MODIFIER_TAKES_EFFECT`), and offer\n `zs.rates.resend()` as a separate, deliberate button (\"Apply to nights already on sale\"): 3 a day\n per hotel, never automatic.\n- Keep the grid on the price before any modifier; show a channel's price beside it with\n `channelPrice(rate, steps)`.\n\n## Errors\n\n```ts\nimport { ZimmerStack, ZimmerStackError } from \"@zimmerstack/connect\";\n\ntry {\n await zs.rates.set(updates);\n} catch (err) {\n if (err instanceof ZimmerStackError) {\n // err.code is stable (RATE_LIMITED, RATE_OUT_OF_BAND, SCOPE_MISSING, …); err.message is for people.\n // Show err.message to the person; branch on err.code; never retry unless err.retryable.\n }\n throw err;\n}\n```\n\n- `SCOPE_MISSING`: the key was not given that permission. Say which one is missing; the hotel's\n owner grants it (Admin → Developers → API keys). Do not look for another route.\n- `API_KEY_INVALID`, `API_KEY_REVOKED`, `API_KEY_EXPIRED`: stop. The client refuses every later call\n by itself; repeated bad calls get the server's address refused.\n- `RATE_OUT_OF_BAND`, `MODIFIER_OUT_OF_BAND`: the value is outside what the hotel allows. It is a\n guard against a typing slip; show the message, never split the change into smaller steps to pass.\n\n## The MCP server\n\nThe package carries an MCP server for you, the agent: `npx -y @zimmerstack/connect mcp`. If it is\nconnected, use it instead of guessing: `zimmerstack_reference` looks up any operation, type, limit\nor error code from the API's own contract, and `zimmerstack_sandbox_read` /\n`zimmerstack_sandbox_write` make one call on the sandbox so you can see real ids and try a body\nbefore you write the code that sends it. It works with a `zsk_test_` key only and refuses a live\none. It is for building; the application you write calls the API through the client, never through\nthese tools.\n\n## Before you call the work done\n\n- [ ] The key is read from the environment, on a server, and appears in no committed file or log.\n- [ ] Every screen that writes sends only what the person changed, once, on their action.\n- [ ] No retry loop, no timer and no polling faster than 15 seconds around a call of this package.\n- [ ] Errors show `err.message` to the person and branch on `err.code`.\n- [ ] Tests run against a `zsk_test_` key or a fake `fetch`; none needs a live key.\n- [ ] Where a modifier is saved, the screen says when it takes effect, and the re-send is its own button.\n";
5
+ export const RULES = "# Building on @zimmerstack/connect: rules for coding agents\n\nYou are writing code that calls the ZimmerStack Connect API through its official package. A write\nthrough it changes a real hotel's prices and rooms on every booking site it sells on. The package\nenforces most of the API's rules for you; this file is the rest. Keep it in the repository (as\nAGENTS.md or CLAUDE.md) and follow it. The whole API reference, in one file an agent can read:\nhttps://docs.zimmerstack.com/llms-full.txt\n\n## The key\n\n- It lives in the environment variable `ZIMMERSTACK_CONNECT_KEY` on a server. Never write it into a\n file that is committed, a log line, an error message, a URL, a test fixture or anything a browser\n or a mobile app receives. Never print it. `new ZimmerStack()` reads it by itself.\n- The package refuses to start in a browser or in React Native. Do not work around that: the\n person's own frontend calls their own server, and the server calls ZimmerStack. Never put the key in\n a variable a bundler sends to the browser (`VITE_`, `NEXT_PUBLIC_`, `REACT_APP_`, `EXPO_PUBLIC_`).\n An app with no server gets the smallest one: https://docs.zimmerstack.com/sdk#no-server. A plain\n `fetch` from a browser is refused too (\"Failed to fetch\"), on purpose.\n- `zsk_test_…` is a sandbox: nothing reaches a channel. Build and test with it. `zsk_live_…` is a real\n hotel. The package refuses to WRITE with a live key under a test runner; never switch that off to\n make a test pass.\n- A software vendor's company key acts on one hotel at a time: `zs.forProperty(propertyId)`\n (`zs.properties.list()` names them), or `ZIMMERSTACK_PROPERTY_ID` in the environment for an app that\n serves one hotel. A test company key that reaches one sandbox finds it by itself; with several,\n name one; a live key never guesses.\n- No key yet: a software company signs up, free, at https://www.zimmerstack.com/partners/pms-companies#join\n and makes test keys in the partner portal (Developers); a hotel's owner makes one in Admin →\n Developers → API keys.\n\n## Let the package pace; never work around it\n\n- It reads the `RateLimit` header and slows down before a budget runs out, sends writes one at a\n time, retries only what passes with time (429, 5xx, a network failure) under the same idempotency\n key, and gives up with a `ZimmerStackError` otherwise. Do not wrap its calls in your own retry\n loop, and never resend a 4xx other than 429: it is a verdict on the request. Fix the request.\n- Per minute: 120 requests and 30 writes per key; 300 and 60 for all of a hotel's keys together.\n A hotel also has budgets per hour and per day that count CHANGED cells (at least 10,000 an hour, 30,000\n a day). Hitting one is `error.code === \"RATE_LIMITED\"` with `error.retryAfterSeconds`: tell the\n person when to try again; do not sleep through an hour.\n- One instance per process (`new ZimmerStack()` once, in a module). Two instances do not share a pace.\n- Never write on a timer, in a loop over all nights, or \"to be safe\". Send what a person changed,\n when they changed it: `zs.grid.save(edits)` folds nights into ranges and splits a large save.\n- Do not poll faster than every 15 seconds (`zs.batches.wait` already does it right), and stop.\n\n## Money and dates\n\n- A price is SENT in major units (4500 = 4,500.00 of the hotel's own currency) with that currency, and READ in minor\n units (`rateMinor`). `zs.grid.load` gives major units; `zs.grid.save` takes them.\n- A date is a plain `YYYY-MM-DD` calendar day in the hotel's timezone. Never build one with\n `new Date()` arithmetic in local time; use `eachDate(from, to)`.\n- To close a night send `stopSell: true`. Never a zero price, never zero rooms as a substitute.\n- Writes may reach 365 days ahead. A write is accepted (202) when it is in ZimmerStack's record; it\n reaches the channels in seconds to minutes. `zs.sync.get()` says how far along it is.\n\n## A channel's price modifier\n\n- `zs.channels.setModifier(channelId, steps)` moves EVERY price sent to that channel from then on.\n Call it only when a person saved that setting on a screen. Never from a loop, a timer, a seed\n script or a test against a live key. A hotel may change modifiers 6 times a day.\n- A modifier applies to prices sent to the channel after the change. Prices already on the channel stay as they are until those nights are sent again.\n Show that sentence where the person saves (`MODIFIER_TAKES_EFFECT`), and offer\n `zs.rates.resend()` as a separate, deliberate button (\"Apply to nights already on sale\"): 3 a day\n per hotel, never automatic.\n- Keep the grid on the price before any modifier; show a channel's price beside it with\n `channelPrice(rate, steps)`.\n\n## Website bookings: apply them before you push room counts\n\n- When the hotel also sells on its own website through ZimmerStack's booking engine, those bookings\n reach you as the webhooks `direct.booking.created` and `direct.booking.cancelled` (the endpoint must\n list those two types) and by `zs.directBookings.all({ since })` (scope `direct-bookings:read`). They\n are not OTA bookings: `isWebsiteBookingEvent(event)` tells them apart, `channel.otaName` is `\"Website\"`\n and `finance` is null. There is no modified event.\n- A website booking takes one room off the count the channels hold, at once. A PMS that pushes absolute\n room counts must apply the booking to its own calendar BEFORE its next `zs.availability.set` or\n `zs.grid.save`, or that push puts the sold room back on sale. Read `zs.directBookings.all` before a\n full push. Nothing on our side stops the count from going up.\n- You cannot cancel a website booking through this package: the guest cancels on the booking page, or\n the hotel does in ZimmerStack.\n\n## Errors\n\n```ts\nimport { ZimmerStack, ZimmerStackError } from \"@zimmerstack/connect\";\n\ntry {\n await zs.rates.set(updates);\n} catch (err) {\n if (err instanceof ZimmerStackError) {\n // err.code is stable (RATE_LIMITED, RATE_OUT_OF_BAND, SCOPE_MISSING, …); err.message is for people.\n // Show err.message to the person; branch on err.code; never retry unless err.retryable.\n }\n throw err;\n}\n```\n\n- `SCOPE_MISSING`: the key was not given that permission. Say which one is missing; the hotel's\n owner grants it (Admin → Developers → API keys). Do not look for another route.\n- `API_KEY_INVALID`, `API_KEY_REVOKED`, `API_KEY_EXPIRED`: stop. The client refuses every later call\n by itself; repeated bad calls get the server's address refused.\n- `RATE_OUT_OF_BAND`, `MODIFIER_OUT_OF_BAND`: the value is outside what the hotel allows. It is a\n guard against a typing slip; show the message, never split the change into smaller steps to pass.\n\n## The MCP server\n\nThe package carries an MCP server for you, the agent: `npx -y @zimmerstack/connect mcp`. If it is\nconnected, use it instead of guessing: `zimmerstack_reference` looks up any operation, type, limit\nor error code from the API's own contract, and `zimmerstack_sandbox_read` /\n`zimmerstack_sandbox_write` make one call on the sandbox so you can see real ids and try a body\nbefore you write the code that sends it. It works with a `zsk_test_` key only and refuses a live\none. It is for building; the application you write calls the API through the client, never through\nthese tools.\n\n## Before you call the work done\n\n- [ ] The key is read from the environment, on a server, and appears in no committed file or log.\n- [ ] Every screen that writes sends only what the person changed, once, on their action.\n- [ ] No retry loop, no timer and no polling faster than 15 seconds around a call of this package.\n- [ ] Errors show `err.message` to the person and branch on `err.code`.\n- [ ] Tests run against a `zsk_test_` key or a fake `fetch`; none needs a live key.\n- [ ] Where a modifier is saved, the screen says when it takes effect, and the re-send is its own button.\n- [ ] A PMS that pushes room counts applies every website booking to its own calendar before it pushes.\n";
6
6
  export const REFERENCE = {
7
7
  "api": "ZimmerStack Connect API v1",
8
8
  "base": "https://api.zimmerstack.com/api/v1/connect-api/v1",
@@ -1753,6 +1753,236 @@ export const REFERENCE = {
1753
1753
  }
1754
1754
  ]
1755
1755
  },
1756
+ {
1757
+ "key": "GET /direct-bookings",
1758
+ "summary": "The bookings guests made on the hotel's own website, in the webhook's shape",
1759
+ "description": "Scope direct-bookings:read. The bookings of the ZimmerStack booking engine on this property: the pull beside the direct.booking.* webhooks (x-zimmerstack.directBookings). Oldest change first; since (default the last 7 days) is on the booking's last change so a cancellation is listed again; while more is true, ask again with cursor = nextCursor. A booking deleted in ZimmerStack stays listed, as CANCELLED. Read it before a full availability push.",
1760
+ "scope": "direct-bookings:read",
1761
+ "call": "zs.directBookings.list(query)",
1762
+ "path": [],
1763
+ "query": [
1764
+ {
1765
+ "name": "since",
1766
+ "required": false,
1767
+ "type": "string",
1768
+ "description": "Changed on or after this instant (ISO 8601); default: the last 7 days"
1769
+ },
1770
+ {
1771
+ "name": "status",
1772
+ "required": false,
1773
+ "type": "\"CONFIRMED\" | \"CANCELLED\"",
1774
+ "description": "Only confirmed or only cancelled; default both"
1775
+ },
1776
+ {
1777
+ "name": "limit",
1778
+ "required": false,
1779
+ "type": "number",
1780
+ "description": "Default 50"
1781
+ },
1782
+ {
1783
+ "name": "cursor",
1784
+ "required": false,
1785
+ "type": "string",
1786
+ "description": "The previous page's nextCursor; takes precedence over since. One this API did not issue is 400 VALIDATION"
1787
+ }
1788
+ ],
1789
+ "body": null,
1790
+ "response": "ChannelBookingsList",
1791
+ "answerStatus": [
1792
+ 200
1793
+ ],
1794
+ "idempotent": false,
1795
+ "request": null,
1796
+ "answer": {
1797
+ "since": "2026-10-23T12:00:00.000Z",
1798
+ "items": [
1799
+ {
1800
+ "id": 100001,
1801
+ "reference": "TEST-WEB-4H7P9D",
1802
+ "status": "CONFIRMED",
1803
+ "stayStatus": "UPCOMING",
1804
+ "channel": {
1805
+ "otaName": "Website",
1806
+ "otaReservationCode": "TEST-WEB-4H7P9D",
1807
+ "source": "DIRECT_WEB",
1808
+ "sourceGroup": "DIRECT"
1809
+ },
1810
+ "stay": {
1811
+ "checkIn": "2026-11-13",
1812
+ "checkOut": "2026-11-15",
1813
+ "nights": 2,
1814
+ "dayUse": false
1815
+ },
1816
+ "guest": {
1817
+ "fullName": "Asha Verma",
1818
+ "firstName": "Asha",
1819
+ "lastName": "Verma",
1820
+ "phone": "+919876500000",
1821
+ "email": "asha.verma@example.com",
1822
+ "country": "IN",
1823
+ "language": "en"
1824
+ },
1825
+ "guestNotes": null,
1826
+ "occupancy": {
1827
+ "adults": 2,
1828
+ "children": 0
1829
+ },
1830
+ "rooms": [
1831
+ {
1832
+ "roomTypeId": 412,
1833
+ "ratePlanId": 901,
1834
+ "roomTypeName": "Deluxe Sea View",
1835
+ "mealPlan": "CP",
1836
+ "adults": 2,
1837
+ "children": 0,
1838
+ "checkIn": "2026-11-13",
1839
+ "checkOut": "2026-11-15",
1840
+ "nights": 2,
1841
+ "dayUse": false,
1842
+ "ratePerNight": 2700,
1843
+ "amount": 5400,
1844
+ "status": "UPCOMING"
1845
+ }
1846
+ ],
1847
+ "amounts": {
1848
+ "currency": "INR",
1849
+ "total": 5400,
1850
+ "paid": 1080,
1851
+ "balanceDue": 4320,
1852
+ "paymentCollect": "property"
1853
+ },
1854
+ "finance": null,
1855
+ "cancellation": null,
1856
+ "createdAt": "2026-10-30T12:00:00.000Z",
1857
+ "updatedAt": "2026-10-30T12:00:00.000Z"
1858
+ }
1859
+ ],
1860
+ "more": false,
1861
+ "nextCursor": null
1862
+ },
1863
+ "refusals": [
1864
+ {
1865
+ "status": 401,
1866
+ "description": "Missing, malformed, unknown or revoked key (data.code API_KEY_INVALID | API_KEY_REVOKED)"
1867
+ },
1868
+ {
1869
+ "status": 403,
1870
+ "description": "The key lacks the scope this route needs (SCOPE_MISSING, details.needed / details.held), or the request came from outside the key's address allowlist (IP_NOT_ALLOWED)"
1871
+ },
1872
+ {
1873
+ "status": 404,
1874
+ "description": "X-ZS-Property names a property this key may not act on (PROPERTY_NOT_FOUND): for a company key, one outside its hotels; for a hotel key, any other property. A company key without the header is 400 PROPERTY_REQUIRED"
1875
+ },
1876
+ {
1877
+ "status": 409,
1878
+ "description": "The property is deleted or demo (PROPERTY_UNAVAILABLE); on an ARI route its channel manager is off (CHANNEL_MANAGER_DISABLED), or, on a company key, its rates are not the source of truth (ARI_NOT_AUTHORITATIVE); on a booking route it has no PMS (PMS_NOT_AVAILABLE)"
1879
+ },
1880
+ {
1881
+ "status": 429,
1882
+ "description": "A budget was exhausted — data.scope names it (ip · ip-auth · requests · writes · property · property-writes · cells · company · global, or one of the long budgets of x-zimmerstack.shield); honour Retry-After and pace on the RateLimit header (x-zimmerstack.rateLimits)"
1883
+ }
1884
+ ]
1885
+ },
1886
+ {
1887
+ "key": "GET /direct-bookings/{bookingId}",
1888
+ "summary": "One website booking, the webhook's shape",
1889
+ "description": "Scope direct-bookings:read. 404 for a booking that is not this property's or was not made on its website.",
1890
+ "scope": "direct-bookings:read",
1891
+ "call": "zs.directBookings.get(bookingId)",
1892
+ "path": [
1893
+ "bookingId"
1894
+ ],
1895
+ "query": [],
1896
+ "body": null,
1897
+ "response": "ChannelBooking",
1898
+ "answerStatus": [
1899
+ 200
1900
+ ],
1901
+ "idempotent": false,
1902
+ "request": null,
1903
+ "answer": {
1904
+ "id": 100001,
1905
+ "reference": "TEST-WEB-4H7P9D",
1906
+ "status": "CONFIRMED",
1907
+ "stayStatus": "UPCOMING",
1908
+ "channel": {
1909
+ "otaName": "Website",
1910
+ "otaReservationCode": "TEST-WEB-4H7P9D",
1911
+ "source": "DIRECT_WEB",
1912
+ "sourceGroup": "DIRECT"
1913
+ },
1914
+ "stay": {
1915
+ "checkIn": "2026-11-13",
1916
+ "checkOut": "2026-11-15",
1917
+ "nights": 2,
1918
+ "dayUse": false
1919
+ },
1920
+ "guest": {
1921
+ "fullName": "Asha Verma",
1922
+ "firstName": "Asha",
1923
+ "lastName": "Verma",
1924
+ "phone": "+919876500000",
1925
+ "email": "asha.verma@example.com",
1926
+ "country": "IN",
1927
+ "language": "en"
1928
+ },
1929
+ "guestNotes": null,
1930
+ "occupancy": {
1931
+ "adults": 2,
1932
+ "children": 0
1933
+ },
1934
+ "rooms": [
1935
+ {
1936
+ "roomTypeId": 412,
1937
+ "ratePlanId": 901,
1938
+ "roomTypeName": "Deluxe Sea View",
1939
+ "mealPlan": "CP",
1940
+ "adults": 2,
1941
+ "children": 0,
1942
+ "checkIn": "2026-11-13",
1943
+ "checkOut": "2026-11-15",
1944
+ "nights": 2,
1945
+ "dayUse": false,
1946
+ "ratePerNight": 2700,
1947
+ "amount": 5400,
1948
+ "status": "UPCOMING"
1949
+ }
1950
+ ],
1951
+ "amounts": {
1952
+ "currency": "INR",
1953
+ "total": 5400,
1954
+ "paid": 1080,
1955
+ "balanceDue": 4320,
1956
+ "paymentCollect": "property"
1957
+ },
1958
+ "finance": null,
1959
+ "cancellation": null,
1960
+ "createdAt": "2026-10-30T12:00:00.000Z",
1961
+ "updatedAt": "2026-10-30T12:00:00.000Z"
1962
+ },
1963
+ "refusals": [
1964
+ {
1965
+ "status": 401,
1966
+ "description": "Missing, malformed, unknown or revoked key (data.code API_KEY_INVALID | API_KEY_REVOKED)"
1967
+ },
1968
+ {
1969
+ "status": 403,
1970
+ "description": "The key lacks the scope this route needs (SCOPE_MISSING, details.needed / details.held), or the request came from outside the key's address allowlist (IP_NOT_ALLOWED)"
1971
+ },
1972
+ {
1973
+ "status": 404,
1974
+ "description": "No website booking with this id on this property; on a company key, PROPERTY_NOT_FOUND when X-ZS-Property names a property it may not act on"
1975
+ },
1976
+ {
1977
+ "status": 409,
1978
+ "description": "The property is deleted or demo (PROPERTY_UNAVAILABLE); on an ARI route its channel manager is off (CHANNEL_MANAGER_DISABLED), or, on a company key, its rates are not the source of truth (ARI_NOT_AUTHORITATIVE); on a booking route it has no PMS (PMS_NOT_AVAILABLE)"
1979
+ },
1980
+ {
1981
+ "status": 429,
1982
+ "description": "A budget was exhausted — data.scope names it (ip · ip-auth · requests · writes · property · property-writes · cells · company · global, or one of the long budgets of x-zimmerstack.shield); honour Retry-After and pace on the RateLimit header (x-zimmerstack.rateLimits)"
1983
+ }
1984
+ ]
1985
+ },
1756
1986
  {
1757
1987
  "key": "GET /sandbox/bookings",
1758
1988
  "summary": "Simulated OTA bookings on the sandbox, newest first",
@@ -2055,7 +2285,7 @@ export const REFERENCE = {
2055
2285
  "BookingsQuery": "export interface BookingsQuery {\n /** Created on or after this instant (ISO 8601); default: the last 7 days */\n since?: string;\n /** Your own reservation id; unique per property. A retried POST with the same value returns the same booking while it is live and yours; after a cancel, a new stay needs a new reference (409 EXTERNAL_REFERENCE_REUSED otherwise) */\n externalReference?: string;\n /** 1 to 100; default 50 */\n limit?: number;\n}",
2056
2286
  "Booking": "export interface Booking {\n bookingId: number;\n reference: string;\n externalReference: string | null;\n status: \"UPCOMING\" | \"INHOUSE\" | \"COMPLETED\" | \"CANCELLED\" | \"NOSHOW\";\n /** Hotel-local calendar date, YYYY-MM-DD */\n checkIn: string;\n /** Hotel-local calendar date, YYYY-MM-DD */\n checkOut: string;\n nights: number;\n currency: string;\n /** MAJOR units, two decimals: the whole stay */\n totalAmount: string;\n /** MAJOR units, two decimals: collected so far */\n totalPaid: string;\n /** MAJOR units, two decimals: owed at the hotel */\n balanceDue: string;\n guest: {\n name: string;\n phone: string;\n email: string | null;\n };\n rooms: Array<{\n bookingRoomId: number;\n roomTypeId: number;\n ratePlanId: number | null;\n mealPlan: \"EP\" | \"CP\" | \"MAP\" | \"AP\";\n adults: number;\n children: number;\n /** MAJOR units, two decimals */\n nightlyRate: string;\n status: \"UPCOMING\" | \"CHECKEDIN\" | \"CHECKEDOUT\" | \"CANCELLED\" | \"NOSHOW\";\n }>;\n inventory: {\n eventRecorded: boolean;\n /** false = this property has no channel manager; nothing is pushed */\n channelManager: boolean;\n pushedBy: \"inventory-drain\";\n };\n replay: boolean;\n createdAt: string;\n cancelledAt: string | null;\n}",
2057
2287
  "BookingsList": "export interface BookingsList {\n since: string;\n items: Array<{\n bookingId: number;\n reference: string;\n externalReference: string | null;\n status: \"UPCOMING\" | \"INHOUSE\" | \"COMPLETED\" | \"CANCELLED\" | \"NOSHOW\";\n /** Hotel-local calendar date, YYYY-MM-DD */\n checkIn: string;\n /** Hotel-local calendar date, YYYY-MM-DD */\n checkOut: string;\n nights: number;\n currency: string;\n /** MAJOR units, two decimals: the whole stay */\n totalAmount: string;\n /** MAJOR units, two decimals: collected so far */\n totalPaid: string;\n /** MAJOR units, two decimals: owed at the hotel */\n balanceDue: string;\n guest: {\n name: string;\n phone: string;\n email: string | null;\n };\n rooms: Array<{\n bookingRoomId: number;\n roomTypeId: number;\n ratePlanId: number | null;\n mealPlan: \"EP\" | \"CP\" | \"MAP\" | \"AP\";\n adults: number;\n children: number;\n /** MAJOR units, two decimals */\n nightlyRate: string;\n status: \"UPCOMING\" | \"CHECKEDIN\" | \"CHECKEDOUT\" | \"CANCELLED\" | \"NOSHOW\";\n }>;\n inventory: {\n eventRecorded: boolean;\n /** false = this property has no channel manager; nothing is pushed */\n channelManager: boolean;\n pushedBy: \"inventory-drain\";\n };\n replay: boolean;\n createdAt: string;\n cancelledAt: string | null;\n }>;\n}",
2058
- "SandboxBookingCreate": "export interface SandboxBookingCreate {\n /** A room type of the sandbox (GET /catalog) */\n roomTypeId: number;\n /** Arrival, YYYY-MM-DD in the property's timezone; today or later, within the horizon */\n checkIn: string;\n /** 1–30; checkout = checkIn + nights */\n nights: number;\n /** Rooms of this type the guest books (1–5); default 1 */\n rooms?: number;\n /** Adults per room; default 2 */\n adults?: number;\n /** The guest's name; default a fictional one */\n guestName?: string;\n /** The channel the booking pretends to arrive from; default Booking.com */\n otaName?: \"Booking.com\" | \"Expedia\" | \"Agoda\" | \"Airbnb\" | \"MakeMyTrip\" | \"Goibibo\";\n /** true = the channel collected the money, so totalPaid equals the total; default false (pay at the property) */\n paidByOta?: boolean;\n}",
2288
+ "SandboxBookingCreate": "export interface SandboxBookingCreate {\n /** A room type of the sandbox (GET /catalog) */\n roomTypeId: number;\n /** Arrival, YYYY-MM-DD in the property's timezone; today or later, within the horizon */\n checkIn: string;\n /** 1–30; checkout = checkIn + nights */\n nights: number;\n /** Rooms of this type the guest books (1–5); default 1 */\n rooms?: number;\n /** Adults per room; default 2 */\n adults?: number;\n /** The guest's name; default a fictional one */\n guestName?: string;\n /** The channel the booking pretends to arrive from; default Booking.com. \"Website\" simulates a booking on the hotel's own website (our booking engine): it sends direct.booking.created and is listed by GET /direct-bookings, not GET /channel-bookings */\n otaName?: \"Booking.com\" | \"Expedia\" | \"Agoda\" | \"Airbnb\" | \"MakeMyTrip\" | \"Goibibo\" | \"Website\";\n /** true = the channel collected the money (for Website: the guest paid online), so totalPaid equals the total; default false (pay at the property) */\n paidByOta?: boolean;\n}",
2059
2289
  "SandboxBookingModify": "export interface SandboxBookingModify {\n /** New arrival, YYYY-MM-DD in the property's timezone; today or later */\n checkIn?: string;\n /** New length of stay, 1–30 */\n nights?: number;\n /** New number of rooms, 1–5 */\n rooms?: number;\n /** New adults per room */\n adults?: number;\n /** The guest renamed, as a channel sometimes does */\n guestName?: string;\n}",
2060
2290
  "Channels": "export interface Channels {\n /** When the connection list was last captured; null when never */\n asOf: string | null;\n channels: Array<{\n /** The channel manager's id for this connection */\n channelId: string;\n /** The channel: BookingCom, Expedia, Agoda, Airbnb, GoMMT, … */\n kind: string;\n /** The connection's title in the channel manager */\n title: string | null;\n /** When our record last saw this connection (the nightly settings sweep) */\n seenAt: string;\n /** Unresolved problems the channel manager reported for this connection */\n openIssues: Array<{\n /** sync_error · rate_error · disconnect_channel · inventory_out_of_sync · … */\n event: string;\n raisedAt: string;\n }>;\n /** This channel's price modifier (§2.8): the steps the channel manager applies, in order, to every price it sends this channel. [] = prices go as they are. null = the channel holds a rule set by hand in the channel manager that this API cannot express; PUT /channels/{channelId}/modifier replaces it */\n modifier: Array<{\n /** Raise or lower what this channel is sent */\n action: \"increase\" | \"decrease\";\n /** percent of the price, or a fixed amount in MAJOR units of the property's currency */\n type: \"percent\" | \"fixed\";\n /** How much: 18 with type percent is 18 %; 200 with type fixed is 200.00 in the property's currency. Always positive: choose decrease instead of a minus sign. Two decimals at most */\n value: number;\n }> | null;\n /** A separate adjustment the owner set for this channel in the ZimmerStack Channels app, applied before the modifier. Read-only here; null = none */\n markupPlan: {\n /** markup: this channel sells a copy of each plan priced a fixed step from it · manual: this channel has prices of its own for some nights */\n mode: \"markup\" | \"manual\";\n direction: \"increase\" | \"decrease\";\n /** Percent of the price, when the step is a percentage */\n percent: number | null;\n /** MAJOR units, when the step is a fixed amount */\n amount: number | null;\n } | null;\n }>;\n /** Unresolved problems not tied to one connection (for example the inventory pipe out of sync) */\n propertyIssues: Array<{\n event: string;\n raisedAt: string;\n }>;\n}",
2061
2291
  "ModifierWrite": "export interface ModifierWrite {\n /** The whole modifier, in the order it is applied; replaces what the channel holds. At most 5 steps. An empty list removes it: prices go to the channel as they are */\n steps: Array<{\n /** Raise or lower what this channel is sent */\n action: \"increase\" | \"decrease\";\n /** percent of the price, or a fixed amount in MAJOR units of the property's currency */\n type: \"percent\" | \"fixed\";\n /** How much: 18 with type percent is 18 %; 200 with type fixed is 200.00 in the property's currency. Always positive: choose decrease instead of a minus sign. Two decimals at most */\n value: number;\n }>;\n}",
@@ -2064,21 +2294,22 @@ export const REFERENCE = {
2064
2294
  "ChannelBookingsQuery": "export interface ChannelBookingsQuery {\n /** Changed (created, modified or cancelled) on or after this instant (ISO 8601); default: the last 7 days */\n since?: string;\n /** Only confirmed (live) or only cancelled bookings; default both */\n status?: \"CONFIRMED\" | \"CANCELLED\";\n /** 1 to 100; default 50 */\n limit?: number;\n /** The previous page's nextCursor: resume exactly after its last item, even when many bookings changed in the same instant. Takes precedence over since */\n cursor?: string;\n}",
2065
2295
  "ChannelBookingsList": "export interface ChannelBookingsList {\n /** The instant the list starts at, echoed */\n since: string;\n /** Oldest change first — exactly the booking object the webhooks carry */\n items: Array<{\n id: number;\n reference: string;\n status: \"CONFIRMED\" | \"CANCELLED\";\n stayStatus: string;\n channel: {\n otaName: string;\n otaReservationCode: string;\n source: string;\n sourceGroup: string;\n };\n stay: {\n checkIn: string;\n checkOut: string;\n nights: number;\n dayUse: boolean;\n };\n guest: {\n fullName: string;\n firstName: string | null;\n lastName: string | null;\n phone?: string | null;\n email?: string | null;\n country: string | null;\n language: string | null;\n };\n guestNotes: string | null;\n occupancy: {\n adults: number;\n children: number;\n };\n rooms: Array<{\n roomTypeId: number;\n roomTypeName: string;\n ratePlanId?: number | null;\n mealPlan: \"EP\" | \"CP\" | \"MAP\" | \"AP\";\n adults: number;\n children: number;\n checkIn: string;\n checkOut: string;\n nights: number;\n dayUse: boolean;\n ratePerNight: number;\n amount: number;\n status: string;\n }>;\n amounts: {\n currency: string;\n total: number;\n paid: number;\n balanceDue: number;\n paymentCollect: \"ota\" | \"property\" | \"unknown\";\n };\n finance: {\n otaName: string;\n amountBasis: string;\n currency: string | null;\n grossAmount: number | null;\n commissionAmount: number | null;\n taxAmount: number | null;\n netPayoutAmount: number | null;\n } | null;\n cancellation: {\n at: string;\n reason: string | null;\n } | null;\n createdAt: string;\n updatedAt: string;\n }>;\n /** More rows matched than limit: ask again with cursor = nextCursor */\n more: boolean;\n /** Pass as cursor for the next page; null when there is no more */\n nextCursor: string | null;\n}",
2066
2296
  "ChannelBooking": "export interface ChannelBooking {\n id: number;\n reference: string;\n status: \"CONFIRMED\" | \"CANCELLED\";\n stayStatus: string;\n channel: {\n otaName: string;\n otaReservationCode: string;\n source: string;\n sourceGroup: string;\n };\n stay: {\n checkIn: string;\n checkOut: string;\n nights: number;\n dayUse: boolean;\n };\n guest: {\n fullName: string;\n firstName: string | null;\n lastName: string | null;\n phone?: string | null;\n email?: string | null;\n country: string | null;\n language: string | null;\n };\n guestNotes: string | null;\n occupancy: {\n adults: number;\n children: number;\n };\n rooms: Array<{\n roomTypeId: number;\n roomTypeName: string;\n ratePlanId?: number | null;\n mealPlan: \"EP\" | \"CP\" | \"MAP\" | \"AP\";\n adults: number;\n children: number;\n checkIn: string;\n checkOut: string;\n nights: number;\n dayUse: boolean;\n ratePerNight: number;\n amount: number;\n status: string;\n }>;\n amounts: {\n currency: string;\n total: number;\n paid: number;\n balanceDue: number;\n paymentCollect: \"ota\" | \"property\" | \"unknown\";\n };\n finance: {\n otaName: string;\n amountBasis: string;\n currency: string | null;\n grossAmount: number | null;\n commissionAmount: number | null;\n taxAmount: number | null;\n netPayoutAmount: number | null;\n } | null;\n cancellation: {\n at: string;\n reason: string | null;\n } | null;\n createdAt: string;\n updatedAt: string;\n}",
2067
- "SandboxBooking": "export interface SandboxBooking {\n /** The PMS booking id, the one the webhook carries */\n bookingId: number;\n /** The booking reference, SBX-… — the webhook's booking.reference */\n reference: string;\n /** The pretend channel-side id */\n channelBookingId: string;\n otaName: string;\n status: \"UPCOMING\" | \"CANCELLED\";\n guestName: string;\n checkIn: string;\n checkOut: string;\n nights: number;\n rooms: number;\n roomTypeId: number;\n /** Major units, per room per night */\n nightlyRate: number;\n /** Major units */\n total: number;\n currency: string;\n paidByOta: boolean;\n /** true when a night had no sandbox availability left — the booking lands anyway, as an OTA booking would */\n oversold: boolean;\n createdAt: string;\n /** What this call put on the wire for the sandbox's webhook endpoints */\n webhook: {\n eventType: \"channel.booking.created\" | \"channel.booking.modified\" | \"channel.booking.cancelled\";\n /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */\n queued: boolean;\n };\n}",
2068
- "SandboxBookingsList": "export interface SandboxBookingsList {\n /** Simulated OTA bookings on the sandbox, newest first */\n bookings: Array<{\n /** The PMS booking id, the one the webhook carries */\n bookingId: number;\n /** The booking reference, SBX-… — the webhook's booking.reference */\n reference: string;\n /** The pretend channel-side id */\n channelBookingId: string;\n otaName: string;\n status: \"UPCOMING\" | \"CANCELLED\";\n guestName: string;\n checkIn: string;\n checkOut: string;\n nights: number;\n rooms: number;\n roomTypeId: number;\n /** Major units, per room per night */\n nightlyRate: number;\n /** Major units */\n total: number;\n currency: string;\n paidByOta: boolean;\n /** true when a night had no sandbox availability left — the booking lands anyway, as an OTA booking would */\n oversold: boolean;\n createdAt: string;\n /** What this call put on the wire for the sandbox's webhook endpoints */\n webhook: {\n eventType: \"channel.booking.created\" | \"channel.booking.modified\" | \"channel.booking.cancelled\";\n /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */\n queued: boolean;\n };\n }>;\n}"
2297
+ "SandboxBooking": "export interface SandboxBooking {\n /** The PMS booking id, the one the webhook carries */\n bookingId: number;\n /** The booking reference, SBX-… — the webhook's booking.reference */\n reference: string;\n /** The pretend channel-side id */\n channelBookingId: string;\n otaName: string;\n status: \"UPCOMING\" | \"CANCELLED\";\n guestName: string;\n checkIn: string;\n checkOut: string;\n nights: number;\n rooms: number;\n roomTypeId: number;\n /** Major units, per room per night */\n nightlyRate: number;\n /** Major units */\n total: number;\n currency: string;\n paidByOta: boolean;\n /** true when a night had no sandbox availability left — the booking lands anyway, as an OTA booking would */\n oversold: boolean;\n createdAt: string;\n /** What this call put on the wire for the sandbox's webhook endpoints */\n webhook: {\n eventType: \"channel.booking.created\" | \"channel.booking.modified\" | \"channel.booking.cancelled\" | \"direct.booking.created\" | \"direct.booking.cancelled\";\n /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */\n queued: boolean;\n };\n}",
2298
+ "SandboxBookingsList": "export interface SandboxBookingsList {\n /** Simulated bookings on the sandbox (OTA and website), newest first */\n bookings: Array<{\n /** The PMS booking id, the one the webhook carries */\n bookingId: number;\n /** The booking reference, SBX-… — the webhook's booking.reference */\n reference: string;\n /** The pretend channel-side id */\n channelBookingId: string;\n otaName: string;\n status: \"UPCOMING\" | \"CANCELLED\";\n guestName: string;\n checkIn: string;\n checkOut: string;\n nights: number;\n rooms: number;\n roomTypeId: number;\n /** Major units, per room per night */\n nightlyRate: number;\n /** Major units */\n total: number;\n currency: string;\n paidByOta: boolean;\n /** true when a night had no sandbox availability left — the booking lands anyway, as an OTA booking would */\n oversold: boolean;\n createdAt: string;\n /** What this call put on the wire for the sandbox's webhook endpoints */\n webhook: {\n eventType: \"channel.booking.created\" | \"channel.booking.modified\" | \"channel.booking.cancelled\" | \"direct.booking.created\" | \"direct.booking.cancelled\";\n /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */\n queued: boolean;\n };\n }>;\n}"
2069
2299
  },
2070
2300
  "topics": {
2071
- "keys": "## auth\nscheme: Authorization: Bearer zsk_live_… (zsk_test_… on a sandbox)\nkeyShape: zsk_live_ (or zsk_test_ on a sandbox) + 43 base64url characters; shown once at creation; a hotel key = one property, a company key = a software vendor's hotels\nnever:\n - query string\n - x-api-key\n - user-api-key\nexpiry: The owner may give a key an end of life (expiresAt); past it every request is 401 API_KEY_EXPIRED, like a revocation. A rotation keeps the life.\nscopes:\n - scope: ari:read · does: Read availability, rates, restrictions and sync state from our record\n - scope: ari:write · does: Set availability, rates and restrictions (pushed to every connected channel)\n - scope: catalog:write · does: Create and change room types and rate plans (created on the channel manager and mirrored there)\n - scope: channel-modifiers:write · does: Set a channel's price modifier: one change moves every price sent to that channel from then on\n - scope: channel-bookings:read · does: Read the OTA bookings the channel manager delivered to this property, in the webhook's shape\n - scope: bookings:read · does: Read bookings this key created\n - scope: bookings:write · does: Create and cancel bookings in the PMS (inventory updates and reaches the channels)\n - scope: bookings:payments · does: Record a payment on a booking it creates (needs bookings:write)\nscopeRule: A key holds the scopes the owner granted at creation (editable later without rotating). Every route names the one scope it needs; a key without it is 403 SCOPE_MISSING. bookings:payments needs bookings:write. GET /property echoes this key's scopes.\nallowlist: Optional per key: up to 20 IPv4/IPv6 addresses or CIDR ranges. Set it to your servers' egress addresses: a request from anywhere else is 403 IP_NOT_ALLOWED, counts against the address's authentication budget, and is shown to the owner.\nwhichKey: Two kinds of key, one API. A HOTEL KEY is bound to one property: the property is implicit and needs no header (an X-ZS-Property naming another property is 404 PROPERTY_NOT_FOUND). A COMPANY KEY belongs to a software vendor and reaches every hotel the vendor may act on: name the hotel on every request with the X-ZS-Property header, its id from GET /properties. GET /properties says which kind you hold (keyKind). Routes, bodies and answers are the same for both.\ncompanyKey:\n header: X-ZS-Property: <property id from GET /properties>\n missingHeader: 400 PROPERTY_REQUIRED (GET /properties is the one route that needs no header)\n notReachable: 404 PROPERTY_NOT_FOUND for a property the key may not act on, whether or not it exists\n reach: A live company key reaches the hotels the vendor enrolled and any hotel whose owner allowed the vendor (Integrations → Software vendors, by the vendor code); the owner can revoke that any time and the key stops reaching the hotel at once. A test company key reaches the vendor's own sandbox only.\n scopes: Channel-manager scopes only: ari:read, ari:write, catalog:write, channel-bookings:read. A hotel's PMS bookings (bookings:*) need that hotel's own key.\n budgets: Each hotel keeps its own per-key and per-property budgets; the company key also has one budget across all its hotels (x-zimmerstack.limits.companyRequestsPerMinute).\n writes: An ARI write to a hotel whose local rates and availability are not the channels' source of truth is 409 ARI_NOT_AUTHORITATIVE (a hotel a vendor enrols is born the source of truth).\n minted: In the ZimmerStack partner portal (Developers), shown once, revoked there.\n webhooks: One company webhook endpoint (partner portal, Developers) receives the booking and sync events of every hotel a live company key reaches; each event names its hotel in property.id. A sandbox endpoint receives the vendor's sandbox. A pause holds events: they are kept (up to 90 days) and sent in order on resume. A suspension (72 hours of failures) drops them; Recover since in the portal replays them, for a hotels endpoint only from hotels that allowed the vendor when the event happened and still do.\n\n",
2301
+ "keys": "## auth\nscheme: Authorization: Bearer zsk_live_… (zsk_test_… on a sandbox)\nkeyShape: zsk_live_ (or zsk_test_ on a sandbox) + 43 base64url characters; shown once at creation; a hotel key = one property, a company key = a software vendor's hotels\nnever:\n - query string\n - x-api-key\n - user-api-key\nexpiry: The owner may give a key an end of life (expiresAt); past it every request is 401 API_KEY_EXPIRED, like a revocation. A rotation keeps the life.\nscopes:\n - scope: ari:read · does: Read availability, rates, restrictions and sync state from our record\n - scope: ari:write · does: Set availability, rates and restrictions (pushed to every connected channel)\n - scope: catalog:write · does: Create and change room types and rate plans (created on the channel manager and mirrored there)\n - scope: channel-modifiers:write · does: Set a channel's price modifier: one change moves every price sent to that channel from then on\n - scope: channel-bookings:read · does: Read the OTA bookings the channel manager delivered to this property, in the webhook's shape\n - scope: direct-bookings:read · does: Read the bookings guests made on the hotel's own website (our booking engine), in the webhook's shape\n - scope: bookings:read · does: Read bookings this key created\n - scope: bookings:write · does: Create and cancel bookings in the PMS (inventory updates and reaches the channels)\n - scope: bookings:payments · does: Record a payment on a booking it creates (needs bookings:write)\nscopeRule: A key holds the scopes the owner granted at creation (editable later without rotating). Every route names the one scope it needs; a key without it is 403 SCOPE_MISSING. bookings:payments needs bookings:write. GET /property echoes this key's scopes.\nallowlist: Optional per key: up to 20 IPv4/IPv6 addresses or CIDR ranges. Set it to your servers' egress addresses: a request from anywhere else is 403 IP_NOT_ALLOWED, counts against the address's authentication budget, and is shown to the owner.\nwhichKey: Two kinds of key, one API. A HOTEL KEY is bound to one property: the property is implicit and needs no header (an X-ZS-Property naming another property is 404 PROPERTY_NOT_FOUND). A COMPANY KEY belongs to a software vendor and reaches every hotel the vendor may act on: name the hotel on every request with the X-ZS-Property header, its id from GET /properties. GET /properties says which kind you hold (keyKind). Routes, bodies and answers are the same for both.\ncompanyKey:\n header: X-ZS-Property: <property id from GET /properties>\n missingHeader: 400 PROPERTY_REQUIRED (GET /properties is the one route that needs no header)\n notReachable: 404 PROPERTY_NOT_FOUND for a property the key may not act on, whether or not it exists\n reach: A live company key reaches the hotels the vendor enrolled and any hotel whose owner allowed the vendor (Integrations → Software vendors, by the vendor code); the owner can revoke that any time and the key stops reaching the hotel at once. A test company key reaches the vendor's own sandbox only.\n scopes: Channel-manager scopes only: ari:read, ari:write, catalog:write, channel-modifiers:write, channel-bookings:read, direct-bookings:read. A hotel's PMS bookings (bookings:*) need that hotel's own key.\n budgets: Each hotel keeps its own per-key and per-property budgets; the company key also has one budget across all its hotels (x-zimmerstack.limits.companyRequestsPerMinute).\n writes: An ARI write to a hotel whose local rates and availability are not the channels' source of truth is 409 ARI_NOT_AUTHORITATIVE (a hotel a vendor enrols is born the source of truth).\n minted: In the ZimmerStack partner portal (Developers), shown once, revoked there.\n webhooks: One company webhook endpoint (partner portal, Developers) receives the booking and sync events of every hotel a live company key reaches; each event names its hotel in property.id. A sandbox endpoint receives the vendor's sandbox. A pause holds events: they are kept (up to 90 days) and sent in order on resume. A suspension (72 hours of failures) drops them; Recover since in the portal replays them, for a hotels endpoint only from hotels that allowed the vendor when the event happened and still do.\n\n",
2072
2302
  "money-and-dates": "## dates\nYYYY-MM-DD, calendar dates in the property's timezone (GET /property); a stay occupies [checkIn, checkOut) — the checkout day is not a night\n\n## money\nrates are SENT in major units with the property's currency and RETURNED in minor units (rateMinor); stored as whole major units\n\n## writes\nabsolute values, last write wins within a request, unchanged cells are dropped before anything is written\n\n## idempotency\nheader: x-idempotency-key\nretentionDays: 7\n\n",
2073
2303
  "limits": "## limits\nrequestsPerMinute: 120\nwritesPerMinute: 30\npropertyRequestsPerMinute: 300\npropertyWritesPerMinute: 60\npropertyCellsPerMinute: 20000\nipRequestsPerMinute: 240\nmaxUpdatesPerRequest: 1000\nmaxCellsPerRequest: 5000\nmaxBodyBytes: 1048576\nhorizonDays: 365\nbookingsPerMinute: 20\npropertyBookingsPerMinute: 40\npropertyBookingsPerDay: 500\ncompanyRequestsPerMinute: 1200\nmaxNightsPerBooking: 90\n\n## rateLimits\nwindow: 60 s sliding, shared by every API machine; counters are exact, not per machine\nscopes:\n - scope: ip · perMinute: 240 · counts: every request from one address, checked before the key is read\n - scope: ip-auth · perMinute: 20 · counts: 401 answers to one address; after that the address is refused before any lookup\n - scope: requests · perMinute: 120 · counts: every request on one key\n - scope: writes · perMinute: 30 · counts: PUT requests on one key\n - scope: property · perMinute: 300 · counts: every request on all of a property's keys together (five keys are not five budgets)\n - scope: property-writes · perMinute: 60 · counts: PUT requests on all of a property's keys together\n - scope: cells · perMinute: 20000 · counts: cells a property's writes name after range expansion, charged before anything is read or written\n - scope: bookings · perMinute: 20 · counts: POST /bookings on one key\n - scope: property-bookings · perMinute: 40 · counts: POST /bookings on all of a property's keys together\n - scope: property-bookings-day · perMinute: 500 · counts: POST /bookings per property per ROLLING 24 HOURS (not per minute); the owner can raise it per property\n - scope: company · perMinute: 1200 · counts: every request on one company key, across all its hotels (each hotel keeps its own key and property budgets too)\n - scope: global · perMinute: 3000 · counts: every request on the Connect API, all keys and addresses\nheaders:\n RateLimit-Policy: on every answer, one quoted policy per key scope — \"key\";q=120;w=60, \"key-writes\";q=30;w=60\n RateLimit: on every answer, what is left and when it refills — \"key\";r=117;t=42, \"key-writes\";r=29;t=42\n Retry-After: on every 429, whole seconds to wait; the body's data.scope says which budget refused\nonRefusal: 429 RATE_LIMITED. Wait Retry-After, then resend the same request. Never retry in a tight loop; never retry any other 4xx.\ntooLarge: 413 when the JSON body exceeds 1048576 bytes; split the updates array\npace:\n - Batch: one PUT per resource carrying ranges (dateFrom..dateTo, optional days) — a 365-night calendar for three plans is a handful of updates, not a thousand\n - Send on change, not on a timer: unchanged cells are dropped and cost nothing, but they still spend your request budget\n - Read RateLimit on every answer and slow down when r approaches 0, instead of waiting for a 429\n - Reuse x-idempotency-key on a retry so a timed-out request can never land twice\n - Poll GET /batches/{batchId} and GET /sync no more than every 15 s; the push to the channels is asynchronous and bounded by the channel manager's own budget\nchannelManager:\n whyAsynchronous: Your 202 means the cells are in our record. Pushing them to the channel manager is paced by its budget — ten rate/restriction reads a minute for the whole account and a per-property write budget — so a full calendar takes minutes, never seconds, and is never lost.\n whatWeDo: We coalesce your cells into the fewest channel-manager calls, drop what did not change, pace every call, stop before the channel manager's last token, and back off on its Retry-After — you never have to think about its limits, only about ours.\n\n",
2074
2304
  "bookings": "## bookings\nwho: Hotels that run the ZimmerStack PMS and their OWN booking engine: hand us the reservation your website sold and it lands in the PMS exactly as a front-desk booking — guest, folio, inventory, channels.\npricing: You price the stay. Send the nightly rate you charged per room; we store it and never re-quote. currency must equal the property's.\ninventory: Availability is checked inside the booking transaction under the property's inventory lock (a sold-out night is 409 NO_AVAILABILITY, nothing written). The inventory event commits with the booking; the drain pushes the new counts to every connected channel within seconds.\nidempotency: externalReference is YOUR reservation id and is unique per property: the same value again from the same key (or the key it was rotated from), while that booking is live, returns the same booking with HTTP 200 and replay: true. Use it on every retry. A reference another key already used on this property, or one that belongs to a booking you cancelled, is 409 EXTERNAL_REFERENCE_REUSED: after a cancel, the new stay needs a new reference.\npayments: A payment is recorded only when the key holds bookings:payments and never above the stay total. Nothing collected = omit payment; the desk collects at check-in.\nguest: By default the guest hears from YOUR site only; the owner can switch on our confirmation per property (admin → Developers → Settings).\ncancel: POST /bookings/{bookingId}/cancel cancels the whole booking and re-opens its nights on the channels; a booking already checked in is 409 BOOKING_NOT_CANCELLABLE. Date or room changes: cancel and re-create under a NEW externalReference (a modify endpoint is planned).\nscope: A key reads and cancels only the bookings it (or the key it was rotated from) created on its property; another key's, front-desk and OTA bookings are never visible (BOOKING_NOT_FOUND).\n\n",
2075
2305
  "budgets-and-standing": "## shield\nwhat: On top of the per-minute budgets, every property has budgets over an hour and a day, hard limits on its structure, and a standing ZimmerStack can change. They exist because every changed cell is forwarded by the channel manager to every connected channel: an integration that re-sends, flaps or loops is the hotel's and the channels' problem within a minute. GET /property carries this property's own figures (limits), what it has used (usage) and where it stands (shield).\ncounted: A budget counts CHANGED cells: cells whose value differs from our record. Re-sending a calendar we already hold costs nothing here. So send on change, in ranges.\ncalendar:\n what: One full calendar of a property is (2 × its rate plans + its room types) × 365 nights: a price and a stay-rule cell for every plan night, an availability cell for every room-type night. The figures in the table are the least any property gets; a larger one gets whole calendars.\n horizonDays: 365\n perHour: 2\n perDay: 6\n vendorPerDayBase: 150000\n vendorPerDayPerHotel: 15000\n perProperty: Every key on a property spends the same budget: a second key, or a company key beside a hotel key, is not a second budget.\nbudgets:\n - scope: cells-hour · window: one clock hour (UTC) · floor: 10000 · counts: 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\n - scope: cells-day · window: rolling 24 hours · floor: 30000 · counts: 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\n - scope: vendor-cells-day · window: rolling 24 hours · floor: 150000 · counts: 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\n - scope: structure-creates · window: 60 s sliding · floor: 20 · counts: new room types and rate plans per property; also the most one request may create (TOO_MANY_NEW_ENTITIES)\n - scope: structure-creates-day · window: rolling 24 hours · floor: 300 · counts: new room types and rate plans per property\n - scope: structure-edits-day · window: rolling 24 hours · floor: 300 · counts: changed room types and rate plans per property\n - scope: structure-deletes-day · window: rolling 24 hours · floor: 60 · counts: deleted room types and rate plans per property\n - scope: vendor-structure-creates-day · window: rolling 24 hours · floor: 500 · counts: a software vendor's new room types and rate plans across all its hotels\n - scope: vendor-remote-properties-day · window: rolling 24 hours · floor: 10 · counts: hotels a software vendor puts on the channel manager for the first time\n - scope: modifier-changes-day · window: rolling 24 hours · floor: 6 · counts: changes to a channel's price modifier per property (PUT /channels/{channelId}/modifier); steps the channel already holds are not counted\n - scope: rate-resends-day · window: rolling 24 hours · floor: 3 · counts: times a property's prices are sent to the channels again (POST /rates/resend)\ncaps:\n maxRoomTypes: 18\n maxRatePlans: 180\n why: Each cap sits a tenth under what the channel manager includes for that kind of property before it bills extra, so an integration never runs a hotel into overage. GET /property carries this property's own caps.\n byCategory:\n - category: hotel · maxRoomTypes: 18 · maxRatePlans: 180 · ratePlansPerRoomType: null\n - category: vacation rental · maxRoomTypes: 45 · maxRatePlans: 405 · ratePlansPerRoomType: 9\n onRefusal: 409 CATALOG_LIMIT_REACHED (details.limit, details.current, details.requested). Delete what is unused, or ask ZimmerStack support.\nonRefusal: 429 RATE_LIMITED with data.scope naming the budget and Retry-After in whole seconds: to the next clock hour for cells-hour, until enough of the day has aged out for a rolling day. Nothing was written. Wait, then send what still needs to change.\nsafetyLane: A hotel must not oversell because its integration ran out of budget or was paused. A write that only CLOSES inventory (a lower availability count or 0, or stopSell / closedToArrival / closedToDeparture switched on, and nothing else in the request) is still accepted in both cases, against its own hourly allowance (at least 500 cells); its 202 carries lane: true. A write that opens inventory or changes a price waits.\npriceBand:\n what: PUT /rates takes prices in MAJOR units; reads answer in MINOR units. A price below a tenth or above ten times its plan's standing price (the plan's defaultRate, or its room type's base rate) is not taken on trust: the whole request is 422 RATE_OUT_OF_BAND and nothing is written. A plan with no standing price is never judged.\n minPct: 10\n maxPct: 1000\n wayOut: If the price is meant, move the plan's standing price first (PUT /catalog/rate-plans defaultRate): the band moves with it. ZimmerStack support can set a property to warn only (the 202 then carries priceWarnings) or switch its band off; the hotel's owner asks for it.\nstanding:\n levels:\n CLEAR: Nothing held against the integration.\n WATCH: Something notable happened (a budget was used up). Nothing is refused.\n PAUSED: Only writes that close inventory are accepted (the safety lane); anything else is 429 RATE_LIMITED with data.scope shield-pause and a Retry-After that ends with the pause. Set automatically for a while when the channel manager refuses the integration's values or it uses up a budget on two of three days (15 minutes, then 1 hour, 6 hours, a day), or by ZimmerStack support until released.\n SUSPENDED: Every write is 403 WRITES_SUSPENDED until ZimmerStack support releases it.\n frozen: 503 WRITES_FROZEN with Retry-After: ZimmerStack has paused every integration's writes at once. Rare, short, and never your integration alone.\n never: Reads, GET /channel-bookings, webhooks and POST /bookings are never refused by any of this: a guest's reservation and its news always travel.\nrejectedValues: A rate or restriction value the channel manager itself refuses is held, not re-sent: GET /sync counts it (rates.parkedCells), its batch reads failed with the reason, and the property's other cells keep landing. Send a corrected value for those nights.\nsandbox: A sandbox meets the same budgets, limits and band on its own property, so you learn them before going live. It is never frozen and never counts against your company's budgets.\n\n",
2076
2306
  "room-types-and-rate-plans": "## structure\nwhat: PUT /catalog/room-types and PUT /catalog/rate-plans (scope catalog:write) let the PMS own the hotel's structure: an upsert by ref, your own id. A new entity is created on the channel manager at once; every later change mirrors there with retries and a nightly drift check; the answer names our id, the action and the sync status per entity. GET /catalog carries ref and sync from now on.\nadoption: A room type the owner already made with the same name (and no ref) becomes yours by ref (action: adopted); a plan likewise under the same room type. A plan never moves between room types (409 CATALOG_CONFLICT): delete it and send it again.\nswitchOn: A channel-manager-only hotel with no channel-manager property yet gets one on the first write, and the channel manager is switched on once a room type and a plan are mapped; channelManager.enabled in the answer says where it stands, reason why not.\nidempotent: Twice over: ref is the upsert key here, and the channel-manager create adopts an existing entity with the same title instead of creating it again, so a retry never duplicates on either side. Send x-idempotency-key on retries as on every write.\nnotHere: A room count after creation (it lives on the channel manager), photos, descriptions, amenities, cancellation policies and stay rules: the owner's Rooms & rates screen, or the restrictions routes.\nsandbox: On a sandbox everything lands locally and reads IN_SYNC, through the same code path.\n\n",
2077
- "ota-bookings": "## channelBookings\nwhat: GET /channel-bookings lists the OTA bookings the channel manager delivered to the property — the SAME booking object the webhooks carry, so one parser serves both. Scope channel-bookings:read, granted separately from the ARI pair.\nsince: since is on the booking's last change (created, modified or cancelled), default the last 7 days; page with limit (≤100) and repeat with since = the last item's updatedAt while more is true.\nwhy: Recover a missed webhook, or poll instead of receiving: the webhooks remain the push path, this is the pull path over the same shape.\nnever: Front-desk, booking-engine and Connect API bookings are never listed here; they are not channel bookings.\n\n",
2307
+ "ota-bookings": "## channelBookings\nwhat: GET /channel-bookings lists the OTA bookings the channel manager delivered to the property — the SAME booking object the webhooks carry, so one parser serves both. Scope channel-bookings:read, granted separately from the ARI pair.\nsince: since is on the booking's last change (created, modified or cancelled), default the last 7 days; page with limit (≤100) and repeat with since = the last item's updatedAt while more is true.\nwhy: Recover a missed webhook, or poll instead of receiving: the webhooks remain the push path, this is the pull path over the same shape.\nnever: Front-desk, booking-engine and Connect API bookings are never listed here; they are not channel bookings. The booking engine's are GET /direct-bookings.\n\n",
2308
+ "website-bookings": "## directBookings\nwhat: A hotel that sells on its own website through the ZimmerStack booking engine takes bookings no OTA sent. They reach a PMS under their own names: the webhooks direct.booking.created and direct.booking.cancelled, and GET /direct-bookings for the pull. The booking object is the one channel.booking.* carries, so one parser serves both families.\ntellApart: channel.source is DIRECT_WEB, channel.sourceGroup is DIRECT and channel.otaName is \"Website\". finance is null (no OTA, no commission); amounts.paymentCollect is \"property\"; amounts.paid is what the guest paid online, amounts.balanceDue what the desk collects.\nsubscribe: An endpoint receives them only when it lists the two event types. An endpoint registered before they existed receives none until its owner ticks them.\napplyFirst: A website booking takes one room off the count the channels hold, at once. A PMS that pushes absolute room counts must apply the booking to its own calendar BEFORE its next PUT /availability, or that push puts the sold room back on sale. Read GET /direct-bookings before a full push to catch anything a webhook has not delivered yet.\nevents: created: a nightly or an hourly booking the guest confirmed. cancelled: the guest cancelled on the booking page, or the hotel cancelled or deleted the booking in ZimmerStack; cancellation.reason says which. There is no modified event: the booking engine never changes a booking's dates.\nafterwards: What the hotel changes on a website booking in ZimmerStack afterwards (other dates, one room of several cancelled, a no-show) sends no event. GET /direct-bookings lists that booking again, because since is on its last change: read it on a slow schedule too (once an hour is plenty), not only before a push. A cancelled event can also arrive for a booking whose created your endpoint never received (it ticked the types later): treat an unknown booking id as new and read it with GET /direct-bookings/{bookingId}.\npull: GET /direct-bookings takes the same since, status, limit and cursor as GET /channel-bookings and pages the same way. Scope direct-bookings:read, granted separately from channel-bookings:read. A booking deleted in ZimmerStack stays listed, as CANCELLED.\nnever: OTA bookings (GET /channel-bookings), front-desk bookings and bookings a key created (GET /bookings) are never listed here.\nsandbox: POST /sandbox/bookings with otaName \"Website\" simulates one and sends the real direct.booking.created; its cancel sends direct.booking.cancelled. Its modify is 409 BOOKING_NOT_MODIFIABLE.\n\n",
2078
2309
  "channels-and-modifiers": "## channels\nwhat: GET /channels lists the connections the channel manager holds for the property, from our record (the nightly settings sweep), with every unresolved problem the channel manager reported (rate_error, sync_error, disconnect_channel, the inventory pipe out of sync).\nfreshness: asOf says when the list was captured; a channel connected today appears after the next sweep. Problems are live.\npushed: The same problems are pushed as webhooks: channel.sync.alert when one is raised, channel.sync.recovered when the inventory pipe recovers (docs/webhooks).\n\n## modifiers\nwhat: One price per rate plan per night goes to every channel the plan is mapped to. A channel's modifier is the one thing that differs per channel: up to five ordered steps (raise or lower, by a percentage or a fixed amount in major units) the channel manager applies to every price it sends that channel. GET /channels shows each channel's steps; PUT /channels/{channelId}/modifier replaces them (scope channel-modifiers:write, granted separately: one call moves every price on that channel).\ntakesEffect: A modifier applies to prices sent to the channel after the change. Prices already on the channel stay as they are until those nights are sent again.\nresend: POST /rates/resend (scope ari:write) sends the property's prices and stay rules to the channels again, unchanged, so every night picks the current modifiers up. Re-sending the same price through PUT /rates does nothing: a value our record already holds is dropped before anything is sent. The re-send is the way, and a hotel may ask for it only a few times a day (data.scope rate-resends-day).\nworkflow:\n - GET /channels: find the channel (channelId, kind) and read the steps it holds\n - PUT /channels/{channelId}/modifier with the whole list of steps; [] removes the modifier\n - POST /rates/resend if nights already on the channel should move too, then watch rates.dirtyCells on GET /sync fall to 0\nband:\n maxDecreasePct: 50\n maxIncreasePct: 100\nbandRule: The steps together may not lower a price by more or raise it by more than the band: 422 MODIFIER_OUT_OF_BAND, nothing changed. A fixed amount is judged at the property's lowest and highest standing price.\nshared: A connection that serves more than one property (one Airbnb or Booking.com account for sister hotels) is refused, 409 CHANNEL_SHARED: its modifier would move another hotel's prices. The hotels' owner sets it in ZimmerStack.\ngrid: GET /rates always answers the price before any modifier. What a channel is sent is that price with the channel's steps applied in order.\nmarkupPlan: markupPlan on GET /channels is a separate adjustment the owner may have set in the ZimmerStack Channels app; it applies before the modifier and is read-only here.\nsandbox: A sandbox has three pretend channels (Booking.com, MakeMyTrip, Agoda) so the whole workflow can be tried with a test key; nothing leaves our record.\n\n",
2079
- "sandbox": "## sandbox\nwhat: The owner creates a sandbox from a real property (admin → Developers → API keys, Channels → Integrations): a copy of its room types and rate plans that no channel ever sees. Keys minted there start with zsk_test_ and work ONLY there; a live key never reaches it.\npushes: Every route behaves as in production. A push lands in our record and stops: GET /sync reports IN_SYNC and GET /batches/{batchId} reports landed within a minute, through the same code path as a live property. GET /property says sandbox: true.\nmodify: POST /sandbox/bookings/{bookingId}/modify sends a modified revision — new dates, length, rooms or guest — and the REAL channel.booking.modified webhook with changes and previous, the old nights back on availability and the new ones off.\nbookings: POST /sandbox/bookings simulates an OTA booking end to end — the booking, the sandbox's availability moved down, the inventory event, and the REAL channel.booking.created webhook to every endpoint registered on the sandbox. POST /sandbox/bookings/{bookingId}/cancel does the same for a cancellation. A live key gets 403 SANDBOX_ONLY.\nlimits: The same budgets as production (one sandbox per owner, up to five per software partner, at most five keys on each). Nothing you do there is billed or pushed to a channel.\ngoLive: Ask the owner for a zsk_live_ key on the real property, swap the key, keep the code.\n\n",
2310
+ "sandbox": "## sandbox\nwhat: The owner creates a sandbox from a real property (admin → Developers → API keys, Channels → Integrations): a copy of its room types and rate plans that no channel ever sees. Keys minted there start with zsk_test_ and work ONLY there; a live key never reaches it.\npushes: Every route behaves as in production. A push lands in our record and stops: GET /sync reports IN_SYNC and GET /batches/{batchId} reports landed within a minute, through the same code path as a live property. GET /property says sandbox: true.\nmodify: POST /sandbox/bookings/{bookingId}/modify sends a modified revision — new dates, length, rooms or guest — and the REAL channel.booking.modified webhook with changes and previous, the old nights back on availability and the new ones off.\nbookings: POST /sandbox/bookings simulates an OTA booking end to end — the booking, the sandbox's availability moved down, the inventory event, and the REAL channel.booking.created webhook to every endpoint registered on the sandbox. POST /sandbox/bookings/{bookingId}/cancel does the same for a cancellation. With otaName \"Website\" the booking is one made on the hotel's own website instead, and the events are direct.booking.created and direct.booking.cancelled (x-zimmerstack.directBookings). A live key gets 403 SANDBOX_ONLY.\nlimits: The same budgets as production (one sandbox per owner, up to five per software partner, at most five keys on each). Nothing you do there is billed or pushed to a channel.\ngoLive: Ask the owner for a zsk_live_ key on the real property, swap the key, keep the code.\n\n",
2080
2311
  "errors": "Every refusal is { statuscode, message, data: { code, … } }. Branch on data.code (the client: err.code): it is stable. message is for a person and may change.\nRetry only 429, 5xx and IDEMPOTENCY_IN_FLIGHT, after Retry-After; every other code is a verdict on the request. The client does this by itself.\n\n- API_KEY_INVALID (401): \"Unauthorized\"\n- API_KEY_REVOKED (401): \"Unauthorized\"\n- API_KEY_EXPIRED (401): \"Unauthorized\"\n- CONNECT_API_NOT_CONFIGURED\n- IP_NOT_ALLOWED (403): \"This API key may not be used from this address. The property owner restricts it to an allowlist.\"\n- SCOPE_MISSING (403): \"This API key does not have the bookings:write scope. The property owner grants scopes when creating or editing a key.\"\n- PROPERTY_UNAVAILABLE (409): \"This property is not available to the API any more. Contact the property owner.\"\n- CHANNEL_MANAGER_DISABLED (409): \"This property's channel manager is switched off, so writes would not reach any channel. Contact the property owner.\"\n- PMS_NOT_AVAILABLE (409): \"This property runs the channel manager only; there is no PMS to put a booking in.\"\n- VALIDATION (400): \"updates[0].available: Expected number, received string\"\n- RANGE_INVALID (400)\n- HORIZON (400): \"updates[0]: 2028-01-01 is beyond the horizon (last writable night is 2027-10-12, today + 365 days)\" [PUT /availability, PUT /rates, PUT /restrictions]\n- TOO_MANY_UPDATES (400) [PUT /availability, PUT /rates, PUT /restrictions]\n- TOO_MANY_CELLS (400): \"a request may name at most 5000 cells (entity × night); split the calendar into several requests\" [PUT /availability, PUT /rates, PUT /restrictions]\n- UNKNOWN_ROOM_TYPE (400) [PUT /catalog/rate-plans, PUT /availability, POST /bookings, POST /sandbox/bookings]\n- UNKNOWN_RATE_PLAN (400): \"rate plan(s) 77 do not belong to this property (see GET /catalog)\" [PUT /rates, PUT /restrictions, POST /bookings]\n- CURRENCY_MISMATCH (400): \"rates must be sent in INR (got EUR)\" [PUT /rates, POST /bookings]\n- RATE_LIMITED (429): \"Too many requests on this API key. Slow down and retry after the Retry-After interval.\"\n- NOTHING_ACCEPTED (422): \"exceptions are switched off for this property — move the base rate instead\" [PUT /availability, PUT /rates, PUT /restrictions]\n- BATCH_NOT_FOUND (404): \"Batch not found.\"\n- IDEMPOTENCY_KEY_INVALID\n- IDEMPOTENCY_KEY_REUSED (409): \"This idempotency key was already used with a different request body.\"\n- IDEMPOTENCY_IN_FLIGHT\n- STAY_INVALID (400): \"checkIn 2026-10-01 is in the past (today at the property is 2026-10-20)\" [POST /bookings, POST /sandbox/bookings, POST /sandbox/bookings/{bookingId}/modify]\n- UNKNOWN_ROOM_TYPE_FOR_PLAN (400) [POST /bookings]\n- OCCUPANCY_EXCEEDED (400): \"rooms[0]: Deluxe takes at most 3 adults (got 4)\" [POST /bookings]\n- NO_AVAILABILITY (409): \"room type 412 has 0 left on 2026-12-21; 1 requested\" [POST /bookings]\n- EXTERNAL_REFERENCE_REUSED (409) [POST /bookings]\n- PAYMENT_NOT_ALLOWED (403): \"This API key may not record payments. The property owner grants the bookings:payments scope.\" [POST /bookings]\n- PAYMENT_EXCEEDS_TOTAL (400): \"payment.amount 30000.00 exceeds the stay total 27000.00\" [POST /bookings]\n- BOOKING_NOT_FOUND (404): \"Booking not found.\"\n- BOOKING_NOT_CANCELLABLE (409): \"Booking already checked in. Ask the hotel to handle it at the desk.\"\n- MODULE_NOT_ENTITLED (402): \"This property's plan does not include the PMS.\"\n- SANDBOX_ONLY (403): \"The sandbox routes answer only to a test key (zsk_test_…) on a sandbox property. This key is a live key.\" [POST /sandbox/bookings, POST /sandbox/bookings/{bookingId}/cancel, POST /sandbox/bookings/{bookingId}/modify]\n- ROOM_TYPE_NOT_FOUND (404): \"That room type doesn't exist.\"\n- RATE_PLAN_NOT_FOUND (404): \"That rate plan doesn't exist.\"\n- CATALOG_CONFLICT (409): \"A room type with this name already exists.\" [PUT /catalog/room-types, PUT /catalog/rate-plans]\n- CATALOG_BUSY (409): \"Another room-type or rate-plan write for this property is still running. Retry in a few seconds.\"\n- CHANNEL_MANAGER_ERROR (502): \"The channel manager refused the delete. Nothing changed here; try again in a moment.\"\n- PROPERTY_REQUIRED (400): \"This is a company key: name the hotel in the X-ZS-Property header, with its id from GET /properties.\"\n- PROPERTY_NOT_FOUND (404): \"No property with this id that this key may act on (see GET /properties).\"\n- ARI_NOT_AUTHORITATIVE (409): \"This property's local rates and availability are not the channels' source of truth yet, so API writes would never be pushed. Contact ZimmerStack support.\"\n- ROUTE_NOT_FOUND (404): \"No GET /api/v1/connect-api/v1/nope in the Connect API; the contract lists every route.\"\n- PAYLOAD_TOO_LARGE (413): \"The request body is larger than the API accepts. Split the updates array across requests.\"\n- AUTH_BACKEND_UNAVAILABLE\n- BOOKING_NOT_MODIFIABLE (409): \"A cancelled booking cannot be modified from the sandbox.\"\n- SANDBOX_NOT_FOUND\n- SANDBOX_INCOMPLETE\n- WRITES_FROZEN (503): \"ZimmerStack has paused every write to the channel manager for now. Nothing was written. Retry after the Retry-After interval; reads and bookings are not affected.\"\n- WRITES_SUSPENDED (403): \"ZimmerStack has suspended writes for this integration: it kept sending after repeated notices. Reads and bookings still work. Contact ZimmerStack support to have it released.\" [PUT /availability, PUT /rates, PUT /restrictions, PUT /channels/{channelId}/modifier, POST /rates/resend]\n- SHIELD_UNAVAILABLE (503): \"The write could not be checked against this property's budgets right now. Nothing was written. Retry after the Retry-After interval.\"\n- CATALOG_LIMIT_REACHED (409): \"This property holds 298 rate plans and may hold 300; this request would add 6. Delete what is unused, or ask ZimmerStack support to raise the limit.\" [PUT /catalog/room-types, PUT /catalog/rate-plans]\n- TOO_MANY_NEW_ENTITIES (400): \"This request would create 34 new room types or rate plans; one request may create at most 20. Entities that already exist do not count. Split the new ones across requests.\" [PUT /catalog/room-types, PUT /catalog/rate-plans]\n- RATE_OUT_OF_BAND (422): \"rate plan 901 on 2026-12-01: 45 INR is below the band around this plan's standing price 4500 INR (lowest accepted 450) (and 29 more cells). Rates are sent in major units (4500, not 450000). If the price is meant, change the plan's standing price first (PUT /catalog/rate-plans defaultRate), or ask ZimmerStack support to lift the band for this property.\" [PUT /availability, PUT /rates, PUT /restrictions]\n- CHANNEL_NOT_FOUND (404): \"No connected channel with this id on this property. GET /channels lists them.\" [PUT /channels/{channelId}/modifier]\n- CHANNEL_SHARED (409): \"This connection serves more than one property, so its modifier would move another hotel's prices too. It is set by the hotels' owner in ZimmerStack, not through this API. Nothing was changed.\" [PUT /channels/{channelId}/modifier]\n- MODIFIER_OUT_OF_BAND (422): \"These steps would change what the channel is sent by +180%; a channel's modifier must stay between 50% lower and 100% higher. Nothing was changed.\"\n",
2081
- "webhooks": "ZimmerStack POSTs a signed JSON event to the endpoint the hotel's owner (or a software vendor) registered.\n- Events: channel.booking.created, channel.booking.modified, channel.booking.cancelled (an OTA booking arrived, changed, was cancelled); channel.sync.* (a connection's health); zimmerstack.ping (a test).\n- Envelope: { id, type, apiVersion, occurredAt, mode: \"live\" | \"test\", property: { id, name, currency, timezone }, data: { booking }, changes, previous }.\n- Signature (Standard Webhooks): headers webhook-id, webhook-timestamp, webhook-signature. The signature is \"v1,\" + base64(HMAC-SHA256(secret, id + \".\" + timestamp + \".\" + rawBody)); the secret is whsec_ + base64. During a rotation the header carries two, space-separated.\n- Verify the RAW body before parsing it, compare in constant time, and refuse a timestamp more than five minutes old. With this package: const event = await verifyWebhook(rawBody, headers, secret); it throws ZimmerStackWebhookError otherwise.\n- Deliveries are at-least-once and may arrive out of order: dedupe on event.id, order on occurredAt. Answer 2xx within seconds and do slow work afterwards.\n- GET /channel-bookings (zs.channelBookings.all({ since })) recovers what an endpoint missed. It is not a polling loop.\n",
2082
- "the-package": "@zimmerstack/connect 0.2.0: npm install @zimmerstack/connect. Node 20 or newer, on a server only, zero dependencies.\n\nconst zs = new ZimmerStack(); // reads ZIMMERSTACK_CONNECT_KEY; make one per process and reuse it\n\nEvery operation has a method: each operation's lookup names it (\"With the package\"). On top of those:\n- zs.grid.load(from, to): the whole rate grid for a window, ready for a screen. Rows are room types with their rate plans, columns are nights; prices in MAJOR units. Three reads (four the first time; the catalog is kept ten minutes).\n- zs.grid.save(edits): what a person changed, as single nights { availability?, rates?, restrictions? }. Folds nights into ranges, fills in the currency, splits a large save, sends one request per resource in turn. Returns the accepted answers, each with a batchId.\n- zs.batches.wait(batchId): asks every 15 seconds at the fastest, for at most five minutes; returns the last status (\"landed\", \"failed\", or still \"pending\").\n- zs.channelBookings.all({ since }): an async iterator over every OTA booking changed since then, following the cursor.\n- zs.forProperty(propertyId): a software vendor's company key acting on one hotel; shares the pace of the client it came from.\n- zs.request(\"GET /sync\"): any operation by its contract name, typed.\n- Pure helpers: eachDate(from, to), addDays(date, n), toRanges(cells), chunk(updates), buildGrid(parts), channelPrice(rate, steps).\n- verifyWebhook(rawBody, headers, secret): returns the event or throws ZimmerStackWebhookError.\n- MODIFIER_TAKES_EFFECT: the sentence to show where a person saves a channel's modifier. LIMITS, ERROR_CODES, SCOPES: the contract's own.\n\nA refusal is a ZimmerStackError: code (stable; branch on it), message (for a person; show it), status, retryable (false = fix the request, never resend), retryAfterSeconds, scope (which budget), details, operation.\n\nOptions: apiKey, propertyId, timeoutMs (30 s), maxRetries (3), maxWaitSeconds (120), onEvent (every answer, wait and retry, for logs; never the key), fetch (a stand-in for tests), allowLiveWritesInTests.\n\nWhat it keeps by itself, so do not re-implement it or wrap its calls in a retry loop:\n- Server only: it refuses a browser and React Native, sends the key to ZimmerStack only, never follows a redirect with it and never prints it.\n- Reads the RateLimit header and waits before a budget runs out. Writes go one at a time, in order; at most four reads at once.\n- Retries 429, 5xx and a network failure (four attempts, a growing wait, the same idempotency key); throws anything else at once. A wait over two minutes is handed back.\n- A write the server keeps no idempotency record for is not resent when its outcome is unknown.\n- Splits a write at 1,000 updates or 5,000 cells.\n- After API_KEY_INVALID, API_KEY_REVOKED or API_KEY_EXPIRED it stops calling.\n- A zsk_live_ key under a test runner may read but not write.\n"
2312
+ "webhooks": "ZimmerStack POSTs a signed JSON event to the endpoint the hotel's owner (or a software vendor) registered.\n- Events: channel.booking.created, channel.booking.modified, channel.booking.cancelled (an OTA booking arrived, changed, was cancelled); direct.booking.created, direct.booking.cancelled (a guest booked, or cancelled, on the hotel's own website through ZimmerStack's booking engine: topic website-bookings; an endpoint gets them only when it lists those two types); channel.sync.* (a connection's health); zimmerstack.ping (a test).\n- Envelope: { id, type, apiVersion, occurredAt, mode: \"live\" | \"test\", property: { id, name, currency, timezone }, data: { booking }, changes, previous }.\n- Signature (Standard Webhooks): headers webhook-id, webhook-timestamp, webhook-signature. The signature is \"v1,\" + base64(HMAC-SHA256(secret, id + \".\" + timestamp + \".\" + rawBody)); the secret is whsec_ + base64. During a rotation the header carries two, space-separated.\n- Verify the RAW body before parsing it, compare in constant time, and refuse a timestamp more than five minutes old. With this package: const event = await verifyWebhook(rawBody, headers, secret); it throws ZimmerStackWebhookError otherwise.\n- Deliveries are at-least-once and may arrive out of order: dedupe on event.id, order on occurredAt. Answer 2xx within seconds and do slow work afterwards.\n- GET /channel-bookings (zs.channelBookings.all({ since })) and GET /direct-bookings (zs.directBookings.all({ since })) recover what an endpoint missed. They are not polling loops.\n- isWebsiteBookingEvent(event) says an event is a website booking (direct.booking.*); isOtaBookingEvent(event) says it is an OTA booking (channel.booking.*). The booking object is the same in both.\n",
2313
+ "the-package": "@zimmerstack/connect 0.3.0: npm install @zimmerstack/connect. Node 20 or newer, on a server only, zero dependencies.\n\nconst zs = new ZimmerStack(); // reads ZIMMERSTACK_CONNECT_KEY; make one per process and reuse it\n\nEvery operation has a method: each operation's lookup names it (\"With the package\"). On top of those:\n- zs.grid.load(from, to): the whole rate grid for a window, ready for a screen. Rows are room types with their rate plans, columns are nights; prices in MAJOR units. Three reads (four the first time; the catalog is kept ten minutes).\n- zs.grid.save(edits): what a person changed, as single nights { availability?, rates?, restrictions? }. Folds nights into ranges, fills in the currency, splits a large save, sends one request per resource in turn. Returns the accepted answers, each with a batchId.\n- zs.batches.wait(batchId): asks every 15 seconds at the fastest, for at most five minutes; returns the last status (\"landed\", \"failed\", or still \"pending\").\n- zs.channelBookings.all({ since }): an async iterator over every OTA booking changed since then, following the cursor.\n- zs.directBookings.all({ since }): the same for the bookings guests made on the hotel's own website (scope direct-bookings:read). Read it before a full availability push.\n- zs.forProperty(propertyId): a software vendor's company key acting on one hotel; shares the pace of the client it came from.\n- zs.request(\"GET /sync\"): any operation by its contract name, typed.\n- Pure helpers: eachDate(from, to), addDays(date, n), toRanges(cells), chunk(updates), buildGrid(parts), channelPrice(rate, steps).\n- verifyWebhook(rawBody, headers, secret): returns the event or throws ZimmerStackWebhookError.\n- isWebsiteBookingEvent(event), isOtaBookingEvent(event): tell the two booking families apart; BOOKING_EVENT_TYPES lists every type of both.\n- MODIFIER_TAKES_EFFECT: the sentence to show where a person saves a channel's modifier. LIMITS, ERROR_CODES, SCOPES: the contract's own.\n\nA refusal is a ZimmerStackError: code (stable; branch on it), message (for a person; show it), status, retryable (false = fix the request, never resend), retryAfterSeconds, scope (which budget), details, operation.\n\nOptions: apiKey, propertyId, timeoutMs (30 s), maxRetries (3), maxWaitSeconds (120), onEvent (every answer, wait and retry, for logs; never the key), fetch (a stand-in for tests), allowLiveWritesInTests.\n\nWhat it keeps by itself, so do not re-implement it or wrap its calls in a retry loop:\n- Server only: it refuses a browser and React Native, sends the key to ZimmerStack only, never follows a redirect with it and never prints it.\n- Reads the RateLimit header and waits before a budget runs out. Writes go one at a time, in order; at most four reads at once.\n- Retries 429, 5xx and a network failure (four attempts, a growing wait, the same idempotency key); throws anything else at once. A wait over two minutes is handed back.\n- A write the server keeps no idempotency record for is not resent when its outcome is unknown.\n- Splits a write at 1,000 updates or 5,000 cells.\n- After API_KEY_INVALID, API_KEY_REVOKED or API_KEY_EXPIRED it stops calling.\n- A zsk_live_ key under a test runner may read but not write.\n"
2083
2314
  }
2084
2315
  };
@@ -3,11 +3,30 @@ import type { ChannelBooking } from "./generated.js";
3
3
  * Verifying a webhook ZimmerStack sent you (Standard Webhooks: the `webhook-id`, `webhook-timestamp` and
4
4
  * `webhook-signature` headers). Uses Web Crypto, so it runs on Node and on edge runtimes alike.
5
5
  */
6
+ /** An OTA booking arrived, changed or was cancelled (through the channel manager). */
7
+ export declare const OTA_BOOKING_EVENT_TYPES: readonly ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled"];
8
+ /**
9
+ * A guest booked, or cancelled, on the hotel's own website through ZimmerStack's booking engine. The same
10
+ * booking object as the OTA events, in a family of its own: an endpoint receives these only when it lists
11
+ * the two types. There is no modified event.
12
+ */
13
+ export declare const WEBSITE_BOOKING_EVENT_TYPES: readonly ["direct.booking.created", "direct.booking.cancelled"];
14
+ /** Every event whose `data.booking` is a booking, of either family. */
15
+ export declare const BOOKING_EVENT_TYPES: readonly ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled", "direct.booking.created", "direct.booking.cancelled"];
16
+ export type OtaBookingEventType = (typeof OTA_BOOKING_EVENT_TYPES)[number];
17
+ export type WebsiteBookingEventType = (typeof WEBSITE_BOOKING_EVENT_TYPES)[number];
18
+ export type BookingEventType = (typeof BOOKING_EVENT_TYPES)[number];
19
+ /** Every type an endpoint can receive. A newer API may add more: `WebhookEvent.type` stays a string. */
20
+ export type WebhookEventType = BookingEventType | "channel.sync.alert" | "channel.sync.recovered" | "zimmerstack.ping";
6
21
  /** What every delivery carries. Deliveries are at-least-once: dedupe on `id`, order on `occurredAt`. */
7
22
  export interface WebhookEvent {
8
23
  /** "evt_<uuid>", the same on every retry and on every endpoint. */
9
24
  id: string;
10
- /** channel.booking.created · channel.booking.modified · channel.booking.cancelled · channel.sync.* · zimmerstack.ping */
25
+ /**
26
+ * channel.booking.created · channel.booking.modified · channel.booking.cancelled (an OTA booking) ·
27
+ * direct.booking.created · direct.booking.cancelled (a booking on the hotel's own website) ·
28
+ * channel.sync.* · zimmerstack.ping. Narrow it with `isOtaBookingEvent` and `isWebsiteBookingEvent`.
29
+ */
11
30
  type: string;
12
31
  apiVersion: string;
13
32
  occurredAt: string;
@@ -30,6 +49,29 @@ export interface WebhookEvent {
30
49
  previous?: Record<string, unknown> | null;
31
50
  truncated?: boolean;
32
51
  }
52
+ /** An event whose `data.booking` is there: of either booking family. */
53
+ export type BookingEvent = WebhookEvent & {
54
+ type: BookingEventType;
55
+ data: {
56
+ booking: ChannelBooking;
57
+ [key: string]: unknown;
58
+ };
59
+ };
60
+ /** A booking a guest made on the hotel's own website. `finance` is null and `changes` and `previous` always are. */
61
+ export type WebsiteBookingEvent = BookingEvent & {
62
+ type: WebsiteBookingEventType;
63
+ };
64
+ /** A booking an OTA sent. */
65
+ export type OtaBookingEvent = BookingEvent & {
66
+ type: OtaBookingEventType;
67
+ };
68
+ /**
69
+ * True for `direct.booking.created` and `direct.booking.cancelled`: a booking made on the hotel's own
70
+ * website. A PMS that pushes room counts must put it in its own calendar before its next push.
71
+ */
72
+ export declare function isWebsiteBookingEvent(event: WebhookEvent): event is WebsiteBookingEvent;
73
+ /** True for `channel.booking.created`, `.modified` and `.cancelled`: a booking an OTA sent. */
74
+ export declare function isOtaBookingEvent(event: WebhookEvent): event is OtaBookingEvent;
33
75
  export declare class ZimmerStackWebhookError extends Error {
34
76
  /** Why the delivery was refused. Answer 400 and do not act on the body. */
35
77
  readonly reason: "missing_headers" | "stale_timestamp" | "bad_signature" | "bad_body";
@@ -1,3 +1,29 @@
1
+ /**
2
+ * Verifying a webhook ZimmerStack sent you (Standard Webhooks: the `webhook-id`, `webhook-timestamp` and
3
+ * `webhook-signature` headers). Uses Web Crypto, so it runs on Node and on edge runtimes alike.
4
+ */
5
+ /** An OTA booking arrived, changed or was cancelled (through the channel manager). */
6
+ export const OTA_BOOKING_EVENT_TYPES = ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled"];
7
+ /**
8
+ * A guest booked, or cancelled, on the hotel's own website through ZimmerStack's booking engine. The same
9
+ * booking object as the OTA events, in a family of its own: an endpoint receives these only when it lists
10
+ * the two types. There is no modified event.
11
+ */
12
+ export const WEBSITE_BOOKING_EVENT_TYPES = ["direct.booking.created", "direct.booking.cancelled"];
13
+ /** Every event whose `data.booking` is a booking, of either family. */
14
+ export const BOOKING_EVENT_TYPES = [...OTA_BOOKING_EVENT_TYPES, ...WEBSITE_BOOKING_EVENT_TYPES];
15
+ const isType = (list, event) => typeof event?.type === "string" && list.includes(event.type);
16
+ /**
17
+ * True for `direct.booking.created` and `direct.booking.cancelled`: a booking made on the hotel's own
18
+ * website. A PMS that pushes room counts must put it in its own calendar before its next push.
19
+ */
20
+ export function isWebsiteBookingEvent(event) {
21
+ return isType(WEBSITE_BOOKING_EVENT_TYPES, event) && Boolean(event.data?.booking);
22
+ }
23
+ /** True for `channel.booking.created`, `.modified` and `.cancelled`: a booking an OTA sent. */
24
+ export function isOtaBookingEvent(event) {
25
+ return isType(OTA_BOOKING_EVENT_TYPES, event) && Boolean(event.data?.booking);
26
+ }
1
27
  export class ZimmerStackWebhookError extends Error {
2
28
  /** Why the delivery was refused. Answer 400 and do not act on the body. */
3
29
  reason;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zimmerstack/connect",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Official Node.js client for the ZimmerStack Connect API: rates, availability, stay rules, prices per channel and bookings, with pacing, safe retries and idempotency built in. Ships an MCP server for coding agents.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.zimmerstack.com/sdk",