import type { NextApiRequest } from "next"; import handleNewBooking from "@calcom/features/bookings/lib/handleNewBooking"; import { defaultResponder } from "@calcom/lib/server"; /** * @swagger * /bookings: * post: * summary: Creates a new booking * parameters: * - in: query * name: apiKey * required: true * schema: * type: string * description: Your API key * operationId: addBooking * requestBody: * description: Create a new booking related to one of your event-types * required: true * content: * application/json: * schema: * type: object * required: * - startTime * - endTime * properties: * title: * type: string * description: 'Booking event title' * startTime: * type: string * format: date-time * description: 'Start time of the Event' * endTime: * type: string * format: date-time * description: 'End time of the Event' * recurringEventId: * type: integer * description: 'Recurring event ID if the event is recurring' * description: * type: string * description: 'Event description' * status: * type: string * description: 'Acceptable values one of ["ACCEPTED", "PENDING", "CANCELLED", "REJECTED"]' * location: * type: string * description: 'Meeting location' * smsReminderNumber: * type: number * description: 'SMS reminder number' * attendees: * type: array * description: 'List of attendees of the booking' * items: * type: object * properties: * name: * type: string * email: * type: string * format: email * timeZone: * type: string * locale: * type: string * * tags: * - bookings * responses: * 201: * description: Booking(s) created successfully. * 400: * description: | * Bad request * * * * * * * * * * * * * * * * * * * * * *
MessageCause
Booking body is invalidMissing property on booking entity.
Invalid eventTypeIdThe provided eventTypeId does not exist.
Missing recurringCountThe eventType is recurring, and no recurringCount was passed.
Invalid recurringCountThe provided recurringCount is greater than the eventType recurring config
* 401: * description: Authorization information is missing or invalid. */ async function handler(req: NextApiRequest) { const { userId, isAdmin } = req; if (isAdmin) req.userId = req.body.userId || userId; const booking = await handleNewBooking(req); return booking; } export default defaultResponder(handler);