# Fetch user calendar slots availability via API

**URL:** <https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797>\
**Category:** API\
**Created:** [May 30, 2024, 12:52pm UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797 "2024-05-30T12:52:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicor88](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@nicor88](https://forum.youcanbook.me/u/nicor88)\
**Post date:** [May 30, 2024, 12:52pm UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797/1 "2024-05-30T12:52:20Z")

</div>

I was planning to use YCBM APIs to find out “Calendar” Slots a user is offering up in you can book me - required to build some analytics on top of this data.  
Specifically, I would like to know for a specific user which are her free slots (available slots based on their calendar availability).

Is there any specific API that I can use for that? I was not really lucky to find the right endpoint.

Thanks

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [May 30, 2024, 6:33pm UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797/2 "2024-05-30T18:33:03Z")

</div>

@nicor88 you can check on more information with the API here:  
`https://ycbm.stoplight.io/`

for this you will need to GET the teamMember Ids from the profile you are looking to get the free times for.

with this:  
`https://api.youcanbook.me/v1/profiles/{profileId}?fields=teamMembers,teamMembers.items,teamMembers.items.name,teamMembers.items.id`

Then you will need to POST to create an intent with these selections:  
`https://api.youcanbook.me/v1/intents`  
{  
“subdomain” :“{pageSubdomain}”,  
“selections” : {  
“teamMemberId” : “{teamMemberId}”}  
}

Once you have this intent made you can take the returned intentId and run a GET here:  
`https://api.youcanbook.me/v1/intents/{intentId}/availabilitykey`

Then once you have the availabilityKey use that with a GET here:  
`https://api.youcanbook.me/v1/availabilities/{availbilityKey}`

This will return the Unix timestamp of availability based off of the selections you have made in the intent.

Once you have the time you can create the booking by running a PATCH here:  
`https://api.youcanbook.me/v1/intents/{intentId}/selections`

Add in your startsAt with the unix stamp and any form question that need to be answered:  
{“form” : [ {  
“id” : “LNAME”,  
“value” : “Test”  
}, {  
“id” : “EMAIL”,  
“value” : “[ben@domain.com](mailto:ben@domain.com)”  
}, {  
“id” : “FNAME”,  
“value” : “Ben”  
} ],  
“startsAt” : {unixTimeStamp}  
}

Then run an empty PATCH to `https://api.youcanbook.me/v1/intents/{intentId}/confirm`

---

<div class="post-metadata">

**Author:** ![nicor88](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@nicor88](https://forum.youcanbook.me/u/nicor88)\
**Post date:** [May 31, 2024, 7:59am UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797/3 "2024-05-31T07:59:27Z")

</div>

Thanks really helpful.  
I was indeed using the page [https://ycbm.stoplight.io/](https://ycbm.stoplight.io/) to understand how can do the above, but I got a bit lost.

Alight, overall the answer make sense.  
But I’m just unsure about the step where I have to create an “intent”, could you explain to me what exactly an intent? Bear in mind that I’m interested on a **read only** use case, so I’m afraid that creating an intent I will modify an existing entities in YCBM, and that’s not my intention.

At the end of then day I just care about getting availability, and not create any booking.

Thanks

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [May 31, 2024, 1:44pm UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797/4 "2024-05-31T13:44:54Z")

</div>

@nicor88 intents act as preselections and options for a booking and are not an actual booking, so if you only need to get read only data you would POST to the intents endpoint with the teamMemberId and then run through to get the availabilityKey for that intent, this will show you when that specific team member is available. You do not need to add a form and confirm the booking if you aren’t looking to make a booking programmatically.

---

<div class="post-metadata">

**Author:** ![nicor88](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@nicor88](https://forum.youcanbook.me/u/nicor88)\
**Post date:** [June 6, 2024, 1:16pm UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797/5 "2024-06-06T13:16:01Z")

</div>

@Ben thanks, after playing a bit more with APIs I got what an intent is.

Is it possible to get availability in the past?  
I was adding

```auto
params = {
    'startSearchAt': '2024-06-01',
}

```

as GET parameter for **availabilitykey** API request, but I always get availabilities in the future.

As we are interested on availability in the past, I put a startSearchAt in the past, but I get availabilities in the future. Is even possible to get past availabilities?

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [June 9, 2024, 9:50am UTC](https://forum.youcanbook.me/t/fetch-user-calendar-slots-availability-via-api/2797/6 "2024-06-09T09:50:34Z")

</div>

No, there is not a way to get past availability. The concept of availability on our side is a snap shot at a certain time that is requested. We don’t have a way via the API to pull in any information from the past.
