StayBindDevelopers
Get started

Quickstart

From an API key to a confirmed booking in four calls, using nothing but HTTP.

This walks the full happy path: find a property, check availability, price the stay, and book it. Every call uses the API key from the previous page.

Calling convention

The Booking API speaks tRPC over HTTP with plain JSON (no transformer). Queries are GET /public/trpc/<procedure>?input=<url-encoded JSON>; mutations are POST /public/trpc/<procedure> with the input as the JSON body. Every successful response is wrapped as {"result":{"data": …}}. Full details and the error shape are in Booking API → Overview.

1. List properties

A no-input query, so there is nothing to encode:

curl https://api.staybind.com/public/trpc/properties \
  -H "x-api-key: $STAYBIND_API_KEY"
{
  "result": {
    "data": [
      { "id": "prop_haveli", "name": "Jaipur Haveli", "status": "active" }
    ]
  }
}

2. Search availability

A query with input, so the JSON is URL-encoded into ?input=:

INPUT='{"propertyId":"prop_haveli","checkIn":"2026-02-20","checkOut":"2026-02-22"}'
curl -G https://api.staybind.com/public/trpc/searchAvailability \
  -H "x-api-key: $STAYBIND_API_KEY" \
  --data-urlencode "input=$INPUT"
{
  "result": {
    "data": [
      { "unitId": "unit_courtyard", "unitName": "Courtyard Suite" }
    ]
  }
}

Only units that are free for the whole range are returned. Check-out is exclusive, so this asks for the nights of the 20th and 21st.

3. Get a server-priced quote

Pricing is computed by StayBind (nights × the unit's rate), never trusted from the client. Show this to the guest before they commit; the same amount is charged at checkout.

INPUT='{"unitId":"unit_courtyard","checkIn":"2026-02-20","checkOut":"2026-02-22"}'
curl -G https://api.staybind.com/public/trpc/quote \
  -H "x-api-key: $STAYBIND_API_KEY" \
  --data-urlencode "input=$INPUT"
{ "result": { "data": { "nights": 2, "subtotalMinor": 1500000, "currency": "INR" } } }

subtotalMinor is paise: 1500000 is ₹15,000.00.

4. Create the booking

A mutation, so the input goes in the body:

curl -X POST https://api.staybind.com/public/trpc/createBooking \
  -H "x-api-key: $STAYBIND_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "propertyId": "prop_haveli",
    "unitId": "unit_courtyard",
    "guest": { "name": "Aarav Sharma", "phone": "+919812345678" },
    "checkIn": "2026-02-20",
    "checkOut": "2026-02-22"
  }'
{ "result": { "data": { "id": "bk_2Xq…", "status": "confirmed", "unitId": "unit_courtyard" } } }

The booking defaults to confirmed, which writes the ledger hold and fans the new availability out to every other connected channel, within seconds. If those nights were taken in the meantime, the call returns CONFLICT (HTTP 409) instead of double-booking.

Taking payment instead

To collect money before holding the calendar, use createCheckout instead of createBooking. It opens the booking as a non-blocking enquiry and returns a payment URL; the calendar is committed only when the payment is captured. See Booking API → Bookings & checkout.

Using a typed client

If you build in TypeScript and can depend on StayBind's published router types, you can use a typed tRPC client and skip hand-writing URLs:

client.ts
import { createTRPCClient, httpLink } from "@trpc/client";
import type { PublicApiRouter } from "@staybind/api";

export const staybind = createTRPCClient<PublicApiRouter>({
  links: [
    httpLink({
      url: "https://api.staybind.com/public/trpc",
      headers: { "x-api-key": process.env.STAYBIND_API_KEY! },
    }),
  ],
});

const units = await staybind.searchAvailability.query({
  propertyId: "prop_haveli",
  checkIn: "2026-02-20",
  checkOut: "2026-02-22",
});

Raw HTTP works from any language and is the safe default; the typed client is a convenience for TypeScript codebases.

Next steps

On this page