Unexpected Scheduler Availability Response

The scheduler availability endpoint is ignoring start and end times in default_open_hours. Here’s an example

Get Configuration
Response

{
  "request_id": "6c11fb22-1e0d-4308-87cd-b41c109c53f2",
  "data": {
    "id": "ba363e49-b1ad-4218-a7c6-8bae078503f5",
    "version": "1.0.0",
    "participants": [
      {
        "name": "<redacted>",
        "email": "<redacted>",
        "is_organizer": true,
        "availability": {
          "calendar_ids": [
            "a3cceb74-9bac-4a79-91d6-f33bbe9ac8c9"
          ]
        },
        "booking": {
          "calendar_id": "a3cceb74-9bac-4a79-91d6-f33bbe9ac8c9"
        }
      }
    ],
    "requires_session_auth": false,
    "availability": {
      "duration_minutes": 65,
      "interval_minutes": 65,
      "availability_rules": {
        "availability_method": "",
        "buffer": {
          "before": 0,
          "after": 0
        },
        "default_open_hours": [
          {
            "days": [
              1
            ],
            "exdates": [],
            "timezone": "",
            "start": "9:00:00",
            "end": "12:00:00"
          }
        ],
        "round_robin_group_id": ""
      }
    },
    "event_booking": {
      "title": "Muh Service",
      "timezone": "America/New_York",
      "description": "\n",
      "booking_type": "booking",
      "hide_participants": null,
      "disable_emails": null
    },
    "scheduler": {
      "available_days_in_future": 30,
      "min_cancellation_notice": 0,
      "min_booking_notice": 60
    }
  }

Get Availability
Request

curl 'https://api.eu.nylas.com/v3/scheduling/availability?start_time=1716021200&end_time=1716199200&configuration_id=ba363e49-b1ad-4218-a7c6-8bae078503f5

Response

{
  "request_id": "5b093605-1efc-4f71-ae82-cae05dda063f",
  "data": {
    "time_slots": [
      {
        "end_time": 1716181500,
        "start_time": 1716177600
      },
      {
        "end_time": 1716185400,
        "start_time": 1716181500
      },
      {
        "end_time": 1716189300,
        "start_time": 1716185400
      },
      {
        "end_time": 1716193200,
        "start_time": 1716189300
      },
      {
        "end_time": 1716197100,
        "start_time": 1716193200
      }
    ]
  }
}

Basically the time slots begin at midnight on monday in the timezone (data.event_booking.timezone) instead of at 9am

@Julian thanks for reaching out! Let me take a look and circle back :slight_smile:

1 Like

Thanks. If it helps debug, I implemented very similar logic by just pulling configuration data from the API and passing it to the traditional calendar availability endpoint and things worked as expected.

Hi @julian - I am not able to reproduce. Let me share the curl command that I used:

curl --request POST \
  --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/configurations" \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <API_KEY> \
  --header 'Content-Type: application/json' \
  --data '{
    "version": "1.0.0",
    "requires_session_auth": false,
    "participants": [
      {
        "name": "Test1234",
        "email": "<EMAIL>",
        "is_organizer": true,
        "availability": {
          "calendar_ids": [
            "primary"
          ]
        },
        "booking": {
          "calendar_id": "primary"
        }
      }
    ],
    "availability": {
      "duration_minutes": 30,
      "availability_rules": {
        "availability_method": "",
        "buffer": {
          "before": 0,
          "after": 0
        },
        "default_open_hours": [
          {
            "days": [
              1
            ],
            "exdates": [],
            "start": "9:00:00",
            "end": "12:00:00"
          }
        ],
        "round_robin_group_id": ""
      }
    },
    "event_booking": {
      "title": "My test event",
      "timezone": "America/New_York"
    }
  }'

I was able to retrieve availability between the configuration hours (I did a day in the past, but works for next Monday as well):

curl --request GET \
  --url 'https://api.us.nylas.com/v3/scheduling/availability?start_time=1715605200&end_time=1715634000&configuration_id=<CONFIGURATION_ID>' \

Response:

{"request_id":"ed0665bd-ade3-4744-a5f9-39417a001d8d","data":{"time_slots":[{"emails":["<EMAIL>"],"end_time":1715608800,"start_time":1715607000},{"emails":["<EMAIL>"],"end_time":1715610600,"start_time":1715608800},{"emails":["<EMAIL>"],"end_time":1715614200,"start_time":1715612400},{"emails":["<EMAIL>"],"end_time":1715616000,"start_time":1715614200},{"emails":["<EMAIL>"],"end_time":1715621400,"start_time":1715619600},{"emails":["<EMAIL>"],"end_time":1715623200,"start_time":1715621400},{"emails":["<EMAIL>"],"end_time":1715625000,"start_time":1715623200},{"emails":["<EMAIL>"],"end_time":1715626800,"start_time":1715625000},{"emails":["<EMAIL>"],"end_time":1715628600,"start_time":1715626800},{"emails":["<EMAIL>"],"end_time":1715630400,"start_time":1715628600}]}}% 

Apologies if I’m missing something, but doesn’t the time_slots array contain times outside of the open hours?

Just looking at the last time slot:

{
    "emails": [
        "<EMAIL>"
    ],
    "end_time": 1715630400,
    "start_time": 1715628600
}

Start time is 3:30PM in America/New_York

The availability is looking at the calendar availability between specific hours.

So the question is whether setting default_open_hours changes what’s returned when calling the availability endpoint (https://api.us.nylas.com/v3/scheduling/availability).

Let me circle back when I learn more :+1:

Yeah, that would be my expectation. It is also the behavior you get when you use the traditional calendar availability endpoint.

@julian

So I confirmed with Eng and if we don’t receive default_open_hours in the configuration response, it was not set correctly. Here is the cURL command that worked:

curl --request POST \
  --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/scheduling/configurations" \
  --header 'Accept: application/json' \
  --header 'Authorization: <API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "version": "1.0.0",
    "requires_session_auth": false,
    "participants": [
      {
        "name": "Test12345678",
        "email": "devrel-virtual-calendar",
        "is_organizer": true,
        "availability": {
          "calendar_ids": [
            "primary"
          ]
        },
        "booking": {
          "calendar_id": "primary"
        }
      }
    ],
    "availability": {
      "duration_minutes": 30,
      "availability_rules": {
        "default_open_hours": [
          {
            "days": [
              1
            ],
            "exdates": [],
            "start": "9:00",
            "end": "12:00"
          }
        ]
      }
    },
    "event_booking": {
      "title": "My test event",
      "timezone": "America/New_York"
    }
  }'

I was able to retrieve the correct time slots (total 6) from 9:00 to 12:00.

Let me know if this cURL configuration for scheduler works. Here is an example response after calling the configuration endpoint (note that default_open_hours is not defined)

{"request_id":"<REQUEST_ID>","data":{"id":"<CONFIGURATION_ID>","version":"1.0.0","participants":[{"name":"Test12345678","email":"devrel-virtual-calendar","is_organizer":true,"availability":{"calendar_ids":["primary"]},"booking":{"calendar_id":"primary"}}],"requires_session_auth":false,"availability":{"duration_minutes":30,"interval_minutes":30,"availability_rules":{"availability_method":"","buffer":{"before":0,"after":0},"":[{"days":[1],"exdates":[],"timezone":"","start":"9:00","end":"12:00"}],"round_robin_group_id":""}},"event_booking":{"title":"My test event","timezone":"America/New_York","booking_type":"booking","hide_participants":null,"disable_emails":null},"scheduler":{"available_days_in_future":30,"min_cancellation_notice":0,"min_booking_notice":60}}}%