Tool Template

Cal.com Get Bookings

by Webble Templates

Use Template
/**
 * @param {object} args
 * @param {string} args.apiKey
 * @param {string} args.status Optionally filter bookings by status, e.g upcoming, recurring, past, cancelled, unconfirmed
 * @param {string} args.attendeeEmail Optionally filter by attendee email
 * @param {string} args.attendeeName Optionally filter by attendee name
 * @param {string} args.eventTypeIds Optional. Filter bookings by event type ids belonging to the user. Event type ids must be separated by a comma.
 * @param {string} args.eventTypeId Optional. Filter bookings by event type id belonging to the user.
 * @param {number} args.take The number of items to take, default 100
 * @param {number} args.skip The number of items to skip, default 0
 * @param {string} args.afterStart Optional. Filter bookings with start after this date string
 * @param {string} args.beforeEnd Optional. Filter bookings with end before this date string.
 * @param {string} args.afterCreatedAt Optional. Filter bookings that have been created after this date string.
 * @param {string} args.beforeCreatedAt Optional. Filter bookings that have been created before this date string.
 * @param {string} args.afterUpdatedAt Optional. Filter bookings that have been updated after this date string.
 * @param {string} args.beforeUpdatedAt Optional. Filter bookings that have been updated before this date string.
 * @param {string} args.teamsIds Optional. Filter bookings by team ids that user is part of. Team ids must be separated by a comma.
 * @param {string} args.teamId Optional. Filter bookings by team id that user is part of
 */
async function main(args) {
  let {apiKey, ...payload} = args;
  const headers = {
        "Authorization": `Bearer ${apiKey}`,
        "Content-Type": "application/json",
        "cal-api-version": "2024-08-13"
  }
  const searchParams = new URLSearchParams([
       ...Array.from(Object.entries(payload)), // [["a","hello"],["b","world"]]
  ]).toString();

  const result = await fetch(`https://api.cal.com/v2/bookings?${searchParams}`, { headers })
  .then(response => response.json())
  .catch(err => console.error(err));

  return {output: result};
}

Want to see more chatbot templates and resources?

View more templates