Get Available Slots of Users by Search Criteria

Lets you retrieve the available time slots for multiple users by passing search criteria.

The API request uses condition groups similar to the User Advanced Search API.

  • Pass a “FromDate” and “ToDate” within which you want to retrieve user availability slots. The difference between the from and to date cannot be more than 100 days.
  • Pass one or more conditions within the “GroupConditions” parameter to specify which users you want to get the availability slots for.
  • If you want to retrieve slots that have conflicting tasks, pass the “IncludeAllowedConflictSlots” parameter as true. Otherwise pass it as false.

The API response returns –

  • Available slots, break timings, busy slots and workday template timezone for each user.
  • A “NoSlotsReason” parameter as either “Holiday”, “Leave”“NotScheduled” or “WorkDayTemplateNotDefined”.

 

API URL

POST
https://{host}/v2/Task.svc/RetrieveAvailableSlots/ByUserSearchCriteria?accessKey=AccessKey&secretKey=SecretKey
Copy URL

Request

JSON Body/Payload

Content-Type: application/json

{
  "FromDate": "2018-06-01",
  "ToDate": "2018-08-02",
  "UserSearchCriteria": {
    "GroupConditions": [
      {
        "GroupConditions": [
          {
            "Condition": [
              {
                "LookupName": "TeamId",
                "Operator": "eq",
                "LookupValue": "8bfc8586-0f53-11e8-871e-02bf1924461c",
                "ConditionOperator": null
              }
            ],
            "GroupOperator": null
          }
        ],
        "GroupOperator": "AND"
      },
      {
        "Condition": [
          {
            "LookupName": "StatusCode",
            "Operator": "eq",
            "LookupValue": "0",
            "ConditionOperator": null
          }
        ],
        "GroupOperator": null
      }
    ]
  },
  "IncludeAllowedConflictSlots": false
}

JSON Properties

Parameter Description
FromDate

Starting date to retrieve user availability slots from.

ToDate

End date to retrieve user availability slots till.

UserSearchCriteria

“GroupConditions” – You can create one or more condition groups. You can set multiple conditions inside each condition group.

“Condition”

  • “LookupName” – The user attribute you want to search by (FirstName, LastName etc.)
  • “Operator” – The following operators are permitted –eq – equals
    neq – not equal to
    lik – like
    nlik – not like
    lik_s – starts with
    lik_e – ends with
    n – null
    nn – not null
  • “LookupValue” – The value of the user attribute you passed in LookupName.
  • “ConditionOperator” – “AND” or “OR”. You can add multiple conditions with a condition group. When you’re adding the next condition, you must specify its relationship with the previous condition here. You must use the same operator between conditions within a group (Condition 1 AND Condition to AND Condition 3 or Condition 1 OR Condition 2 OR Condition 3)
IncludeAllowedConflictSlots

Pass true to include availability slots with conflicting appointments. Pass false to exclude conflicting appointment slots.

Response

200 OK

Content-Type: application/json

{
  "RecordCount": 3,
  "List": [
    {
      "Date": "2018-10-16",
      "UserSlots": [
        {
          "UserId": "d4d5f703-677b-11e7-bd09-22000aa220ce",
          "EmailAddress": "su.3529@yopmail.com",
          "UserTimeZone": "Asia/Kolkata",
          "AvailableSlots": [
            {
              "StartTime": "09:00:00",
              "EndTime": "18:00:00"
            }
          ],
          "Breaks": [],
          "BusySlots": [],
          "WorkDayTemplateTimeZone": "Asia/Kolkata",
          "NoSlotsReason": null
        },
        {
          "UserId": "cc1a3996-c92a-11e7-8dc3-22000aa8e760",
          "EmailAddress": "User.14118@mailinator.com",
          "UserTimeZone": "Asia/Kolkata",
          "AvailableSlots": [
            {
              "StartTime": "09:00:00",
              "EndTime": "18:00:00"
            }
          ],
          "Breaks": [],
          "BusySlots": [
            {
              "StartTime": "2018-10-16 09:30:00",
              "EndTime": "2018-10-16 10:00:00"
            },
            {
              "StartTime": "2018-10-16 10:30:00",
              "EndTime": "2018-10-16 11:00:00"
            }
          ],
          "WorkDayTemplateTimeZone": "Asia/Kolkata",
          "NoSlotsReason": null
        },
        {
          "UserId": "50633e81-bb52-11e8-8a16-024dd1074912",
          "EmailAddress": "user.18090@mailinator.com",
          "UserTimeZone": "Asia/Kolkata",
          "AvailableSlots": [
            {
              "StartTime": "09:00:00",
              "EndTime": "18:00:00"
            }
          ],
          "Breaks": [],
          "BusySlots": [],
          "WorkDayTemplateTimeZone": "Asia/Kolkata",
          "NoSlotsReason": null
        }
      ]
    }
  ]
}

HTTP Response Code

Code Description
200 OK

This is the status code for successful API call.

401 Unauthorized

The API call was made with invalid access credentials. Check your AccessKey and SecretKey.

400 Bad Request

The message body on the request is not as per API specification. Make sure that content type is set to “application/json” and the JSON body has correct attribute names and structure.

404 Not Found

The API could not be found. Please check the API signature.

429 Too Many Requests

API calls exceeded the limit of 25 in 5 second(s)

500 Internal Server Error

The API called failed. There could be many reasons for it. Check the exception message to get more details.