Sign in for interactive examples and your API keys.
Get free API keys
DocsWebhooks

Webhooks

Receive booking lifecycle events via signed POST requests to your endpoint.

Overview

BookRails sends HMAC-SHA256 signed POST requests to your endpoint on every booking lifecycle event. Events are retried with exponential backoff for up to 72 hours.

Verify & handle

javascript
import { verifySignature } from "@bookrails/sdk";

app.post("/hooks/bookrails", express.raw({ type: "application/json" }), (req, res) => {
  const sig = req.headers["bookrails-signature"];
  let event;

  try {
    event = verifySignature(req.body, sig, process.env.BOOKRAILS_WEBHOOK_SECRET);
  } catch (err) {
    return res.status(400).send("Invalid signature");
  }

  switch (event.type) {
    case "booking.created":
      await handleNewBooking(event.data);
      break;
    case "booking.no_show":
      await notifyAgent(event.data.agentId);
      break;
  }

  res.sendStatus(200);
});

Event types

EventWhen
booking.createdA new booking is made by an agent
booking.confirmedBusiness confirms (auto or manual)
booking.cancelledBooking is cancelled by any party
booking.no_showBusiness marks customer as no-show
booking.completedService completed; outcome recorded
booking.rescheduledSlot changed by agent or business