Availability

Weekly Availability

Weekly Service Availability is the overall business hours unique to each Service. This only applies to services that not offered during all Business hours. For example if your Business is opened on Monday's from 9am to 9pm but the service is only offered in the morning, from 9am - 12pm, then you would use the weekly service availability to limit the offering. When a Service is first created the weekly hours of availability will default to that of the Business Location. For more information about how availability results are returned please see Availability Factoring.

👍

Use Case: Varied Service Availability

Service availability can be used should you require certain Services to be booked within specified time frames (i.e. Accepting Product Demo's all day, but Follow Up Calls only in the mornings).

Updating Service Availability

To update a service's availability you will need the ID of the service you wish to update. If you do not have this then first call GET /services in order to obtain the ID. Pass the service ID into the request URL then add the days and hours you wish to update in the following format:

curl -X PUT 
  'https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}/availability'
  --header 'Content-Type: application/json-patch+json' 
  --header 'Accept: application/json' 
  --header 'Authorization: Bearer {AUTH_TOKEN}' 
  -d '{
    "sun":{"startTime":0,"endTime":0},
    "mon":{"startTime":900,"endTime":1700},
    "tue":{"startTime":900,"endTime":1700},
    "wed":{"startTime":900,"endTime":17000},
    "thu":{"startTime":900,"endTime":17000},
    "fri":{"startTime":900,"endTime":1700},
    "sat":{"startTime":0,"endTime":0}
  }'

#Update availability: mon-fri 9-5
PUT /setup/v1/services/{SERVICE_ID}/availability HTTP/1.1
Host: sandbox-api.onsched.com
Content-Type: application/json
Authorization: Bearer {AUTH_TOKEN}
Accept: */*
Cache-Control: no-cache
Host: sandbox-api.onsched.com
Accept-Encoding: gzip, deflate
Content-Length: 102
Cookie: ARRAffinity={RANDOM_STRING}
Connection: keep-alive
cache-control: no-cache

{
    "sun":{"startTime":0,"endTime":0},
    "mon":{"startTime":900,"endTime":1700},
    "tue":{"startTime":900,"endTime":1700},
    "wed":{"startTime":900,"endTime":17000},
    "thu":{"startTime":900,"endTime":17000},
    "fri":{"startTime":900,"endTime":1700},
    "sat":{"startTime":0,"endTime":0}
}
var request = require("request");

var options = { method: 'PUT',
  url: 'https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}/availability',
  headers: 
   { 'cache-control': 'no-cache',
     Connection: 'keep-alive',
     Cookie: 'ARRAffinity={RANDOM_STRING}}',
     'Content-Length': '102',
     'Accept-Encoding': 'gzip, deflate',
     Host: 'sandbox-api.onsched.com',
     'Cache-Control': 'no-cache',
     Accept: '*/*',
     Authorization: 'Bearer {AUTH_TOKEN}',
     'Content-Type': 'application/json' },
  body: 
   { 
    "sun":{"startTime":0,"endTime":0},
    "mon":{"startTime":900,"endTime":1700},
    "tue":{"startTime":900,"endTime":1700},
    "wed":{"startTime":900,"endTime":17000},
    "thu":{"startTime":900,"endTime":17000},
    "fri":{"startTime":900,"endTime":1700},
    "sat":{"startTime":0,"endTime":0}
   },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}/availability",
  "method": "PUT",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "*/*",
    "Cache-Control": "no-cache",
    "Host": "sandbox-api.onsched.com",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "102",
    "Cookie": "ARRAffinity={RANDOM_STRING}",
    "Connection": "keep-alive",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": {
    "sun":{"startTime":0,"endTime":0},
    "mon":{"startTime":900,"endTime":1700},
    "tue":{"startTime":900,"endTime":1700},
    "wed":{"startTime":900,"endTime":17000},
    "thu":{"startTime":900,"endTime":17000},
    "fri":{"startTime":900,"endTime":1700},
    "sat":{"startTime":0,"endTime":0}
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

You can also edit the service availability in the PUT /services endpoint. However the previous approach is recommended for better performance.

To update it in the PUT/services endpoint we wrap the whole availability data in an object with the key "availability" as the following:

curl -X PUT 
  'https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}'
  --header 'Content-Type: application/json-patch+json' 
  --header 'Accept: application/json' 
  --header 'Authorization: Bearer {AUTH_TOKEN}' 
  -d '{
   "availability": {
    "sun":{"startTime":0,"endTime":0},
    "mon":{"startTime":900,"endTime":1700},
    "tue":{"startTime":900,"endTime":1700},
    "wed":{"startTime":900,"endTime":17000},
    "thu":{"startTime":900,"endTime":17000},
    "fri":{"startTime":900,"endTime":1700},
    "sat":{"startTime":0,"endTime":0}
    }
  }'

#Update availability: mon-fri 9-5
PUT /setup/v1/services/{SERVICE_ID} HTTP/1.1
Host: sandbox-api.onsched.com
Content-Type: application/json
Authorization: Bearer {AUTH_TOKEN}
Accept: */*
Cache-Control: no-cache
Host: sandbox-api.onsched.com
Accept-Encoding: gzip, deflate
Content-Length: 102
Cookie: ARRAffinity={RANDOM_STRING}
Connection: keep-alive
cache-control: no-cache

{
    "availability": {
     "sun":{"startTime":0,"endTime":0},
     "mon":{"startTime":900,"endTime":1700},
     "tue":{"startTime":900,"endTime":1700},
     "wed":{"startTime":900,"endTime":17000},
     "thu":{"startTime":900,"endTime":17000},
     "fri":{"startTime":900,"endTime":1700},
     "sat":{"startTime":0,"endTime":0}
    }
  
}
var request = require("request");

var options = { method: 'PUT',
  url: 'https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}',
  headers: 
   { 'cache-control': 'no-cache',
     Connection: 'keep-alive',
     Cookie: 'ARRAffinity={RANDOM_STRING}}',
     'Content-Length': '102',
     'Accept-Encoding': 'gzip, deflate',
     Host: 'sandbox-api.onsched.com',
     'Cache-Control': 'no-cache',
     Accept: '*/*',
     Authorization: 'Bearer {AUTH_TOKEN}',
     'Content-Type': 'application/json' },
  body: 
   {
    "availability": {
     "sun":{"startTime":0,"endTime":0},
     "mon":{"startTime":900,"endTime":1700},
     "tue":{"startTime":900,"endTime":1700},
     "wed":{"startTime":900,"endTime":17000},
     "thu":{"startTime":900,"endTime":17000},
     "fri":{"startTime":900,"endTime":1700},
     "sat":{"startTime":0,"endTime":0}
    },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}",
  "method": "PUT",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "*/*",
    "Cache-Control": "no-cache",
    "Host": "sandbox-api.onsched.com",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "102",
    "Cookie": "ARRAffinity={RANDOM_STRING}",
    "Connection": "keep-alive",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": {
    "availability": {
     "sun":{"startTime":0,"endTime":0},
     "mon":{"startTime":900,"endTime":1700},
     "tue":{"startTime":900,"endTime":1700},
     "wed":{"startTime":900,"endTime":17000},
     "thu":{"startTime":900,"endTime":17000},
     "fri":{"startTime":900,"endTime":1700},
     "sat":{"startTime":0,"endTime":0}
    }
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Blocked Dates & Times

Service Blocked Dates & Times are used to temporarily restrict online booking specific to one Service. These can also be created as recurring blocks should you need to block out the same time period on a daily, weekly, or monthly basis.

👍

Use Case: Maintenance of a Printer

Service blocks can be used when you need to block the availability at a specific date and time or recurrently every day week or month. (i.e. Printing service needs to be blocked because printers need maintenance every week on Wednesdays for 30 minutes)

To block a service from offering appointments we need create a block by calling the POST services/{id}/blocks endpoint.

In the following example, a block is created. This block is recurring every week forever on Wednesdays for 30 minutes. Therefore, an appointment cannot be booked during this time.

curl -X POST
  'https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}/block'
  --header 'Content-Type: application/json-patch+json' 
  --header 'Accept: application/json' 
  --header 'Authorization: Bearer {AUTH_TOKEN}' 
  -d '{
        "locationId":"e76a39f6-fbe7-48c9-84c9-2fed3ed7b17d",
	"startDate": "2021-07-16",
	"endDate":   "9999-12-31",
	"startTime": 1200,
	"endTime":   1730,
	"reason":    "Maintenance",	
	"repeats":   true,
	"repeat":
		{
			"frequency":"W",
			"interval":1,
			"weekdays":"3",
			"monthDay":"16",
			"monthType":"D"
		}
  }'
POST /setup/v1/services/{SERVICE_ID}/block HTTP/1.1
Host: sandbox-api.onsched.com
Content-Type: application/json
Authorization: Bearer {AUTH_TOKEN}
Accept: */*
Cache-Control: no-cache
Host: sandbox-api.onsched.com
Accept-Encoding: gzip, deflate
Content-Length: 102
Cookie: ARRAffinity={RANDOM_STRING}
Connection: keep-alive
cache-control: no-cache

{
    "locationId":"e76a39f6-fbe7-48c9-84c9-2fed3ed7b17d",  	 
    "startDate": "2021-07-16",
    "endDate":   "9999-12-31",
    "startTime": 1200,
    "endTime":   1730,
    "reason":    "Maintenance",	
    "repeats":   true,
    "repeat": {
    		"frequency":"W", 			 
                "interval":1,
		"weekdays":"3",
		"monthDay":"16",
		"monthType":"D"
	      }
}
var request = require("request");

var options = { method: 'POST',
  url: 'https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}/block',
  headers: 
   { 'cache-control': 'no-cache',
     Connection: 'keep-alive',
     Cookie: 'ARRAffinity={RANDOM_STRING}}',
     'Content-Length': '102',
     'Accept-Encoding': 'gzip, deflate',
     Host: 'sandbox-api.onsched.com',
     'Cache-Control': 'no-cache',
     Accept: '*/*',
     Authorization: 'Bearer {AUTH_TOKEN}',
     'Content-Type': 'application/json' },
  body: 
   {
    "locationId":"e76a39f6-fbe7-48c9-84c9-2fed3ed7b17d",  	 
    "startDate": "2021-07-16",
    "endDate":   "9999-12-31",
    "startTime": 1200,
    "endTime":   1730,
    "reason":    "Maintenance",	
    "repeats":   true,
    "repeat": {
    		"frequency":"W", 			 
                "interval":1,
		"weekdays":"3",
		"monthDay":"16",
		"monthType":"D"
	      }
  },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://sandbox-api.onsched.com/setup/v1/services/{SERVICE_ID}/block",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "*/*",
    "Cache-Control": "no-cache",
    "Host": "sandbox-api.onsched.com",
    "Accept-Encoding": "gzip, deflate",
    "Content-Length": "102",
    "Cookie": "ARRAffinity={RANDOM_STRING}",
    "Connection": "keep-alive",
    "cache-control": "no-cache"
  },
  "processData": false,
  "data": {
    "locationId":"e76a39f6-fbe7-48c9-84c9-2fed3ed7b17d",  	 
    "startDate": "2021-07-16",
    "endDate":   "9999-12-31",
    "startTime": 1200,
    "endTime":   1730,
    "reason":    "Maintenance",	
    "repeats":   true,
    "repeat": {
    		"frequency":"W", 			 
                "interval":1,
		"weekdays":"3",
		"monthDay":"16",
		"monthType":"D"
	      }
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Frequency can be set to a value D, W, M, Y. To repeat every Day Week, Month or Year respectively.

Interval property is to specify the interval that the block repeats. For example, an interval of 2 for a weekly block means that the block will repeat every second week beginning at the day specified. A daily block with an interval of 10 means the block will repeat every 10 days. A Monthly block with an interval of 4 means that the block repeat every 4 months.

Monthday property is for monthly blocks to repeat on the specified date in this property

Weekdays property is for weekly blocks to repeat on the specified days of the weeks. The possible values are 0 to 6 where Sunday is 0, Monday 1, Tuesday 2, Wednesday 3, Thursday 4, Friday 5, and Saturday 6. These values can be combined. i.e. for every week on Mondays, Tuesdays and Fridays would be weekdays: ”125”


What’s Next