@zimmerstack/connect 0.3.0 → 0.4.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
@@ -75,8 +75,16 @@ https://docs.zimmerstack.com/llms-full.txt
75
75
  room counts must apply the booking to its own calendar BEFORE its next `zs.availability.set` or
76
76
  `zs.grid.save`, or that push puts the sold room back on sale. Read `zs.directBookings.all` before a
77
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.
78
+ - `zs.directBookings.cancel(bookingId, { refund, reason })` cancels a whole website booking that is
79
+ still UPCOMING, and moves the guest's money (scope `direct-bookings:cancel`, granted on its own).
80
+ `refund` is `"policy"` (the default: what the booking's own cancellation policy gives back, as if the
81
+ guest cancelled), `"full"` (everything paid online: the hotel is at fault, an overbooking) or
82
+ `"none"` (the hotel settles the money itself). Call it only from a person's own cancel button, with
83
+ the refund they chose on the screen; never from a loop, a sync job or a test against a live key.
84
+ Show `refund.amount` and `refund.status` from the answer. `BOOKING_NOT_CANCELLABLE` (checked in,
85
+ checked out, a no-show) goes to the hotel's desk; do not retry it. `replay: true` means it was
86
+ already cancelled and no money moved. Your own cancel comes back as `direct.booking.cancelled`
87
+ ("Cancelled by the hotel"): match it on the booking id and treat it as already applied.
80
88
 
81
89
  ## Errors
82
90
 
@@ -120,3 +128,4 @@ these tools.
120
128
  - [ ] Tests run against a `zsk_test_` key or a fake `fetch`; none needs a live key.
121
129
  - [ ] Where a modifier is saved, the screen says when it takes effect, and the re-send is its own button.
122
130
  - [ ] A PMS that pushes room counts applies every website booking to its own calendar before it pushes.
131
+ - [ ] A website booking is cancelled only from a person's own action, with the refund they chose.
package/README.md CHANGED
@@ -87,6 +87,7 @@ zs.channels.setModifier(channelId, steps)
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
89
  zs.directBookings.list(…) / .get(id) / .all(…) // what guests booked on the hotel's own website
90
+ zs.directBookings.cancel(id, { refund }) // cancel one from your PMS, with its refund
90
91
  zs.sandbox.bookings.create(…) / .cancel(id) / .modify(id, …) // pretend an OTA or the website booked (test keys)
91
92
 
92
93
  zs.request("GET /sync") // any operation of the contract by name, typed
@@ -194,9 +195,26 @@ for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToM
194
195
  await zs.grid.save(edits); // only now
195
196
  ```
196
197
 
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>
198
+ A guest cancels on the booking page, or the hotel cancels in ZimmerStack. From 0.4.0 your PMS can
199
+ cancel one too, and say what the guest gets back (scope `direct-bookings:cancel`, granted on its own):
200
+
201
+ ```ts
202
+ const { refund, replay } = await zs.directBookings.cancel(bookingId, { refund: "policy", reason: "Guest phoned to cancel" });
203
+ // refund.amount in major units; refund.status NONE, PENDING, PROCESSED or MANUAL
204
+ ```
205
+
206
+ `refund` is `"policy"` (the default: what the booking's own cancellation policy gives back now, as if the
207
+ guest cancelled on the booking page; for a guest who asks the hotel to cancel), `"full"` (everything
208
+ the guest paid online; when the hotel is at fault, such as an overbooking) or `"none"` (the hotel
209
+ settles the money another way). The refund goes back to the guest's online payment, never more than
210
+ it. A checked-in, checked-out or no-show booking is `BOOKING_NOT_CANCELLABLE`; one already cancelled
211
+ answers `replay: true` and moves no money. Your own cancel comes back as `direct.booking.cancelled`
212
+ ("Cancelled by the hotel"): match it on the booking id and treat it as already applied. Call it from
213
+ a person's own cancel button, never from a sync job.
214
+
215
+ To try it with a test key, `zs.sandbox.bookings.create({ …, otaName: "Website" })`, then cancel that
216
+ booking with `zs.directBookings.cancel`: the nights come back and no money moves.
217
+ Guide: <https://docs.zimmerstack.com/website-bookings#cancel>
200
218
 
201
219
  ## Options
202
220
 
@@ -1,4 +1,4 @@
1
- import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
1
+ import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type DirectBookingCancel, type DirectBookingCancelResult, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
2
2
  import { type Grid, type GridEdits, type ModifierStep } from "./grid.js";
3
3
  export interface ZimmerStackOptions {
4
4
  /**
@@ -246,6 +246,28 @@ export declare class ZimmerStack {
246
246
  * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
247
247
  */
248
248
  all: (query?: Omit<NonNullable<Op<"GET /direct-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
249
+ /**
250
+ * Cancel a whole website booking that is still UPCOMING, and say what the guest gets back. Scope
251
+ * `direct-bookings:cancel`, granted on its own and never by default.
252
+ *
253
+ * `refund`: `"policy"` (the default) is what the booking's own cancellation policy gives back now, as
254
+ * if the guest cancelled on the booking page; `"full"` is everything the guest paid online (the hotel
255
+ * is at fault: an overbooking); `"none"` moves no money (the hotel settles it another way). The refund
256
+ * goes back to the guest's online payment and never exceeds it. The answer's `refund` says how much
257
+ * and where it stands (NONE, PENDING, PROCESSED, MANUAL).
258
+ *
259
+ * IT MOVES A GUEST'S MONEY. Call it from a person's own cancel button, with the refund they chose;
260
+ * never from a loop, a sync job or a test against a live key. A booking already cancelled answers
261
+ * `replay: true` and moves no money; checked in, checked out or a no-show is BOOKING_NOT_CANCELLABLE.
262
+ * Your own cancel comes back as `direct.booking.cancelled` ("Cancelled by the hotel"): treat it as
263
+ * already applied. The call carries an idempotency key (yours, or one the client makes) and a retry
264
+ * after a network failure reuses it, so a cancel never lands twice; pass your own `idempotencyKey`
265
+ * when a retry may come from another process.
266
+ *
267
+ * @example
268
+ * const { refund } = await zs.directBookings.cancel(bookingId, { refund: "full", reason: "Overbooked" });
269
+ */
270
+ cancel: (bookingId: number, body?: DirectBookingCancel, options?: WriteOptions) => Promise<DirectBookingCancelResult>;
249
271
  };
250
272
  readonly sandbox: {
251
273
  bookings: {
@@ -567,6 +567,28 @@ class ZimmerStack {
567
567
  * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
568
568
  */
569
569
  all: (query, options) => this.#allPages((cursor) => this.directBookings.list({ limit: 100, ...query, cursor }, options)),
570
+ /**
571
+ * Cancel a whole website booking that is still UPCOMING, and say what the guest gets back. Scope
572
+ * `direct-bookings:cancel`, granted on its own and never by default.
573
+ *
574
+ * `refund`: `"policy"` (the default) is what the booking's own cancellation policy gives back now, as
575
+ * if the guest cancelled on the booking page; `"full"` is everything the guest paid online (the hotel
576
+ * is at fault: an overbooking); `"none"` moves no money (the hotel settles it another way). The refund
577
+ * goes back to the guest's online payment and never exceeds it. The answer's `refund` says how much
578
+ * and where it stands (NONE, PENDING, PROCESSED, MANUAL).
579
+ *
580
+ * IT MOVES A GUEST'S MONEY. Call it from a person's own cancel button, with the refund they chose;
581
+ * never from a loop, a sync job or a test against a live key. A booking already cancelled answers
582
+ * `replay: true` and moves no money; checked in, checked out or a no-show is BOOKING_NOT_CANCELLABLE.
583
+ * Your own cancel comes back as `direct.booking.cancelled` ("Cancelled by the hotel"): treat it as
584
+ * already applied. The call carries an idempotency key (yours, or one the client makes) and a retry
585
+ * after a network failure reuses it, so a cancel never lands twice; pass your own `idempotencyKey`
586
+ * when a retry may come from another process.
587
+ *
588
+ * @example
589
+ * const { refund } = await zs.directBookings.cancel(bookingId, { refund: "full", reason: "Overbooked" });
590
+ */
591
+ cancel: (bookingId, body = {}, options) => this.request("POST /direct-bookings/{bookingId}/cancel", { path: { bookingId }, body, ...options }),
570
592
  };
571
593
  /** Follow a booking list's `nextCursor` to its last page. */
572
594
  async *#allPages(read) {
@@ -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.3.0";
2
+ export declare const SDK_VERSION = "0.4.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";
@@ -21,6 +21,8 @@ export declare const LIMITS: {
21
21
  readonly bookingsPerMinute: 20;
22
22
  readonly propertyBookingsPerMinute: 40;
23
23
  readonly propertyBookingsPerDay: 500;
24
+ readonly directCancelsPerMinute: 10;
25
+ readonly propertyDirectCancelsPerDay: 50;
24
26
  readonly companyRequestsPerMinute: 1200;
25
27
  readonly maxNightsPerBooking: 90;
26
28
  };
@@ -28,7 +30,7 @@ export declare const LIMITS: {
28
30
  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
31
  export type ErrorCode = (typeof ERROR_CODES)[number];
30
32
  /** 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", "direct-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
33
+ export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "direct-bookings:read", "direct-bookings:cancel", "bookings:read", "bookings:write", "bookings:payments"];
32
34
  export type Scope = (typeof SCOPES)[number];
33
35
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
34
36
  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.";
@@ -846,6 +848,96 @@ export interface ChannelBooking {
846
848
  createdAt: string;
847
849
  updatedAt: string;
848
850
  }
851
+ export interface DirectBookingCancel {
852
+ /** policy (the default): what the booking's own cancellation policy gives back now, the same as the guest cancelling on the booking page. full: everything the guest paid online. none: nothing; the hotel settles any money itself. */
853
+ refund?: "policy" | "full" | "none";
854
+ /** Why; kept on the booking's activity log in ZimmerStack */
855
+ reason?: string;
856
+ }
857
+ export interface DirectBookingCancelResult {
858
+ /** The booking after the cancel, the webhook's shape: status CANCELLED, every room CANCELLED */
859
+ booking: {
860
+ id: number;
861
+ reference: string;
862
+ status: "CONFIRMED" | "CANCELLED";
863
+ stayStatus: string;
864
+ channel: {
865
+ otaName: string;
866
+ otaReservationCode: string;
867
+ source: string;
868
+ sourceGroup: string;
869
+ };
870
+ stay: {
871
+ checkIn: string;
872
+ checkOut: string;
873
+ nights: number;
874
+ dayUse: boolean;
875
+ };
876
+ guest: {
877
+ fullName: string;
878
+ firstName: string | null;
879
+ lastName: string | null;
880
+ phone?: string | null;
881
+ email?: string | null;
882
+ country: string | null;
883
+ language: string | null;
884
+ };
885
+ guestNotes: string | null;
886
+ occupancy: {
887
+ adults: number;
888
+ children: number;
889
+ };
890
+ rooms: Array<{
891
+ roomTypeId: number;
892
+ roomTypeName: string;
893
+ ratePlanId?: number | null;
894
+ mealPlan: "EP" | "CP" | "MAP" | "AP";
895
+ adults: number;
896
+ children: number;
897
+ checkIn: string;
898
+ checkOut: string;
899
+ nights: number;
900
+ dayUse: boolean;
901
+ ratePerNight: number;
902
+ amount: number;
903
+ status: string;
904
+ }>;
905
+ amounts: {
906
+ currency: string;
907
+ total: number;
908
+ paid: number;
909
+ balanceDue: number;
910
+ paymentCollect: "ota" | "property" | "unknown";
911
+ };
912
+ finance: {
913
+ otaName: string;
914
+ amountBasis: string;
915
+ currency: string | null;
916
+ grossAmount: number | null;
917
+ commissionAmount: number | null;
918
+ taxAmount: number | null;
919
+ netPayoutAmount: number | null;
920
+ } | null;
921
+ cancellation: {
922
+ at: string;
923
+ reason: string | null;
924
+ } | null;
925
+ createdAt: string;
926
+ updatedAt: string;
927
+ };
928
+ refund: {
929
+ /** The refund this call asked for; null on a replay */
930
+ requested: "policy" | "full" | "none" | null;
931
+ /** What the guest gets back, in currency's major units (1998.5 = ₹1,998.50); 0 when nothing is owed */
932
+ amount: number;
933
+ /** ISO 4217, the property's currency */
934
+ currency: string;
935
+ /** NONE: nothing owed. PROCESSED: the payment gateway accepted the refund. PENDING: the refund is recorded and on its way (the gateway is processing it, or ZimmerStack issues it by hand). MANUAL: money is owed but there is no online payment to refund against; the hotel settles it. */
936
+ status: "NONE" | "PENDING" | "PROCESSED" | "MANUAL";
937
+ };
938
+ /** true: the booking was already cancelled; nothing changed and no money moved */
939
+ replay: boolean;
940
+ }
849
941
  export interface SandboxBooking {
850
942
  /** The PMS booking id, the one the webhook carries */
851
943
  bookingId: number;
@@ -854,6 +946,7 @@ export interface SandboxBooking {
854
946
  /** The pretend channel-side id */
855
947
  channelBookingId: string;
856
948
  otaName: string;
949
+ /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */
857
950
  status: "UPCOMING" | "CANCELLED";
858
951
  guestName: string;
859
952
  checkIn: string;
@@ -861,9 +954,9 @@ export interface SandboxBooking {
861
954
  nights: number;
862
955
  rooms: number;
863
956
  roomTypeId: number;
864
- /** Major units, per room per night */
957
+ /** Major units, per room per night: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */
865
958
  nightlyRate: number;
866
- /** Major units */
959
+ /** Major units: every night's price × rooms */
867
960
  total: number;
868
961
  currency: string;
869
962
  paidByOta: boolean;
@@ -887,6 +980,7 @@ export interface SandboxBookingsList {
887
980
  /** The pretend channel-side id */
888
981
  channelBookingId: string;
889
982
  otaName: string;
983
+ /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */
890
984
  status: "UPCOMING" | "CANCELLED";
891
985
  guestName: string;
892
986
  checkIn: string;
@@ -894,9 +988,9 @@ export interface SandboxBookingsList {
894
988
  nights: number;
895
989
  rooms: number;
896
990
  roomTypeId: number;
897
- /** Major units, per room per night */
991
+ /** Major units, per room per night: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */
898
992
  nightlyRate: number;
899
- /** Major units */
993
+ /** Major units: every night's price × rooms */
900
994
  total: number;
901
995
  currency: string;
902
996
  paidByOta: boolean;
@@ -1124,6 +1218,15 @@ export interface Operations {
1124
1218
  body: undefined;
1125
1219
  response: ChannelBooking;
1126
1220
  };
1221
+ /** Cancel a website booking and refund it: per its policy, in full, or not at all */
1222
+ "POST /direct-bookings/{bookingId}/cancel": {
1223
+ path: {
1224
+ bookingId: string | number;
1225
+ };
1226
+ query: undefined;
1227
+ body: DirectBookingCancel;
1228
+ response: DirectBookingCancelResult;
1229
+ };
1127
1230
  /** Simulated OTA bookings on the sandbox, newest first */
1128
1231
  "GET /sandbox/bookings": {
1129
1232
  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.3.0";
7
+ exports.SDK_VERSION = "0.4.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";
@@ -26,6 +26,8 @@ exports.LIMITS = {
26
26
  "bookingsPerMinute": 20,
27
27
  "propertyBookingsPerMinute": 40,
28
28
  "propertyBookingsPerDay": 500,
29
+ "directCancelsPerMinute": 10,
30
+ "propertyDirectCancelsPerDay": 50,
29
31
  "companyRequestsPerMinute": 1200,
30
32
  "maxNightsPerBooking": 90
31
33
  };
@@ -97,6 +99,7 @@ exports.SCOPES = [
97
99
  "channel-modifiers:write",
98
100
  "channel-bookings:read",
99
101
  "direct-bookings:read",
102
+ "direct-bookings:cancel",
100
103
  "bookings:read",
101
104
  "bookings:write",
102
105
  "bookings:payments"
@@ -130,6 +133,7 @@ exports.OPERATIONS = {
130
133
  "GET /channel-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
131
134
  "GET /direct-bookings": { idempotent: false, bodyRequired: false },
132
135
  "GET /direct-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
136
+ "POST /direct-bookings/{bookingId}/cancel": { idempotent: true, bodyRequired: false },
133
137
  "GET /sandbox/bookings": { idempotent: false, bodyRequired: false },
134
138
  "POST /sandbox/bookings": { idempotent: true, bodyRequired: true },
135
139
  "POST /sandbox/bookings/{bookingId}/cancel": { idempotent: false, bodyRequired: false },
@@ -1,4 +1,4 @@
1
- import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
1
+ import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type DirectBookingCancel, type DirectBookingCancelResult, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
2
2
  import { type Grid, type GridEdits, type ModifierStep } from "./grid.js";
3
3
  export interface ZimmerStackOptions {
4
4
  /**
@@ -246,6 +246,28 @@ export declare class ZimmerStack {
246
246
  * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
247
247
  */
248
248
  all: (query?: Omit<NonNullable<Op<"GET /direct-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
249
+ /**
250
+ * Cancel a whole website booking that is still UPCOMING, and say what the guest gets back. Scope
251
+ * `direct-bookings:cancel`, granted on its own and never by default.
252
+ *
253
+ * `refund`: `"policy"` (the default) is what the booking's own cancellation policy gives back now, as
254
+ * if the guest cancelled on the booking page; `"full"` is everything the guest paid online (the hotel
255
+ * is at fault: an overbooking); `"none"` moves no money (the hotel settles it another way). The refund
256
+ * goes back to the guest's online payment and never exceeds it. The answer's `refund` says how much
257
+ * and where it stands (NONE, PENDING, PROCESSED, MANUAL).
258
+ *
259
+ * IT MOVES A GUEST'S MONEY. Call it from a person's own cancel button, with the refund they chose;
260
+ * never from a loop, a sync job or a test against a live key. A booking already cancelled answers
261
+ * `replay: true` and moves no money; checked in, checked out or a no-show is BOOKING_NOT_CANCELLABLE.
262
+ * Your own cancel comes back as `direct.booking.cancelled` ("Cancelled by the hotel"): treat it as
263
+ * already applied. The call carries an idempotency key (yours, or one the client makes) and a retry
264
+ * after a network failure reuses it, so a cancel never lands twice; pass your own `idempotencyKey`
265
+ * when a retry may come from another process.
266
+ *
267
+ * @example
268
+ * const { refund } = await zs.directBookings.cancel(bookingId, { refund: "full", reason: "Overbooked" });
269
+ */
270
+ cancel: (bookingId: number, body?: DirectBookingCancel, options?: WriteOptions) => Promise<DirectBookingCancelResult>;
249
271
  };
250
272
  readonly sandbox: {
251
273
  bookings: {
@@ -564,6 +564,28 @@ export class ZimmerStack {
564
564
  * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
565
565
  */
566
566
  all: (query, options) => this.#allPages((cursor) => this.directBookings.list({ limit: 100, ...query, cursor }, options)),
567
+ /**
568
+ * Cancel a whole website booking that is still UPCOMING, and say what the guest gets back. Scope
569
+ * `direct-bookings:cancel`, granted on its own and never by default.
570
+ *
571
+ * `refund`: `"policy"` (the default) is what the booking's own cancellation policy gives back now, as
572
+ * if the guest cancelled on the booking page; `"full"` is everything the guest paid online (the hotel
573
+ * is at fault: an overbooking); `"none"` moves no money (the hotel settles it another way). The refund
574
+ * goes back to the guest's online payment and never exceeds it. The answer's `refund` says how much
575
+ * and where it stands (NONE, PENDING, PROCESSED, MANUAL).
576
+ *
577
+ * IT MOVES A GUEST'S MONEY. Call it from a person's own cancel button, with the refund they chose;
578
+ * never from a loop, a sync job or a test against a live key. A booking already cancelled answers
579
+ * `replay: true` and moves no money; checked in, checked out or a no-show is BOOKING_NOT_CANCELLABLE.
580
+ * Your own cancel comes back as `direct.booking.cancelled` ("Cancelled by the hotel"): treat it as
581
+ * already applied. The call carries an idempotency key (yours, or one the client makes) and a retry
582
+ * after a network failure reuses it, so a cancel never lands twice; pass your own `idempotencyKey`
583
+ * when a retry may come from another process.
584
+ *
585
+ * @example
586
+ * const { refund } = await zs.directBookings.cancel(bookingId, { refund: "full", reason: "Overbooked" });
587
+ */
588
+ cancel: (bookingId, body = {}, options) => this.request("POST /direct-bookings/{bookingId}/cancel", { path: { bookingId }, body, ...options }),
567
589
  };
568
590
  /** Follow a booking list's `nextCursor` to its last page. */
569
591
  async *#allPages(read) {
@@ -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.3.0";
2
+ export declare const SDK_VERSION = "0.4.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";
@@ -21,6 +21,8 @@ export declare const LIMITS: {
21
21
  readonly bookingsPerMinute: 20;
22
22
  readonly propertyBookingsPerMinute: 40;
23
23
  readonly propertyBookingsPerDay: 500;
24
+ readonly directCancelsPerMinute: 10;
25
+ readonly propertyDirectCancelsPerDay: 50;
24
26
  readonly companyRequestsPerMinute: 1200;
25
27
  readonly maxNightsPerBooking: 90;
26
28
  };
@@ -28,7 +30,7 @@ export declare const LIMITS: {
28
30
  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
31
  export type ErrorCode = (typeof ERROR_CODES)[number];
30
32
  /** 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", "direct-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
33
+ export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "direct-bookings:read", "direct-bookings:cancel", "bookings:read", "bookings:write", "bookings:payments"];
32
34
  export type Scope = (typeof SCOPES)[number];
33
35
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
34
36
  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.";
@@ -846,6 +848,96 @@ export interface ChannelBooking {
846
848
  createdAt: string;
847
849
  updatedAt: string;
848
850
  }
851
+ export interface DirectBookingCancel {
852
+ /** policy (the default): what the booking's own cancellation policy gives back now, the same as the guest cancelling on the booking page. full: everything the guest paid online. none: nothing; the hotel settles any money itself. */
853
+ refund?: "policy" | "full" | "none";
854
+ /** Why; kept on the booking's activity log in ZimmerStack */
855
+ reason?: string;
856
+ }
857
+ export interface DirectBookingCancelResult {
858
+ /** The booking after the cancel, the webhook's shape: status CANCELLED, every room CANCELLED */
859
+ booking: {
860
+ id: number;
861
+ reference: string;
862
+ status: "CONFIRMED" | "CANCELLED";
863
+ stayStatus: string;
864
+ channel: {
865
+ otaName: string;
866
+ otaReservationCode: string;
867
+ source: string;
868
+ sourceGroup: string;
869
+ };
870
+ stay: {
871
+ checkIn: string;
872
+ checkOut: string;
873
+ nights: number;
874
+ dayUse: boolean;
875
+ };
876
+ guest: {
877
+ fullName: string;
878
+ firstName: string | null;
879
+ lastName: string | null;
880
+ phone?: string | null;
881
+ email?: string | null;
882
+ country: string | null;
883
+ language: string | null;
884
+ };
885
+ guestNotes: string | null;
886
+ occupancy: {
887
+ adults: number;
888
+ children: number;
889
+ };
890
+ rooms: Array<{
891
+ roomTypeId: number;
892
+ roomTypeName: string;
893
+ ratePlanId?: number | null;
894
+ mealPlan: "EP" | "CP" | "MAP" | "AP";
895
+ adults: number;
896
+ children: number;
897
+ checkIn: string;
898
+ checkOut: string;
899
+ nights: number;
900
+ dayUse: boolean;
901
+ ratePerNight: number;
902
+ amount: number;
903
+ status: string;
904
+ }>;
905
+ amounts: {
906
+ currency: string;
907
+ total: number;
908
+ paid: number;
909
+ balanceDue: number;
910
+ paymentCollect: "ota" | "property" | "unknown";
911
+ };
912
+ finance: {
913
+ otaName: string;
914
+ amountBasis: string;
915
+ currency: string | null;
916
+ grossAmount: number | null;
917
+ commissionAmount: number | null;
918
+ taxAmount: number | null;
919
+ netPayoutAmount: number | null;
920
+ } | null;
921
+ cancellation: {
922
+ at: string;
923
+ reason: string | null;
924
+ } | null;
925
+ createdAt: string;
926
+ updatedAt: string;
927
+ };
928
+ refund: {
929
+ /** The refund this call asked for; null on a replay */
930
+ requested: "policy" | "full" | "none" | null;
931
+ /** What the guest gets back, in currency's major units (1998.5 = ₹1,998.50); 0 when nothing is owed */
932
+ amount: number;
933
+ /** ISO 4217, the property's currency */
934
+ currency: string;
935
+ /** NONE: nothing owed. PROCESSED: the payment gateway accepted the refund. PENDING: the refund is recorded and on its way (the gateway is processing it, or ZimmerStack issues it by hand). MANUAL: money is owed but there is no online payment to refund against; the hotel settles it. */
936
+ status: "NONE" | "PENDING" | "PROCESSED" | "MANUAL";
937
+ };
938
+ /** true: the booking was already cancelled; nothing changed and no money moved */
939
+ replay: boolean;
940
+ }
849
941
  export interface SandboxBooking {
850
942
  /** The PMS booking id, the one the webhook carries */
851
943
  bookingId: number;
@@ -854,6 +946,7 @@ export interface SandboxBooking {
854
946
  /** The pretend channel-side id */
855
947
  channelBookingId: string;
856
948
  otaName: string;
949
+ /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */
857
950
  status: "UPCOMING" | "CANCELLED";
858
951
  guestName: string;
859
952
  checkIn: string;
@@ -861,9 +954,9 @@ export interface SandboxBooking {
861
954
  nights: number;
862
955
  rooms: number;
863
956
  roomTypeId: number;
864
- /** Major units, per room per night */
957
+ /** Major units, per room per night: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */
865
958
  nightlyRate: number;
866
- /** Major units */
959
+ /** Major units: every night's price × rooms */
867
960
  total: number;
868
961
  currency: string;
869
962
  paidByOta: boolean;
@@ -887,6 +980,7 @@ export interface SandboxBookingsList {
887
980
  /** The pretend channel-side id */
888
981
  channelBookingId: string;
889
982
  otaName: string;
983
+ /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */
890
984
  status: "UPCOMING" | "CANCELLED";
891
985
  guestName: string;
892
986
  checkIn: string;
@@ -894,9 +988,9 @@ export interface SandboxBookingsList {
894
988
  nights: number;
895
989
  rooms: number;
896
990
  roomTypeId: number;
897
- /** Major units, per room per night */
991
+ /** Major units, per room per night: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */
898
992
  nightlyRate: number;
899
- /** Major units */
993
+ /** Major units: every night's price × rooms */
900
994
  total: number;
901
995
  currency: string;
902
996
  paidByOta: boolean;
@@ -1124,6 +1218,15 @@ export interface Operations {
1124
1218
  body: undefined;
1125
1219
  response: ChannelBooking;
1126
1220
  };
1221
+ /** Cancel a website booking and refund it: per its policy, in full, or not at all */
1222
+ "POST /direct-bookings/{bookingId}/cancel": {
1223
+ path: {
1224
+ bookingId: string | number;
1225
+ };
1226
+ query: undefined;
1227
+ body: DirectBookingCancel;
1228
+ response: DirectBookingCancelResult;
1229
+ };
1127
1230
  /** Simulated OTA bookings on the sandbox, newest first */
1128
1231
  "GET /sandbox/bookings": {
1129
1232
  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.3.0";
4
+ export const SDK_VERSION = "0.4.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";
@@ -23,6 +23,8 @@ export const LIMITS = {
23
23
  "bookingsPerMinute": 20,
24
24
  "propertyBookingsPerMinute": 40,
25
25
  "propertyBookingsPerDay": 500,
26
+ "directCancelsPerMinute": 10,
27
+ "propertyDirectCancelsPerDay": 50,
26
28
  "companyRequestsPerMinute": 1200,
27
29
  "maxNightsPerBooking": 90
28
30
  };
@@ -94,6 +96,7 @@ export const SCOPES = [
94
96
  "channel-modifiers:write",
95
97
  "channel-bookings:read",
96
98
  "direct-bookings:read",
99
+ "direct-bookings:cancel",
97
100
  "bookings:read",
98
101
  "bookings:write",
99
102
  "bookings:payments"
@@ -127,6 +130,7 @@ export const OPERATIONS = {
127
130
  "GET /channel-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
128
131
  "GET /direct-bookings": { idempotent: false, bodyRequired: false },
129
132
  "GET /direct-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
133
+ "POST /direct-bookings/{bookingId}/cancel": { idempotent: true, bodyRequired: false },
130
134
  "GET /sandbox/bookings": { idempotent: false, bodyRequired: false },
131
135
  "POST /sandbox/bookings": { idempotent: true, bodyRequired: true },
132
136
  "POST /sandbox/bookings/{bookingId}/cancel": { idempotent: false, bodyRequired: false },
@@ -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## 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";
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- `zs.directBookings.cancel(bookingId, { refund, reason })` cancels a whole website booking that is\n still UPCOMING, and moves the guest's money (scope `direct-bookings:cancel`, granted on its own).\n `refund` is `\"policy\"` (the default: what the booking's own cancellation policy gives back, as if the\n guest cancelled), `\"full\"` (everything paid online: the hotel is at fault, an overbooking) or\n `\"none\"` (the hotel settles the money itself). Call it only from a person's own cancel button, with\n the refund they chose on the screen; never from a loop, a sync job or a test against a live key.\n Show `refund.amount` and `refund.status` from the answer. `BOOKING_NOT_CANCELLABLE` (checked in,\n checked out, a no-show) goes to the hotel's desk; do not retry it. `replay: true` means it was\n already cancelled and no money moved. Your own cancel comes back as `direct.booking.cancelled`\n (\"Cancelled by the hotel\"): match it on the booking id and treat it as already applied.\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- [ ] A website booking is cancelled only from a person's own action, with the refund they chose.\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",
@@ -1983,6 +1983,121 @@ export const REFERENCE = {
1983
1983
  }
1984
1984
  ]
1985
1985
  },
1986
+ {
1987
+ "key": "POST /direct-bookings/{bookingId}/cancel",
1988
+ "summary": "Cancel a website booking and refund it: per its policy, in full, or not at all",
1989
+ "description": "Scope direct-bookings:cancel (granted on its own, never by default). The whole booking, while it is UPCOMING: the nights go back on sale, the guest gets the usual cancellation message and direct.booking.cancelled says \"Cancelled by the hotel\". refund decides the money (x-zimmerstack.directBookings.cancel); the answer says what the guest gets back and its status. Idempotent: an already-cancelled booking answers 200 with replay: true and moves no money.",
1990
+ "scope": "direct-bookings:cancel",
1991
+ "call": "zs.directBookings.cancel(bookingId, body)",
1992
+ "path": [
1993
+ "bookingId"
1994
+ ],
1995
+ "query": [],
1996
+ "body": "DirectBookingCancel",
1997
+ "response": "DirectBookingCancelResult",
1998
+ "answerStatus": [
1999
+ 200
2000
+ ],
2001
+ "idempotent": true,
2002
+ "request": {
2003
+ "refund": "policy",
2004
+ "reason": "Guest phoned the front desk to cancel"
2005
+ },
2006
+ "answer": {
2007
+ "booking": {
2008
+ "id": 100001,
2009
+ "reference": "TEST-WEB-4H7P9D",
2010
+ "status": "CANCELLED",
2011
+ "stayStatus": "UPCOMING",
2012
+ "channel": {
2013
+ "otaName": "Website",
2014
+ "otaReservationCode": "TEST-WEB-4H7P9D",
2015
+ "source": "DIRECT_WEB",
2016
+ "sourceGroup": "DIRECT"
2017
+ },
2018
+ "stay": {
2019
+ "checkIn": "2026-11-13",
2020
+ "checkOut": "2026-11-15",
2021
+ "nights": 2,
2022
+ "dayUse": false
2023
+ },
2024
+ "guest": {
2025
+ "fullName": "Asha Verma",
2026
+ "firstName": "Asha",
2027
+ "lastName": "Verma",
2028
+ "phone": "+919876500000",
2029
+ "email": "asha.verma@example.com",
2030
+ "country": "IN",
2031
+ "language": "en"
2032
+ },
2033
+ "guestNotes": null,
2034
+ "occupancy": {
2035
+ "adults": 2,
2036
+ "children": 0
2037
+ },
2038
+ "rooms": [
2039
+ {
2040
+ "roomTypeId": 412,
2041
+ "ratePlanId": 901,
2042
+ "roomTypeName": "Deluxe Sea View",
2043
+ "mealPlan": "CP",
2044
+ "adults": 2,
2045
+ "children": 0,
2046
+ "checkIn": "2026-11-13",
2047
+ "checkOut": "2026-11-15",
2048
+ "nights": 2,
2049
+ "dayUse": false,
2050
+ "ratePerNight": 2700,
2051
+ "amount": 5400,
2052
+ "status": "CANCELLED"
2053
+ }
2054
+ ],
2055
+ "amounts": {
2056
+ "currency": "INR",
2057
+ "total": 5400,
2058
+ "paid": 1080,
2059
+ "balanceDue": 4320,
2060
+ "paymentCollect": "property"
2061
+ },
2062
+ "finance": null,
2063
+ "cancellation": {
2064
+ "at": "2026-10-31T09:15:00.000Z",
2065
+ "reason": "Cancelled by the hotel"
2066
+ },
2067
+ "createdAt": "2026-10-30T12:00:00.000Z",
2068
+ "updatedAt": "2026-10-30T12:00:00.000Z"
2069
+ },
2070
+ "refund": {
2071
+ "requested": "policy",
2072
+ "amount": 1080,
2073
+ "currency": "INR",
2074
+ "status": "PROCESSED"
2075
+ },
2076
+ "replay": false
2077
+ },
2078
+ "refusals": [
2079
+ {
2080
+ "status": 401,
2081
+ "description": "Missing, malformed, unknown or revoked key (data.code API_KEY_INVALID | API_KEY_REVOKED)"
2082
+ },
2083
+ {
2084
+ "status": 403,
2085
+ "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)"
2086
+ },
2087
+ {
2088
+ "status": 404,
2089
+ "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"
2090
+ },
2091
+ {
2092
+ "status": 409,
2093
+ "description": "Checked in, checked out or a no-show: the hotel handles it at the desk"
2094
+ },
2095
+ {
2096
+ "status": 429,
2097
+ "description": "data.scope direct-cancels (10 per key per minute) or property-direct-cancels-day (50 per property per rolling day); honour Retry-After"
2098
+ }
2099
+ ]
2100
+ },
1986
2101
  {
1987
2102
  "key": "GET /sandbox/bookings",
1988
2103
  "summary": "Simulated OTA bookings on the sandbox, newest first",
@@ -2294,22 +2409,24 @@ export const REFERENCE = {
2294
2409
  "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}",
2295
2410
  "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}",
2296
2411
  "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}",
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}"
2412
+ "DirectBookingCancel": "export interface DirectBookingCancel {\n /** policy (the default): what the booking's own cancellation policy gives back now, the same as the guest cancelling on the booking page. full: everything the guest paid online. none: nothing; the hotel settles any money itself. */\n refund?: \"policy\" | \"full\" | \"none\";\n /** Why; kept on the booking's activity log in ZimmerStack */\n reason?: string;\n}",
2413
+ "DirectBookingCancelResult": "export interface DirectBookingCancelResult {\n /** The booking after the cancel, the webhook's shape: status CANCELLED, every room CANCELLED */\n booking: {\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 refund: {\n /** The refund this call asked for; null on a replay */\n requested: \"policy\" | \"full\" | \"none\" | null;\n /** What the guest gets back, in currency's major units (1998.5 = ₹1,998.50); 0 when nothing is owed */\n amount: number;\n /** ISO 4217, the property's currency */\n currency: string;\n /** NONE: nothing owed. PROCESSED: the payment gateway accepted the refund. PENDING: the refund is recorded and on its way (the gateway is processing it, or ZimmerStack issues it by hand). MANUAL: money is owed but there is no online payment to refund against; the hotel settles it. */\n status: \"NONE\" | \"PENDING\" | \"PROCESSED\" | \"MANUAL\";\n };\n /** true: the booking was already cancelled; nothing changed and no money moved */\n replay: boolean;\n}",
2414
+ "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 /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */\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: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */\n nightlyRate: number;\n /** Major units: every night's price × rooms */\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}",
2415
+ "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 /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */\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: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */\n nightlyRate: number;\n /** Major units: every night's price × rooms */\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}"
2299
2416
  },
2300
2417
  "topics": {
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",
2418
+ "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: direct-bookings:cancel · does: Cancel a booking guests made on the hotel's own website and refund it: per the booking's policy, in full, or not at all\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, direct-bookings:cancel. 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",
2302
2419
  "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",
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",
2420
+ "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\ndirectCancelsPerMinute: 10\npropertyDirectCancelsPerDay: 50\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: direct-cancels · perMinute: 10 · counts: POST /direct-bookings/{bookingId}/cancel on one key (a replay is not counted)\n - scope: property-direct-cancels-day · perMinute: 50 · counts: POST /direct-bookings/{bookingId}/cancel per property per ROLLING 24 HOURS (not per minute)\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",
2304
2421
  "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",
2305
2422
  "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",
2306
2423
  "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",
2307
2424
  "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",
2425
+ "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 or through POST /direct-bookings/{bookingId}/cancel; cancellation.reason says which (\"Cancelled by the guest\" or \"Cancelled by the hotel\"). A cancel your own PMS made comes back to you as this event too: match it on the booking id and treat it as already applied. 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.\ncancel: POST /direct-bookings/{bookingId}/cancel cancels a whole website booking that is still UPCOMING and says what the guest gets back: refund \"policy\" (the default: what the booking's own cancellation policy gives now, exactly as if the guest cancelled on the booking page), \"full\" (everything paid online) or \"none\" (the hotel settles any money itself). The refund goes back to the guest's online payment, never more than it; the hotel's share of that payment is taken back first. The nights go back on sale on the channels, the guest gets the usual cancellation message, and direct.booking.cancelled says \"Cancelled by the hotel\". Scope direct-bookings:cancel, granted on its own and never by default. A checked-in, checked-out or no-show booking is 409 BOOKING_NOT_CANCELLABLE; an already-cancelled one answers 200 with replay: true and moves no money. Send x-idempotency-key: a retry with the same key gets the first answer back. Budgets: 10 per key per minute, 50 per property per rolling day.\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. POST /direct-bookings/{bookingId}/cancel works on a sandbox website booking with a test key: the nights come back and the event says \"Cancelled by the hotel\", and no money moves (refund.status NONE).\n\n",
2309
2426
  "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",
2310
2427
  "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",
2311
2428
  "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",
2312
2429
  "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"
2430
+ "the-package": "@zimmerstack/connect 0.4.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"
2314
2431
  }
2315
2432
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zimmerstack/connect",
3
- "version": "0.3.0",
3
+ "version": "0.4.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",