{"record":{"id":"602343891bad6088","repo":"calcom/cal.diy","slug":"event-type-with-id-input-eventtypeid-not-found","errorCode":null,"errorMessage":"Event Type with ID=${input.eventTypeId} not found","messagePattern":"Event Type with ID=(.+?) not found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts","lineNumber":104,"sourceCode":"    const queryTransformed = await this.slotsInputService.transformGetSlotsQuery(query);\n    return this.fetchAndFormatSlots(queryTransformed, query.format);\n  }\n\n  async getAvailableSlotsWithRouting(query: GetSlotsInputWithRouting_2024_09_04) {\n    const queryTransformed = await this.slotsInputService.transformRoutingGetSlotsQuery(query);\n    return this.fetchAndFormatSlots(queryTransformed, query.format);\n  }\n\n  async reserveSlot(input: ReserveSlotInput_2024_09_04, authUserId?: number) {\n    if (input.reservationDuration && !authUserId) {\n      throw new UnauthorizedException(\n        \"reservationDuration can only be used for authenticated requests - use access token, api key or OAuth credentials\"\n      );\n    }\n\n    const eventType = await this.eventTypeRepository.getEventTypeWithHosts(input.eventTypeId);\n    if (!eventType) {\n      throw new NotFoundException(`Event Type with ID=${input.eventTypeId} not found`);\n    }\n\n    if (input.reservationDuration && authUserId) {\n      const canSpecifyCustomReservationDuration = await this.canSpecifyCustomReservationDuration(\n        authUserId,\n        eventType\n      );\n      if (!canSpecifyCustomReservationDuration) {\n        throw new ForbiddenException(\n          \"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.\"\n        );\n      }\n    }\n\n    const startDate = DateTime.fromISO(input.slotStart, { zone: \"utc\" });\n    if (!startDate.isValid) {\n      throw new BadRequestException(\"Invalid start date\");\n    }","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/slots/slots-2024-09-04/services/slots.service.ts#L86-L122","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fetch the event type via GET /v2/event-types and confirm the ID exists before reserving.","Ensure you pass the numeric eventTypeId, not the slug.","Confirm the API key's scope includes the event type's owner/team/org.","Map 404 to a user-facing 'event unavailable' message and refresh available event types."],"exampleFix":"// before\nfetch('/v2/slots/reserve', { body: JSON.stringify({ eventTypeId: slugOrStaleId, slotStart }) });\n\n// after\nconst et = await calApi.eventTypes.getById(realId);\nif (!et) throw new ClientError('Event type not found');\nfetch('/v2/slots/reserve', { body: JSON.stringify({ eventTypeId: et.id, slotStart }) });","handlingStrategy":"validation","validationCode":"async function assertEventTypeExists(eventTypeId: number) {\n  if (!Number.isInteger(eventTypeId) || eventTypeId <= 0) throw new TypeError('eventTypeId must be a positive integer');\n  const et = await cal.eventTypes.getById(eventTypeId);\n  if (!et) throw new ClientError(`Event type ${eventTypeId} not found`);\n  return et;\n}\nconst eventType = await assertEventTypeExists(input.eventTypeId);","typeGuard":"function isPositiveIntId(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0;\n}","tryCatchPattern":"try {\n  await cal.slots.reserve({ eventTypeId, slotStart });\n} catch (e) {\n  if (e instanceof HttpError && e.statusCode === 404) {\n    throw new UserFacingError('This event is no longer available.');\n  }\n  throw e;\n}","preventionTips":["Fetch the event type once and reuse its numeric id.","Do not pass the event type slug where the id is required.","Re-sync stored ids after environment migrations.","Treat 404 as terminal — refresh available event types."],"tags":["calcom-api","slots","not-found","event-type","reservation"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}