Hooks API
Hook callbacks that fire at key points in the booking lifecycle — beforeBookingCreate, afterBookingConfirm, afterStatusChange, and more.
The plugin exposes hook callbacks that fire at key points in the booking lifecycle. Register them in the hooks option. All hooks receive the req object (Payload request) so you have access to the full Payload instance and request context.
Each hook type is an array — hooks fire sequentially.
Escape hatch: All plugin hooks respect context.skipReservationHooks. When you call payload.update() or payload.create() with context: { skipReservationHooks: true }, none of these callbacks fire — including the afterChange hooks that trigger afterBookingCancel, afterBookingConfirm, and afterStatusChange. Use this when your code handles the side-effect (email, payment) itself and must not double-fire.
beforeBookingCreate
Fires before a new reservation is saved via the POST /api/reserve/book endpoint. Can modify the booking data.
Return the (optionally modified) data. Returning undefined keeps the original data.
beforeBookingConfirm
Fires before a reservation transitions to confirmed. Throw an error to block the transition.
The doc contains the merged document ({ ...originalDoc, ...incomingData }), so fields like status reflect the new value being set.
beforeBookingCancel
Fires before a reservation transitions to cancelled. Throw an error to block the cancellation.
The doc contains the merged document ({ ...originalDoc, ...incomingData }). The reason is passed as a separate parameter from the incoming cancellation data.
afterBookingCreate
Fires after a new reservation is saved to the database.
afterBookingConfirm
Fires after a reservation transitions to confirmed. Errors thrown in after-hooks are caught and logged — they do not cause the API response to fail.
afterBookingCancel
Fires after a reservation transitions to cancelled. Errors thrown in after-hooks are caught and logged — they do not cause the API response to fail.
afterStatusChange
Generic hook that fires on every status transition. Errors thrown in after-hooks are caught and logged — they do not cause the API response to fail.