calcom/cal.diy · error · NotFoundException

Event Type with ID=${input.eventTypeId} not found

Error message

Event Type with ID=${input.eventTypeId} not found

What it means

A NestJS NotFoundException (HTTP 404) from SlotsService_2024_09_04.reserveSlot. eventTypeRepository.getEventTypeWithHosts(input.eventTypeId) returned null — no event type with that ID exists (or it is not visible to the repository scope). The reserve flow cannot proceed without an event type to bind the slot to.

Source

Thrown at apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts:104

    const queryTransformed = await this.slotsInputService.transformGetSlotsQuery(query);
    return this.fetchAndFormatSlots(queryTransformed, query.format);
  }

  async getAvailableSlotsWithRouting(query: GetSlotsInputWithRouting_2024_09_04) {
    const queryTransformed = await this.slotsInputService.transformRoutingGetSlotsQuery(query);
    return this.fetchAndFormatSlots(queryTransformed, query.format);
  }

  async reserveSlot(input: ReserveSlotInput_2024_09_04, authUserId?: number) {
    if (input.reservationDuration && !authUserId) {
      throw new UnauthorizedException(
        "reservationDuration can only be used for authenticated requests - use access token, api key or OAuth credentials"
      );
    }

    const eventType = await this.eventTypeRepository.getEventTypeWithHosts(input.eventTypeId);
    if (!eventType) {
      throw new NotFoundException(`Event Type with ID=${input.eventTypeId} not found`);
    }

    if (input.reservationDuration && authUserId) {
      const canSpecifyCustomReservationDuration = await this.canSpecifyCustomReservationDuration(
        authUserId,
        eventType
      );
      if (!canSpecifyCustomReservationDuration) {
        throw new ForbiddenException(
          "authenticated user is not owner of event type, does not have memberships in common with owner of the event type, nor does belong to event type's team or org."
        );
      }
    }

    const startDate = DateTime.fromISO(input.slotStart, { zone: "utc" });
    if (!startDate.isValid) {
      throw new BadRequestException("Invalid start date");
    }

View on GitHub (pinned to 176037d0af)

Solutions

  1. Fetch the event type via GET /v2/event-types and confirm the ID exists before reserving.
  2. Ensure you pass the numeric eventTypeId, not the slug.
  3. Confirm the API key's scope includes the event type's owner/team/org.
  4. Map 404 to a user-facing 'event unavailable' message and refresh available event types.

Example fix

// before
fetch('/v2/slots/reserve', { body: JSON.stringify({ eventTypeId: slugOrStaleId, slotStart }) });

// after
const et = await calApi.eventTypes.getById(realId);
if (!et) throw new ClientError('Event type not found');
fetch('/v2/slots/reserve', { body: JSON.stringify({ eventTypeId: et.id, slotStart }) });
Defensive patterns

Strategy: validation

Validate before calling

async function assertEventTypeExists(eventTypeId: number) {
  if (!Number.isInteger(eventTypeId) || eventTypeId <= 0) throw new TypeError('eventTypeId must be a positive integer');
  const et = await cal.eventTypes.getById(eventTypeId);
  if (!et) throw new ClientError(`Event type ${eventTypeId} not found`);
  return et;
}
const eventType = await assertEventTypeExists(input.eventTypeId);

Type guard

function isPositiveIntId(v: unknown): v is number {
  return typeof v === 'number' && Number.isInteger(v) && v > 0;
}

Try / catch

try {
  await cal.slots.reserve({ eventTypeId, slotStart });
} catch (e) {
  if (e instanceof HttpError && e.statusCode === 404) {
    throw new UserFacingError('This event is no longer available.');
  }
  throw e;
}

Prevention

When it happens

Trigger: POST /v2/slots/reserve with an eventTypeId that does not exist, was deleted, is a draft/hidden event type not reachable through the API, or belongs to a different organization scope.

Common situations: Hardcoded eventTypeId from a stale config; using the event type's slug where an ID is expected; copying an ID between environments (dev→prod); event type deleted by the owner.

Related errors


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