Booking with the Public Booking API

Postman Collection

Booking API Sequence Diagram

Fetch services

Assuming we already know the location for the appointment (represented by the company_id) typically the customer will want to know what services can be booked and how much they cost.

Get Services API

Endpoint:

https://{host}/api/v5/{company_id}/services

Request:

curl https://example.jrni.com/api/v5/1/services -H App-Id:1234

Response:

{
  "total_entries": 2,
  "_embedded": {
    "services": [
      {
        "name": "Tennis Coaching",
        "description": "Individual coaching is the fastest way to improve your tennis, whether a beginner or experienced club player.",
        "durations": [
          30,
          60
        ],
        "prices": [
          1000,
          1500
        ],
        "listed_durations": [
          20,
          50
        ],
        "booking_time_step": 30,
        "duration_unit": "minute",
        "min_bookings": 1,
        "max_bookings": 2,
        "_links": {
          "self": "https://example.bookingbug.com/api/v5/1/services/1",
          "times": {
            "href": "https://example.bookingbug.com/api/v5/1/time_data?service_id=1{&event_id,date,end_date,location,person_id,resource_id,duration,single,num_resources,group_id,resource_ids,time_zone,ignore_booking,person_group_id,people_ids,is_admin}",
            "templated": true
          }
        }
      },
      {
        "name": "Tennis Coaching Day",
        "description": "Ideal for improvers and seasoned tennis players alike, this professional coaching day, is the perfect chance to sharpen skills and boost performance on the court.",
        "durations": [
          1
        ],
        "prices": [
          6000
        ],
        "listed_durations": [
          1
        ],
        "duration_unit": "day",
        "min_bookings": 1,
        "max_bookings": 1,
        "_links": {
          "self": "https://example.bookingbug.com/api/v5/1/services/2"
        }
      }
    ]
  },
  "_links": {
    "self": "https://example.bookingbug.com/api/v5/1/services"
  }
}

Fetch time

Once the customer has selected a service we can use the service_id along with a date to retrieve the available times.

Get Time API

Endpoint:

https://example.jrni.com/api/v5/{company_id}/times{?service_id,start_date,duration}

Request:

curl https://example.jrni.com/api/v5/1/times?service_id=1&start_date=2018-01-01 \
  -H App-Id:1234

Response:

{
  "times": [
    {
      "start": "2018-01-01T09:00:00+01:00",
      "available": true,
      "durations": [60],
      "prices": [],
      "_links": {
        "self": {
          "href": "https://example.jrni.com/api/v5/admin/1/times/2018-01-01T09:00:00+01:00?service_id=1"
        }
      }
    },
    {
      "start": "2018-01-01T10:00:00+01:00",
      "available": true,
      "durations": [60],
      "prices": [],
      "_links": {
        "self": {
          "href": "https://example.jrni.com/api/v5/admin/1/times/2018-01-01T10:00:00+01:00?service_id=1"
        }
      }
    },
    {
      "start": "2018-01-01T11:00:00+01:00",
      "available": true,
      "durations": [60],
      "prices": [],
      "_links": {
        "self": {
          "href": "https://example.jrni.com/api/v5/admin/1/times/2018-01-01T11:00:00+01:00?service_id=1"
        }
      }
    },
    {
      "start": "2018-01-01T12:00:00+01:00",
      "available": true,
      "durations": [60],
      "prices": [],
      "_links": {
        "self": {
          "href": "https://example.jrni.com/api/v5/admin/1/times/2018-01-01T12:00:00+01:00?service_id=1"
        }
      }
    },
    {
      "start": "2018-01-01T13:00:00+01:00",
      "available": true,
      "durations": [60],
      "prices": [],
      "_links": {
        "self": {
          "href": "https://example.jrni.com/api/v5/admin/1/times/2018-01-01T13:00:00+01:00?service_id=1"
        }
      }
    },
    {
      "start": "2018-01-01T14:00:00+01:00",
      "available": true,
      "durations": [60],
      "prices": [],
      "_links": {
        "self": {
          "href": "https://example.jrni.com/api/v5/admin/1/times2018-01-01T14:00:00+01:00?service_id=1"
        }
      }
    }
  ]
},
"_links": {
  "self": {
    "href: "https://example.jrni.com/api/v5/1/times?service_id=1&start_date=2018-01-01"
  }
}

Create appointment

With the service and time selected the appointment can now be created by providing the customer details in the payload of the create booking request.

Create Booking API

Endpoint:

https://{host}/api/v5/{company_id}/bookings

Request:

curl https://example.jrni.com/api/v5/1/bookings -H App-Id:1234 -X POST \
  -d '{
    "service_id": 1,
    "datetime": "2018-01-01T09:00:00",
    "person_id": 2,
    "resource_id": 1,
    "client": {
      "first_name": "John",
      "last_name": "Doe",
      "email": "jdoe@example.com"
    }
  }'

Response:

{
  "id": 1586,
  "full_describe": "Tennis Coaching with Tom",
  "describe": "01 Jan 09:00",
  "datetime": "2018-01-01T09:00:00",
  "duration": 60,
  "_links": {
    "self": {
      "href": "https://example.jrni.com/api/v5/purchases/askvnASdvaildkDjd/bookings/1586"
    }
  }
}