calcom/cal.diy · error · NotFoundException

User with username ${body.username} not found

Error message

User with username ${body.username} not found

What it means

Thrown in getBookedEventType when resolving an event type by username + eventTypeSlug (instead of eventTypeId) and usersRepository.findByUsername returns no user. The lookup is optionally scoped by organizationSlug, so a username existing in another org also misses. HTTP 404.

Source

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

      throw new UnauthorizedException(
        "checkBookingRequiresAuthentication - request must be authenticated by passing credentials belonging to event type owner, host or team or org admin or owner."
      );
    }

    if (!userIsEventTypeAdminOrOwner) {
      throw new ForbiddenException(
        "checkBookingRequiresAuthentication - user is not authorized to access this event type. User has to be either event type owner, host, team admin or owner or org admin or owner."
      );
    }
  }

  async getBookedEventType(body: CreateBookingInput) {
    if (body.eventTypeId) {
      return await this.eventTypesRepository.getEventTypeByIdWithOwnerAndTeam(body.eventTypeId);
    } else if (body.username && body.eventTypeSlug) {
      const user = await this.usersRepository.findByUsername(body.username, body.organizationSlug);
      if (!user) {
        throw new NotFoundException(`User with username ${body.username} not found`);
      }
      return await this.eventTypesRepository.getUserEventTypeBySlugWithOwnerAndTeam(
        user.id,
        body.eventTypeSlug
      );
    } else if (body.teamSlug && body.eventTypeSlug) {
      const team = await this.getBookedEventTypeTeam(body.teamSlug);
      if (!team) {
        throw new NotFoundException(`Team with slug ${body.teamSlug} not found`);
      }
      return await this.teamsEventTypesRepository.getEventTypeByTeamIdAndSlugWithOwnerAndTeam(
        team.id,
        body.eventTypeSlug
      );
    }
    return null;
  }

View on GitHub (pinned to 176037d0af)

Solutions

  1. Verify the username exists (and within the correct organizationSlug) before booking.
  2. If you have it, book by eventTypeId instead of username/eventTypeSlug to avoid username resolution.
  3. Double-check spelling and that the value is the username, not the email or display name.
Defensive patterns

Strategy: validation

Validate before calling

// Before booking by username/slug, confirm the user exists (within the org if applicable).
const user = await api.get(`/v2/users/${encodeURIComponent(username)}${orgSlug ? `?org=${orgSlug}` : ''}`).catch(() => null);
if (!user) throw new Error(`Username ${username} not found${orgSlug ? ` in org ${orgSlug}` : ''}`);
// Prefer booking by eventTypeId once known.

Try / catch

try {
  await api.post('/v2/bookings', { username, eventTypeSlug, organizationSlug });
} catch (err) {
  if (err.status === 404 && /username .* not found/.test(err.message)) {
    // verify the username/org, or switch to booking by eventTypeId
  }
  throw err;
}

Prevention

When it happens

Trigger: POST /v2/bookings with body.username + body.eventTypeSlug where the username does not resolve to a user (or does not exist within the supplied organizationSlug).

Common situations: Typo in username; user renamed/deleted; organizationSlug mismatch (user exists but in a different org); cross-environment username; passing an email instead of the username.

Related errors


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