calcom/cal.diy · error · BadRequestException

Can't specify 'lengthInMinutes' because event type does not

Error message

Can't specify 'lengthInMinutes' because event type does not have multiple possible lengths. Please, remove the 'lengthInMinutes' field from the request.

What it means

Thrown by InputBookingsService.validateBookingLengthInMinutes when inputBooking.lengthInMinutes is set but the event type's metadata does not define multipleDuration. BadRequestException (HTTP 400). Single-duration event types have one fixed length, so the client is not allowed to override it — the field must be omitted.

Source

Thrown at apps/api/v2/src/platform/bookings/2024-08-13/services/input.service.ts:226

          crmOwnerRecordType?: string;
        }
      | undefined
  ) {
    if (!routing) return null;

    return {
      routedTeamMemberIds: routing.teamMemberIds,
      teamMemberEmail: routing.teamMemberEmail,
      skipContactOwner: routing.skipContactOwner,
      crmAppSlug: routing.crmAppSlug,
      crmOwnerRecordType: routing.crmOwnerRecordType,
    };
  }

  validateBookingLengthInMinutes(inputBooking: CreateBookingInput_2024_08_13, eventType: EventType) {
    const eventTypeMetadata = EventTypeMetaDataSchema.parse(eventType.metadata);
    if (inputBooking.lengthInMinutes && !eventTypeMetadata?.multipleDuration) {
      throw new BadRequestException(
        "Can't specify 'lengthInMinutes' because event type does not have multiple possible lengths. Please, remove the 'lengthInMinutes' field from the request."
      );
    }
    if (
      inputBooking.lengthInMinutes &&
      !eventTypeMetadata?.multipleDuration?.includes(inputBooking.lengthInMinutes)
    ) {
      throw new BadRequestException(
        `Provided 'lengthInMinutes' is not one of the possible lengths for the event type. The possible lengths are: ${eventTypeMetadata?.multipleDuration?.join(
          ", "
        )}`
      );
    }
  }

  async createRecurringBookingRequest(
    request: Request,
    body: CreateRecurringBookingInput_2024_08_13,

View on GitHub (pinned to 176037d0af)

Solutions

  1. Remove the lengthInMinutes field from the request body for single-duration event types.
  2. Conditionally include lengthInMinutes only when the event type's metadata.multipleDuration is a non-empty array.
  3. Fetch the event type first and branch payload construction on whether multipleDuration exists.
  4. If variable length is required, convert the event type to a multi-duration event type in the dashboard.

Example fix

// before
body: { eventTypeId, start, lengthInMinutes: 30, attendee: {...} }

// after
const et = await api.get(`/v2/event-types/${eventTypeId}`);
const body = { eventTypeId, start, attendee: {...} };
if (et.data.metadata?.multipleDuration?.length) body.lengthInMinutes = 30;
Defensive patterns

Strategy: validation

Validate before calling

const et = await api.get(`/v2/event-types/${eventTypeId}`);
const multi = et.data.metadata?.multipleDuration;
const bodyToSend = multi?.length ? { ...body, lengthInMinutes: body.lengthInMinutes } : (() => { const { lengthInMinutes, ...rest } = body; return rest; })();

Type guard

const isMultiDuration = (et: { metadata?: { multipleDuration?: number[] } }): boolean =>
  Array.isArray(et.metadata?.multipleDuration) && (et.metadata?.multipleDuration?.length ?? 0) > 0;

Try / catch

try { await api.post('/v2/bookings', body); }
catch (e) {
  if (e.response?.status === 400 && /Can't specify 'lengthInMinutes'/.test(e.response.data.message)) {
    const { lengthInMinutes, ...rest } = body;
    await api.post('/v2/bookings', rest);
  } else throw e;
}

Prevention

When it happens

Trigger: POST /v2/bookings (or /recurring) with a lengthInMinutes field against an event type whose metadata.multipleDuration is absent/empty. Single-length event types derive duration solely from eventType.length; the API rejects any client-supplied duration.

Common situations: Client code sends lengthInMinutes unconditionally for all event types; event type was changed from multi-duration to single-duration; copy/pasted booking payload from a multi-duration event type; misunderstanding that lengthInMinutes is only valid when the event type advertises multiple durations.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/1219d7d8f8f10219. Report an issue: GitHub.