Run the booking lifecycle from your backend.
Runs on your trusted server. Use a scoped workspace test credential with Read and Book.
On this page
Set up once
Complete resource, hours and offering setup. The backend booking example uses those IDs; it does not need a published guest page. Install Python or PHP, then configure a private key.
A workspace credential belongs to one workspace and one test or live environment. The credential selects the actual environment on the server; the SDK’s environment value records your intended scope. Issue a matching key in the dashboard. Changing a client label cannot move data between environments.
For these booking examples grant Read and Book.
Other permissions
Catalog writes additionally need Edit catalog; customer/webhook administration needs Manage customers and webhooks. Linking a contact to a booking requires both Book and Manage customers and webhooks. Erasure and history pruning require Privacy plus customer management; expired-receipt pruning needs Privacy.
- In API keys, select your workspace and test, grant Read and Book, then create and download the secret shown once. Save the workspace and offering IDs separately.
- Move the downloaded key into a private directory outside source control. Substitute your actual file and IDs below; all YOUR_* values are placeholders.
mkdir -m 700 private
printf 'private/\n' >> .gitignore
mv ~/Downloads/YOUR_DOWNLOADED_KEY.key private/availkit-test.key
chmod 600 private/availkit-test.key
export AVAILKIT_WORKSPACE_ID=YOUR_WORKSPACE_ID
export AVAILKIT_OFFERING_ID=YOUR_TEST_OFFERING_ID
export AVAILKIT_ENVIRONMENT=test
export AVAILKIT_CREDENTIAL_FILE="$PWD/private/availkit-test.key"Keep workspace keys and webhook secrets on a trusted server. Never put them in browser bundles, mobile applications, client storage, public repositories, URLs or command arguments. A mobile app cannot keep a workspace secret private.
Python: inspect, create, read, move, cancel
python -m availkit.examples.first_booking inspect
python -m availkit.examples.first_booking create
python -m availkit.examples.first_booking read
python -m availkit.examples.first_booking move
python -m availkit.examples.first_booking cancelThe installed module defaults to the next seven days and a private ./private/python-intents directory. It finds a future slot within seven days, creates one booking, reads it, selects a different available time for a compare-start move, and cancels. Each action is a separate invocation. Confirm each result before the next action. Configuration and error handling.
PHP: inspect, create, read, move, cancel
php vendor/availkit/availkit/examples/first-booking.php inspect
php vendor/availkit/availkit/examples/first-booking.php create
php vendor/availkit/availkit/examples/first-booking.php read
php vendor/availkit/availkit/examples/first-booking.php move
php vendor/availkit/availkit/examples/first-booking.php cancelThe same sequence uses PHP’s typed booking objects, defaults to the next seven days and retains intents in ./private/php-intents. The move includes the booking’s observed expectedStart; it detects stale start values but is not a monotonic revision. Configuration and error handling.
Check the result and stop on uncertainty
After creation, find the same booking ID in the dashboard’s test Bookings list. After move, read it to confirm its new time. After cancellation, read its cancelled status. Neither example attaches a customer or sends customer booking email.
A Read-only key must be rejected when creating a booking, and a live key must not read a test booking ID. These are server checks; a client environment label does not override them.