calcom/cal.diy · error · BadRequestException
teamId is required for team events, please provide a valid t
Error message
teamId is required for team events, please provide a valid teamId
What it means
Thrown by EventTypesAtomService.getPublicEventTypeForAtoms when isTeamEvent is truthy but no teamId is provided. The method requires a teamId to resolve the team slug (via getTeamSlug) which serves as the URL path component for public team event types. Without it, the team slug cannot be determined and the public event lookup cannot proceed, so BadRequestException (HTTP 400) is thrown.
Source
Thrown at apps/api/v2/src/modules/atoms/services/event-types-atom.service.ts:381
async getPublicEventTypeForAtoms({
username,
eventSlug,
isTeamEvent,
orgId,
teamId,
}: {
username?: string;
eventSlug: string;
isTeamEvent?: boolean;
orgId?: number;
teamId?: number;
}): Promise<PublicEventType> {
const orgSlug = orgId ? await this.getTeamSlug(orgId) : null;
let usernameOrTeamSlug: string | null = null;
if (isTeamEvent) {
if (!teamId) {
throw new BadRequestException("teamId is required for team events, please provide a valid teamId");
}
usernameOrTeamSlug = await this.getTeamSlug(teamId);
} else {
if (!username) {
throw new BadRequestException(
"username is required for non-team events, please provide a valid username"
);
}
usernameOrTeamSlug = username;
}
usernameOrTeamSlug = usernameOrTeamSlug.toLowerCase();
try {
let event = await getPublicEvent(
usernameOrTeamSlug,
eventSlug,
isTeamEvent,View on GitHub (pinned to 176037d0af)
Solutions
- Provide a valid teamId when isTeamEvent is true: include it in the query string or request body.
- Add client-side validation: if isTeamEvent is checked, require teamId before allowing submission.
- If you don't have a teamId, set isTeamEvent to false and provide a username instead (non-team event path).
Example fix
// before: team event requested without teamId
const event = await atomsApi.getPublicEventType({
eventSlug: '30min',
isTeamEvent: true
// teamId missing
});
// after: include teamId for team events
const event = await atomsApi.getPublicEventType({
eventSlug: '30min',
isTeamEvent: true,
teamId: 42
}); Defensive patterns
Strategy: validation
Validate before calling
// Validate that teamId is present when isTeamEvent is true
const validatePublicEventRequest = (params: {
eventSlug: string;
isTeamEvent?: boolean;
teamId?: number;
username?: string;
}): void => {
if (params.isTeamEvent && !params.teamId) {
throw new Error('teamId is required when isTeamEvent is true.');
}
if (!params.isTeamEvent && !params.username) {
throw new Error('username is required when isTeamEvent is false or omitted.');
}
if (!params.eventSlug) {
throw new Error('eventSlug is required.');
}
}; Type guard
type PublicEventRequest =
| { eventSlug: string; isTeamEvent: true; teamId: number; username?: string; orgId?: number }
| { eventSlug: string; isTeamEvent?: false; username: string; teamId?: number; orgId?: number };
const isValidRequest = (p: any): p is PublicEventRequest =>
p.eventSlug && (p.isTeamEvent ? typeof p.teamId === 'number' : typeof p.username === 'string'); Prevention
- Use a discriminated union type in the client to make omitting teamId a compile-time error when isTeamEvent is true.
- Add form validation that requires teamId when the team-event toggle is enabled.
- Document the isTeamEvent/teamId/username relationship clearly in API client documentation.
When it happens
Trigger: Calling the public event-type atoms endpoint with { isTeamEvent: true } but omitting teamId from the query or body. The client sets isTeamEvent based on a flag but doesn't pass the team context. A form that defaults isTeamEvent to true without requiring teamId.
Common situations: Frontend toggle for 'team event' that doesn't validate teamId presence. API client SDK that makes teamId optional without server-side enforcement note. Copy-paste from a user-event request template that forgot to add teamId when switching to team mode. Test fixture with isTeamEvent: true but teamId missing.
Related errors
- username is required for non-team events, please provide a v
- ApiKeysService -Cannot set both apiKeyDaysValid and apiKeyNe
- Team with id ${teamId} not found
- Access denied. Either the team with ID=${teamId} does not ow
- Event type with id ${eventTypeId} not found
AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12).
Data as JSON: /api/errors/3181f0ba6c0872d1.
Report an issue: GitHub.