Find out how to use Cal “atoms” to integrate scheduling into your product.
{ "x-cal-secret-key”: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX}
Body:
timeZone
is passed in the request, the user’s default schedule from 9AM to 5PM will be created in the specified timezone. Then, using the AvailabilitySettings
atom, user can customize their availability. However,
if the timeZone
is not passed, then user has no default schedule and user can’t be booked and user can’t set availability using the AvailabilitySettings
atom. You will have to set it up manually via the /schedules
endpoints.
We recommend setting the timeZone
for ease of use.
Q: Why do we need a separate endpoint just for this? A: Your OAuth client secret and users refresh tokens should never be exposed on the frontend. The OAuth client secret will reside as an environment variable in your backend and the users’ refresh tokens are stored in your database, which are used by our API to refresh the access token.You can check an example refresh token endpoint in our atoms examples app: https://github.com/calcom/atoms-examples/blob/main/cal-sync/src/pages/api/refresh.ts Shortly:
/refresh
endpoint./refresh
endpoint.expiresAt
date (it is a jwt token so you can decode it using some library from npm). You could have a cron job that checks all of your users refresh tokens and sees if the refresh token
is about to expire, then refresh tokens using the /refresh
endpoint./refresh
fails meaning that the
refresh token has expired, call the /force-refresh
endpoint - it allows you to refresh managed user tokens
using only the OAuth client ID and client secret and is intended to be used in cases when one of the tokens is lost or the refresh token is expired.