For full functionality of this site it is necessary to enable JavaScript. Here are the instructions how to enable JavaScript in your web browser.
 You are using an out of date browser, we suggest you upgrade. You may continue if you wish, but aspects of the site may not function correctly.

Basket

The basket method is the process which enables end-users to make a booking (appointment). The basket acts like a shopping cart where a typical user flow consist of the following:

  1. Add items to the basket
  2. View full basket or view an item in a basket
  3. Remove an item from the basket
  4. Checkout to complete the booking.

This section will explain how you can add services/events to the basket and checkout.

Add Item

To be able to add items to the basket we need to check the avalibility for a service or an event, which was explained here.

Parameters

Name Type Description
service_id integer service ID
member_id integer The members (client) ID the booking is being made against
event_id integer The underlying Bookable 'event ID' - that descripbes this bookable service combination
event_chain_id integer Event chain ID
date string ISO date (YYYY-MM-DD)
time string The time of booking in minutes, e.g 10am, 600 minutes

Below is an example of adding a service to the basket. In the header response we will get back an Auth-Token. The returned auth token will be used in subsequent basket requests.

POST /api/v1/{company_id}/basket/add_item
curl -X POST -H "App-Id: {app-id}" -H "App-Key: {app-key}" -H "Content-Type: application/json" 
  -H "Cache-Control: no-cache"
  -d '{"service_id": "104748", "date": "2017-02-01", "time": "630"}'
"https://{host}.bookingbug.com/api/v1/{company_id}/basket/add_item"
{
  "company_id": 50666,
  "total_price": 0,
  "total_due_price": 0,
  "_embedded": {
    "items": [
      {
        "event_id": 1091849,
        "person_id": 30550,
        "resource_id": 43048,
        "service_id": 104748,
        "num_book": 1,
        "person_name": "Emma",
        "resource_name": "Consultation Room 2",
        "service_name": "Medical Consultation",
        "status": 4,
        "id": "5c733ffc20bc6b24",
        "date": "2017-02-01",
        "time": 630,
        "duration": 45,
        "_embedded": {},
        "_links": {
          "self": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24"
          },
          "attachment": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24/attach/"
          },
          "add_attachment": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24/attach"
          },
          "del_attachment": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24/attach/"
          },
          "resource": {
            "href": "https://uk.bookingbug.com/api/v1/50666/resources/43048"
          },
          "person": {
            "href": "https://uk.bookingbug.com/api/v1/50666/people/30550"
          },
          "service": {
            "href": "https://uk.bookingbug.com/api/v1/50666/services/104748"
          },
          "company": {
            "href": "https://uk.bookingbug.com/api/v1/company/50666"
          }
        }
      }
    ]
  },
  "_links": {
    "self": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket"
    },
    "checkout": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/checkout{?member_id,take_from_wallet}",
      "templated": true
    },
    "items": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket{?id}",
      "templated": true
    },
    "add_item": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/add_item{?event_id,member_id,event_chain_id,service_id,product_id,attachment_id,deal_id,package_id,bulk_purchase_id}"
    }
  }
}
...
Auth-Token: Boq2lgDNQLAFTmiJQaABRA
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Length: 1511
...

The member_id is optional at add_item stage but is required upon checkout.

Adding an event

curl -X POST -H "App-Id: {app-id}" -H "App-Key: {app-key}" -H "Content-Type: application/json" 
  -H "Cache-Control: no-cache"
  -d '{"event_id": "104748", "event_chain_id": "3432423", "date": "2017-02-01", "time": "630"}'
"https://{host}.bookingbug.com/api/v1/{company_id}/basket/add_item"

If a space is taken or trying to book the space again, the API will give you the following error.

{
    "status": 409,
    "message": "NoSpaceLeftError",
    "error": "No Space Left",
    "data": {
    "service_id": 104748,
    "name": "Medical Consultation"
    }
}

View Basket

You can view the basket using this method. Notice we are passing in the same Auth-Token retervied from the add_item in the header here. The response will be identical to the one we get when adding to basket.

 GET /api/v1/{company_id}/basket 
curl -X GET -H "App-Id: {app-id}" -H "App-Key: {app-key}" -H "Content-Type: application/json" 
  -H "Cache-Control: no-cache" -H "Auth-Token: Boq2lgDNQLAFTmiJQaABRA"
"https://{host}.bookingbug.com/api/v1/{company_id}/basket"
{
  "company_id": 50666,
  "total_price": 0,
  "total_due_price": 0,
  "_embedded": {
    "items": [
      {
        "event_id": 1091849,
        "person_id": 30550,
        "resource_id": 43048,
        "service_id": 104748,
        "num_book": 1,
        "person_name": "Emma",
        "resource_name": "Consultation Room 2",
        "service_name": "Medical Consultation",
        "status": 4,
        "id": "5c733ffc20bc6b24",
        "date": "2017-02-01",
        "time": 630,
        "duration": 45,
        "_embedded": {},
        "_links": {
          "self": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24"
          },
          "attachment": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24/attach/"
          },
          "add_attachment": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24/attach"
          },
          "del_attachment": {
            "href": "https://uk.bookingbug.com/api/v1/50666/basket/5c733ffc20bc6b24/attach/"
          },
          "resource": {
            "href": "https://uk.bookingbug.com/api/v1/50666/resources/43048"
          },
          "person": {
            "href": "https://uk.bookingbug.com/api/v1/50666/people/30550"
          },
          "service": {
            "href": "https://uk.bookingbug.com/api/v1/50666/services/104748"
          },
          "company": {
            "href": "https://uk.bookingbug.com/api/v1/company/50666"
          }
        }
      }
    ]
  },
  "_links": {
    "self": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket"
    },
    "checkout": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/checkout{?member_id,take_from_wallet}",
      "templated": true
    },
    "items": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket{?id}",
      "templated": true
    },
    "add_item": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/add_item{?event_id,member_id,event_chain_id,service_id,product_id,attachment_id,deal_id,package_id,bulk_purchase_id}"
    }
  }
}

View Basket Item

If you have more than one items in your basket you can view the basket item. Each item has a basket ID.

 GET /api/v1/{company_id}/basket/{id} 
curl -X GET -H "App-Id: {app-id}" -H "App-Key: {app-key}" -H "Content-Type: application/json" 
  -H "Cache-Control: no-cache" -H "Auth-Token: Boq2lgDNQLAFTmiJQaABRA"
"https://{host}.bookingbug.com/api/v1/{company_id}/basket/5c733ffc20bc6b24"
{
  "event_id": 1091849,
  "person_id": 30550,
  "resource_id": 43048,
  "service_id": 104748,
  "num_book": 1,
  "person_name": "Emma",
  "resource_name": "Consultation Room 2",
  "service_name": "Medical Consultation",
  "status": 4,
  "id": "5c733ffc20bc6b24",
  "date": "2017-02-01",
  "time": 630,
  "duration": 45,
  "_embedded": {},
  "_links": {
    "self": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/05b620502ca56322"
    },
    "attachment": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/05b620502ca56322/attach/"
    },
    "add_attachment": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/05b620502ca56322/attach"
    },
    "del_attachment": {
      "href": "https://uk.bookingbug.com/api/v1/50666/basket/05b620502ca56322/attach/"
    },
    "resource": {
      "href": "https://uk.bookingbug.com/api/v1/50666/resources/43048"
    },
    "person": {
      "href": "https://uk.bookingbug.com/api/v1/50666/people/30550"
    },
    "service": {
      "href": "https://uk.bookingbug.com/api/v1/50666/services/104748"
    },
    "company": {
      "href": "https://uk.bookingbug.com/api/v1/company/50666"
    }
  }
}

Delete Basket Item

You can delete an item from the basket. Basket item ID is required with DELETE method.

 DELETE /api/v1/{company_id}/basket/{id} 
curl -X DELETE -H "App-Id: {app-id}" -H "App-Key: {app-key}" -H "Content-Type: application/json" 
  -H "Cache-Control: no-cache" -H "Auth-Token: Boq2lgDNQLAFTmiJQaABRA"
"https://{host}.bookingbug.com/api/v1/{company_id}/basket/5c733ffc20bc6b24"

Checkout

To complete the booking you must checkout the basket before the basket session expires. When an item is added to the basket session it temporarily reserves the space.

Name Type Description
member_id integer member ID
take_from_wallet boolean Use money stored in wallet (true/false)
email string Customer email
reference string A custom reference for the booking invoice
no_notifications boolean Determines whether or not to send notifications to Customers & Admins
 POST /api/v1/{company_id}/basket/checkout 
curl -X POST -H "App-Id: {app-id}" -H "App-Key: {app-key}" -H "Content-Type: application/json" 
  -H "Cache-Control: no-cache" -H "Auth-Token: Boq2lgDNQLAFTmiJQaABRA" 
  -d '{"member_id": "232323", "take_from_wallet": "false"}'
"https://{host}.bookingbug.com/api/v1/{company_id}/basket/checkout"

Using Wallets

Wallets enable your customers to credit their account with real or virtual currency which they can then use to pay for bookings. To use wallets, you must have online payments setup.

for more information about setting wallets up see this guide

for more information regarding setting up payments you can take a look at our payment guides