Tool Template

Cal.com Create a Booking

by Webble Templates

This tool is used to create a cal.com regular booking, recurring bookings and instant bookings.

Use Template
/**
 * @param {object} args
 * @param {string} args.start The start time of the booking in ISO 8601 format in UTC timezone.
 * @param {object} args.attendee
 * @param {string} args.attendee.name The name of the attendee.
 * @param {string} args.attendee.timeZone The time zone of the attendee.
 * @param {string} args.attendee.email
 * @param {string} args.attendee.phoneNumber
 * @param {string} args.attendee.language The preferred language of the attendee. Used for booking confirmation. e.g en, es  (ISO 639-1 standard language codes)
 * @param {object} args.bookingFieldsResponses Booking field responses consisting of an object with booking field slug as keys and user response as values for custom booking fields added by you.
 * @param {number} args.eventTypeId
 * @param {Array<any>} args.guests An optional list of guest emails attending the event.
 * @param {boolean} args.instant Optionally, for team event types it is possible to create instant meeting. To do that just pass `"instant": true` to the request body.
 * @param {string} args.lengthInMinutes If it is an event type that has multiple possible lengths that attendee can pick from, you can pass the desired booking length here.
If not provided then event type default length will be used for the booking.
 * @param {object} args.metadata You can store any additional data you want here. Metadata must have at most 50 keys, each key up to 40 characters, and string values up to 500 characters.
 * @param {string} args.apiKey
 */
async function main(args) {
  let { apiKey, ...payload } = args;
  const headers = {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
    "cal-api-version": "2024-08-13"
  }


  const result = await fetch(`https://api.cal.com/v2/bookings`, {
    headers,
    method: "POST",
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .catch(err => console.error(err));

  return { output: result };
}

Want to see more chatbot templates and resources?

View more templates