Only show these results:

Using the Availability Endpoints with Virtual Calendar

While Virtual calendar currently doesn’t support availability or consecutive availability directly, you can still use it when booking meetings and checking for free time.

Step 1 Get a List of calendar Events

Make a GET request to /events?expand_recurring=true&busy=true. Include the following query parameters:

  • expand_recurring - Makes sure to fetch all events in a series.
  • busy - Returns events where the calendar is confirmed as busy.
curl --request GET \
--url 'https://api.nylas.com/events?expand_recurring=true&busy=true' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <NYLAS_ACCESS_TOKEN>' \

Step 2 Convert the Event to Timeslots

As part of the response, the event times are returned in the when object.

[
{
"account_id": "1wkrvki9owclp1k6d5t239d6x",
"busy": true,
"calendar_id": "5u8xdd75azkoemrhzjhlllt0t",
"description": null,
"ical_uid": "492fde66ba2444b9b4804c75c7617cb9@nylas.com",
"id": "eyd8ioauo5ojugofckz50j6h8",
"location": "Yoga Studio 5 Westlake",
"message_id": null,
"object": "event",
"owner": "Virtual Calendar <virtual_account_unique_id>",
"participants": [
{
"comment": null,
"email": "kat@spacetech.com",
"name": "Katherine Johnson",
"phone_number": null,
"status": "noreply"
}
],
"read_only": false,
"reminders": null,
"status": "confirmed",
"title": "Good Flow Yoga",
"when": {
"end_time": 1628539200,
"object": "timespan",
"start_time": 1628535600
}
}
]

Use the start and end times of the when object to convert the times into time_slots. Timeslots are used as part of the free_busy object in /availability.

"when": {
"end_time": 1628539200,
"object": "timespan",
"start_time": 1628535600
}
"time_slots": [{
"start_time": 1628535600,
"end_time": 1628539200,
"object": "time_slot",
"status": "busy"
}]

Step 3 Pass in the Timeslots

Pass in the timeslots from Step 2 as free_busy.

curl --request POST \
--url https://api.nylas.com/calendars/availability \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <NYLAS_ACCESS_TOKEN>' \
--data-raw '{
"duration_minutes": 30,
"start_time": 1628535600,
"end_time": 1628539200,
"interval_minutes": 10,
"emails": [
"<email@your-domain.com>"
],
"free_busy": [
{
"email": "My virtual calendar",
"object": "free/busy",
"time_slots": [
{
"start_time": 1628535600,
"end_time": 1628539200,
"object": "time_slot",
"status": "busy"
}
]
}
]
}'

The response will return available timeslots for both the Virtual calendar and any emails passed in.

What's Next?