Availability

Weekly Availability

Weekly Resource Availability is the overall business hours unique to each Resource, should they vary from that of the Business Location. When a Resource is first created the weekly hours of availability will default to that of the Business Location, unless otherwise customized in their onboarding process. For more information about how availability results are returned please see Availability Factoring.

Updating Resource Availability

To update a resource's availability you will need the ID of the resource you wish to update. If you do not have this then first call GET /resources in order to obtain the ID. Pass the resource 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/resources/{RESOURCE_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/resources/{RESOURCE_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/resources/{RESOURCE_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/resources/{RESOURCE_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);
});

Another way to update a resource's availability, is from the resource endpoint itself. However, the previous approach is recommended as the performance's penalty is lower. To update it from the resource endpoint, call PUT /resources and change the availability object property with the following format:

{
  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}
  }
}

Blocked Dates & Times

Resource Blocked Dates & Times are used to temporarily restrict online booking specific to an individual Resource. These blocks can be used for lunch breaks, sick days, etc. and can also be created as a recurring block should you need to block out the same time period on a daily, weekly, or monthly basis.

👍

Use Case: Day off

Creating a block will make the specified time unavailable. i.e. One of the employees has asked for a day off next Friday. We can create a block that will cover the whole day next Friday,

Adding a Block

To add a break in the day or a holiday for a specific resource, you can call the resource block endpoint. Resource blocks can be set to all day or a set start and end time.

curl -X POST 
  'https://sandbox-api.onsched.com/setup/v1/resources/{RESOURCE_ID}/blocks'
  --header 'Content-Type: application/json-patch+json' 
  --header 'Accept: application/json' 
  --header 'Authorization: Bearer {AUTH_TOKEN}' 
  -d '{
      "startDate": "2019-10-02T00:00:00",
      "endDate": "9999-12-31T00:00:00", // set year to 9999 to never expire
      "startTime": 900,
      "endTime": 1700,
      "reason": "Lunch break",
      "repeats": true,
      "repeat": {
        "frequency": "D",
        "interval": 1,
        "weekdays": "",
        "monthDay": "",
        "monthType": ""
      }
  }'

#Add a resource block

Repeating Blocks

To repeat a resource block, for instance adding a daily lunch break, you can set the parameter repeats to true then use the following parameters to define the frequency:

Parameter

Options

frequency

D, W, M, Y

Set frequency to D for daily, W for weekly, M for monthly, and Y for Yearly.

interval

Integer

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.

weekdays

Integer

Weekdays parameter only applies for the weekly frequency. If weekly, weekdays is how you define which days of the week you would like to add this block. each day is represented by one of the following integers:
Sun: 0
Mon: 1
Tue: 2
Wed: 3
Thu: 4
Fri: 5
Sat: 6

So to repeat every Sunday, Monday, and Wednesday the weekdays parameter should be set to *013

monthDay

Integer

The monthDay parameter only applies to the monthly frequency, and represents the day of the month that it will be repeated


What’s Next
Did this page help you?