← Back to API Home

Sync Calendar API

2-way synchronization between your club management software and Anybuddy

v2 · Updated Dec 2024

Web services and webhooks allow to synchronize court availability, create bookings and handle cancellations. All endpoints use HTTP REST / JSON.

Account Creation

Send an account creation request to contact@anybuddyapp.com with:

We will send you:

Test Server: https://extsync.stage.anybuddyapp.com/api/testsync

Authentication

HTTP Basic authentication. Include the following header with every request:

Header
Authorization: Basic <credentials>

Where credentials is the Base64 encoding of id:password.

Example for user:pass
Authorization: Basic dXNlcjpwYXNz

HTTP Codes

CodeDescription
200Success of the request
204Request successfully processed but no information to return
401Authentication error, the token is not valid
404Page not found

Club Software → Anybuddy

Pull Calendar

Used to initialize the club calendar or when there is a sync issue. We call this API regularly to get all availabilities.

GET /WEB_HOOK?center_id=WYZ&date=7
ParameterDescription
center_idID of the center
dateNumber of days to sync per club

Response Body

JSON
{ "slots": [ { "facilityId": "1", "facilityName": "Court 1", "startDateTime": "2018-03-19T08:30", "endDateTime": "2018-03-19T09:30", "isAvailable": true, "slotId": "1", // optional "sport": "tennis", // optional "price": 100 // optional, in cents } ] }

Push: Update Slots

Call the Anybuddy API every time there is a change in the calendar (booking or cancellation). Send both available and unavailable slots.

Club Software
Anybuddy API
POST /v1/sync/:centerId
Booking or cancellation → push updated slots → 200 OK

Slot Attributes

AttributeTypeDescription
facilityIdstring requiredUnique identifier of the court
facilityNamestring requiredCourt name
startDateTimestring requiredStart date/time in ISO 8601
endDateTimestring requiredEnd date/time in ISO 8601
isAvailableboolean requiredtrue if the slot is free
facilityDescriptionstring optionalCourt description
facilitySurfacestring optionalCourt surface
IsIndoorboolean optionaltrue if indoor court
sportstring requiredSport code: tennis, padel, squash, badminton
slotIdstring optionalUnique slot ID
pricenumber optionalSlot price in cents (e.g. 1500)

Surface Values

Request

POST /v1/sync/:centerId
Request Body — JSON
{ "slots": [ { "facilityId": "1", "facilityName": "Court 1", "startDateTime": "2018-03-19T08:30", "endDateTime": "2018-03-19T09:30", "isAvailable": true, "slotId": "1", "sport": "tennis", "price": 100 } ] }

Response

Returns HTTP 200 on success.

Anybuddy → Club Software

Anybuddy sends webhook events as JSON in the body of POST requests to notify your software of new reservations and cancellations.

Anybuddy
Club Software
POST /anybuddy_events
Player books or cancels → webhook event sent → your server responds 200 OK

Webhook Creation

Create an API endpoint to read POST requests. Requests are sent as JSON. You can include a token in the URL to secure it:

Example webhook URL
https://your-software.com/webhook/sync/ecea0964-43d2-4a35-a3da-9dfb6d777887

Check Message Signature (Optional)

Anybuddy can optionally sign webhook events by including a signature in the X-Anybuddy-Signature header. This lets you verify events were sent by Anybuddy.

New Booking Event

Sent when an Anybuddy player makes a reservation.

Event Attributes

AttributeTypeDescription
facilityIdstring requiredUnique identifier of the court
startDateTimestring requiredStart date/time in ISO 8601
endDateTimestring requiredEnd date/time in ISO 8601
playerName1string optionalPlayer's full name
slotIdstring optionalUnique slot ID

Request

POST /anybuddy_events
Request Body — reservation.created
{ "event": "reservation.created", "id": "evt_1FgY3WCD9yQTwtMnaGY9CgyR", "livemode": true, "object": "reservation", "apiVersion": "2019-08-14", "data": { "slot": { "centerId": "83536ba3-fba2-497a-a062-06b28a79b48d", "facilityId": "1", "startDateTime": "2018-03-19T08:30", "endDateTime": "2018-03-19T09:30" }, "user": { "id": "ZBZi8HYS", "playerName1": "Oliver", "playerFirstName1": "Oliver", "playerLastName1": "Buddy", "email": "Oliver@anybuddyapp.com" } } }

Response

200 OK — Booking confirmed
{ "accessCode": "12334", "reservationId": "CODE_RESA" }
  • 200 Booking confirmed by the software
  • 400 Bad Request: server cannot process the request
  • 401 Unauthorized: authentication required
  • 403 Forbidden: slot unavailable for booking
  • 404 Not Found: slot doesn't exist
  • 409 Conflict: slot is not available

Event: Cancel a Reservation

Sent when an Anybuddy player cancels a reservation.

POST /anybuddy_events
Request Body — reservation.cancelled
{ "event": "reservation.cancelled", "id": "evt_1FgY3WCD9yQTwtMnaGY9CgyR", "livemode": true, "object": "reservation", "apiVersion": "2019-08-14", "data": { "slot": { "centerId": "83536ba3-fba2-497a-a062-06b28a79b48d", "facilityId": "1", "startDateTime": "2018-03-19T08:30", "endDateTime": "2018-03-19T09:30", "reservationId": "CODE_RESA" }, "user": {} } }

Response Codes

  • 200 Cancellation confirmed by the software
  • 400 Bad Request: server cannot process the request
  • 401 Unauthorized: authentication required
  • 403 Forbidden: not an Anybuddy slot
  • 404 Not Found: slot doesn't exist
  • 409 Conflict: slot is not available

Test Implementation

You can use the following form to test the API calls with your server:

Code Example

PHP — Call Anybuddy API

PHP
<?php $fields = array( "slots" => array( (object)array( 'facilityId' => "1", 'facilityName' => "1", 'startDateTime'=> '2020-02-12T07:00', 'endDateTime' => "2020-02-12T07:00", 'sport' => "tennis", 'isAvailable' => true ) ) ); $fields = json_encode($fields); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://extsync.stage.anybuddyapp.com/v1/sync/CLUB_ID"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json; charset=utf-8", "Authorization: Basic YOUR_TOKEN_HERE")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); $response = curl_exec($ch);

Need help? Contact contact@anybuddyapp.com