{"record":{"id":"fa23e02322f9eeaf","repo":"calcom/cal.diy","slug":"event-type-with-id-body-eventtypeid-not-found","errorCode":null,"errorMessage":"Event type with id ${body.eventTypeId} not found.","messagePattern":"Event type with id (.+?) not found\\.","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-08-13/services/errors.service.ts","lineNumber":31,"sourceCode":"        `Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} not found.`\n      );\n    }\n    if (body.username && body.eventTypeSlug && body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} within organization ${body.organizationSlug} not found.`\n      );\n    }\n    if (body.teamSlug && body.eventTypeSlug && !body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to team ${body.teamSlug} not found.`\n      );\n    }\n    if (body.teamSlug && body.eventTypeSlug && body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to team ${body.teamSlug} within organization ${body.organizationSlug} not found.`\n      );\n    }\n    throw new NotFoundException(`Event type with id ${body.eventTypeId} not found.`);\n  }\n\n  handleBookingError(error: unknown, bookingTeamEventType: boolean): never {\n    const hostsUnavaile = \"One of the hosts either already has booking at this time or is not available\";\n\n    if (error instanceof Error) {\n      if (error.message === \"no_available_users_found_error\") {\n        if (bookingTeamEventType) {\n          throw new BadRequestException(hostsUnavaile);\n        }\n        throw new BadRequestException(\"User either already has booking at this time or is not available\");\n      } else if (error.message === \"booking_time_out_of_bounds_error\") {\n        throw new BadRequestException(\n          `The event type can't be booked at the \"start\" time provided. This could be because it's too soon (violating the minimum booking notice) or too far in the future (outside the event's scheduling window). Try fetching available slots first using the GET /v2/slots endpoint and then make a booking with \"start\" time equal to one of the available slots.`\n        );\n      } else if (error.message === \"Attempting to book a meeting in the past.\") {\n        throw new BadRequestException(\"Attempting to book a meeting in the past.\");\n      } else if (error.message === \"hosts_unavailable_for_booking\") {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/errors.service.ts#L13-L49","documentation":"The terminal fallback of handleEventTypeToBeBookedNotFound: thrown when none of the username/teamSlug/org branches match (typically because the caller passed eventTypeId only, or a combination the dispatcher does not recognize). NotFoundException (HTTP 404). It reports the numeric eventTypeId from the body.","triggerScenarios":"POST /v2/bookings with body containing only eventTypeId (no slug fields) where the id does not exist, was deleted, belongs to another account, or is unpublished. Also fires when an unrecognized field combination reaches the dispatcher's fallthrough.","commonSituations":"Hard-coded eventTypeId from a stale config after the event type was recreated with a new id; event type belongs to a different user/team than the authenticated API key scope; event type soft-deleted; passing eventTypeId alongside slug fields in a way that bypasses the slug branches.","solutions":["Fetch the event type via GET /v2/event-types/{eventTypeId} to confirm it exists and is in scope before booking.","Prefer slug-based booking (username/teamSlug + eventTypeSlug) over numeric ids to survive event-type recreations.","Verify the API key / OAuth client has access to the owner of that event type.","Refresh any cached eventTypeId after event-type recreation."],"exampleFix":"// before\nbody: { eventTypeId: 1234 }\n\n// after\nconst et = await api.get('/v2/event-types/1234');\nif (!et.data) throw new Error('refresh event type id');\nbody: { eventTypeId: et.data.id }","handlingStrategy":"validation","validationCode":"const et = await api.get(`/v2/event-types/${body.eventTypeId}`);\nif (!et.data) throw new Error('event type id stale — refetch');","typeGuard":"const hasOnlyEventTypeId = (b: CreateBookingInput): boolean =>\n  !!(b.eventTypeId && !b.eventTypeSlug && !b.username && !b.teamSlug);","tryCatchPattern":"try { await api.post('/v2/bookings', body); }\ncatch (e) {\n  if (e.response?.status === 404 && /Event type with id/.test(e.response.data.message)) {\n    /* refetch event types and rebuild the booking with the current id */\n  } else throw e;\n}","preventionTips":["Prefer slug-based booking over numeric ids to survive event-type recreation.","Refresh cached eventTypeId after the event type is recreated.","Confirm the API key has access to the event type's owner."],"tags":["api","bookings","event-types","not-found","nestjs"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}