Build an app with OAuth
Build an app that Bookingmood users connect with one click. Your users choose Connect to Bookingmood in your app, sign in to Bookingmood and pick the organizations your app may access. Your app then calls the REST API and receives webhooks on their behalf, without anyone copying an API key.
This guide walks through an app that keeps a copy of each organization's bookings: connecting, the first sync, staying in sync with webhooks, and handling disconnects. For a script that works with one organization of your own, an API key is simpler.
1. Get a client ID and secret
Contact us with:
The name of your app, as users should see it when they connect.
Your logo and the URL of your website.
Your redirect URIs: the URLs in your app that Bookingmood sends users back to after they connect, such as
https://app.example.com/bookingmood/callback. They have to use HTTPS. Add one per environment, for example production and staging.
You get a client_id and a client_secret. The secret is shown once, so store it on your server. If it leaks, ask us for a new one: the old one stops working right away.
Apps that run on the user's device, such as desktop apps and AI assistants, can't keep a secret. They register themselves instead, see Authentication.
2. Choose your scopes
Ask for the least your app needs. The user sees each area on the consent screen and can lower write access to read access, or leave areas out.
| Your app | Scopes |
|---|---|
| Copies bookings | bookings:read webhooks:write offline_access |
| Also changes bookings | bookings:write webhooks:write offline_access |
| Also reads units and prices | add products:read |
offline_access gives a refresh token, so your app keeps access without asking the user again. A webhook can only subscribe to events of data your app may read: bookings.created needs bookings:read, members.created needs organization:read. The API reference shows the scope of each request.
3. Send the user to Bookingmood
When the user chooses Connect to Bookingmood, redirect them to:
https://www.bookingmood.com/oauth/authorize ?response_type=code &client_id=YOUR_CLIENT_ID &redirect_uri=https%3A%2F%2Fapp.example.com%2Fbookingmood%2Fcallback &scope=bookings%3Aread%20webhooks%3Awrite%20offline_access &state=RANDOM_STATE &code_challenge=CODE_CHALLENGE &code_challenge_method=S256
stateis a random value you store in the user's session and check when they come back.code_challengeis PKCE, which every client uses, also those with a secret. Generate a randomcode_verifierof 43 to 128 characters, store it with thestate, and send the base64url-encoded SHA-256 hash of it as the challenge. Most OAuth libraries do this for you.
The user signs in to Bookingmood, picks the organizations your app may access and approves. They can only pick organizations they're an admin of. Bookingmood then redirects to your redirect URI with code and state, or with error=access_denied when the user declined.
A user who already connected your app with these scopes skips the consent screen. Add prompt=consent to show it anyway, for example to let them add an organization.
4. Exchange the code for tokens
From your server, within 5 minutes:
curl https://www.bookingmood.com/oauth/token \ -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \ -d grant_type=authorization_code \ -d code=THE_CODE \ -d code_verifier=THE_CODE_VERIFIER \ -d redirect_uri=https://app.example.com/bookingmood/callback
You can also send client_id and client_secret in the body instead of with HTTP Basic authentication. The response:
{
"access_token": "bmo_at_…",
"expires_in": 3600,
"organizations": [
{ "id": "6f1c…", "name": "Villa Rosa" }
],
"refresh_token": "bmo_rt_…",
"scope": "bookings:read webhooks:write offline_access",
"token_type": "Bearer"
}organizations lists the organizations the tokens reach. Store their ids with the user's account in your app.
5. Call the API
Send the access token as a bearer token:
curl "https://www.bookingmood.com/api/v1/bookings?organization_id=eq.6f1c…" \ -H "Authorization: Bearer bmo_at_…"
A token covers every organization the user connected, so a read returns rows of all of them. Filter on one with organization_id=eq.…, and set organization_id in the body when you create a row.
Changes your app makes show in the organization's activity log as your app, on behalf of the user who connected it.
6. Refresh the access token
Access tokens last an hour. Before one expires, or when a request gets 401, get a new one:
curl https://www.bookingmood.com/oauth/token \ -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \ -d grant_type=refresh_token \ -d refresh_token=bmo_rt_…
The response has a new access token, a new refresh token and the current organizations. Replace both tokens in your database.
A refresh token works once. If two of your workers refresh at the same time, the second one still gets tokens when it comes within 30 seconds of the first. Using a refresh token again after that disconnects your app, since it looks like the token leaked. Refresh in one place, or lock per connection, and keep the newest token.
A refresh token expires 30 days after it was issued. Each refresh gives a new one, so a connection your app uses at least once a month stays connected.
7. Copy the existing bookings
Read each organization's bookings page by page. A request returns at most 1000 rows; see Sorting and pagination.
curl "https://www.bookingmood.com/api/v1/calendar_events?organization_id=eq.6f1c…&select=*,booking:bookings(*)&order=updated_at,id&limit=1000&offset=0" \ -H "Authorization: Bearer bmo_at_…"
The stays of a booking are its calendar events: one per unit, with the dates and the status. The booking holds the guest details and the totals. See Bookings through the API.
Each connection may make 120 requests per minute. The response headers show what's left, and a 429 response has a Retry-After header.
8. Stay in sync with webhooks
Register a webhook in each organization, right after the user connects:
curl "https://www.bookingmood.com/api/v1/webhooks" \
-H "Authorization: Bearer bmo_at_…" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "6f1c…",
"endpoint": "https://app.example.com/bookingmood/webhooks",
"events": ["bookings.created", "bookings.updated", "calendar_events.created", "calendar_events.updated"],
"description": "Sync with Example",
"source": "example"
}'Store the webhook's id and signing_secret from the response, and verify the signature of every event. Each event holds the new and old version of the row, with its organization_id, so you know which connection it belongs to.
Events can arrive more than once, and out of order. Compare updated_at with your copy, or fetch the row again, before you overwrite it. To catch anything a failed delivery missed, also read the rows changed since your last sync now and then, with updated_at=gt.….
9. Handle disconnects
Your app loses access to an organization when:
The user disconnects your app under Connected apps in their profile menu.
An admin of the organization removes your app under Settings › API keys.
The user who connected your app leaves the organization or is no longer an admin there.
The webhooks your app created there are then disabled, and the organization drops out of the organizations of the next token response. Reads no longer return its rows. When it was the last organization of the connection, or the user disconnects your app altogether, the connection ends: requests get 401 and a refresh gets invalid_grant. In each case, show the user that the connection was lost and offer to connect again.
When a user connects your app to the organization again, its disabled webhooks there are enabled again, as long as the new scopes cover their events. Another admin can connect it too, for example after the first one left.
To disconnect from your side, for example when the user deletes their account in your app, revoke the refresh token:
curl https://www.bookingmood.com/oauth/revoke \ -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \ -d token=bmo_rt_…
This removes your app's access to every organization of that connection and disables its webhooks.
Endpoints
| URL | |
|---|---|
| Authorization | https://www.bookingmood.com/oauth/authorize |
| Token | https://www.bookingmood.com/oauth/token |
| Revocation | https://www.bookingmood.com/oauth/revoke |
| Metadata | https://www.bookingmood.com/.well-known/oauth-authorization-server |
| API | https://www.bookingmood.com/api/v1 |
Last modified November 26, 2026