RocketChat/Rocket.Chat · error · Error
Only channels, private groups and direct messages can be cre
Error message
Only channels, private groups and direct messages can be created.
What it means
Thrown by AppRoomBridge.create when room.type does not match RoomType.CHANNEL, RoomType.PRIVATE_GROUP, or RoomType.DIRECT_MESSAGE. The Apps Engine room-creation surface supports only those three room kinds; any other type (or an undefined/misspelled type value) falls through the switch to the default branch and is rejected.
Source
Thrown at apps/meteor/app/apps/server/bridges/rooms.ts:75
export class AppRoomBridge extends RoomBridge {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}
protected async create(room: IRoom, members: Array<string>, appId: string): Promise<string> {
this.orch.debugLog(`The App ${appId} is creating a new room.`, room);
const rcRoom = await this.orch.getConverters()?.get('rooms').convertAppRoom(room);
switch (room.type) {
case RoomType.CHANNEL:
return this.createChannel(room.creator.id, rcRoom, members);
case RoomType.PRIVATE_GROUP:
return this.createPrivateGroup(room.creator.id, rcRoom, members);
case RoomType.DIRECT_MESSAGE:
return this.createDirectMessage(room.creator.id, members);
default:
throw new Error('Only channels, private groups and direct messages can be created.');
}
}
private prepareExtraData(room: Record<string, any>): Record<string, unknown> {
const extraData = Object.assign({}, room);
delete extraData.name;
delete extraData.t;
delete extraData.ro;
delete extraData.customFields;
return extraData;
}
private async createChannel(userId: string, room: ICoreRoom, members: string[]): Promise<string> {
return (await createChannelMethod(userId, room.name || '', members, room.ro, room.customFields, this.prepareExtraData(room))).rid;
}
private async createDirectMessage(userId: string, members: string[]): Promise<string> {View on GitHub (pinned to f9d3ec372b)
Solutions
- Set room.type using the RoomType enum from @rocket.chat/apps-engine/definition/rooms (RoomType.CHANNEL, RoomType.PRIVATE_GROUP, RoomType.DIRECT_MESSAGE).
- For livechat/omnichannel rooms, use the livechat accessor (ILivechatCreator) instead of the generic room creator.
- Map any external type code to one of the three supported enum values before calling create.
Example fix
// before
room.setType('c'); // raw letter — falls through
await modify.getCreator().startRoom(room).done();
// after
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
room.setType(RoomType.CHANNEL);
await modify.getCreator().startRoom(room).done(); Defensive patterns
Strategy: type-guard
Validate before calling
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
const SUPPORTED = new Set<RoomType>([RoomType.CHANNEL, RoomType.PRIVATE_GROUP, RoomType.DIRECT_MESSAGE]);
if (!SUPPORTED.has(room.type)) {
throw new Error(`Unsupported room type: ${room.type}. Use the livechat accessor for omni rooms.`);
}
await modify.getCreator().startRoom(room).done(); Type guard
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
function isSupportedRoomType(type: unknown): type is RoomType {
return type === RoomType.CHANNEL || type === RoomType.PRIVATE_GROUP || type === RoomType.DIRECT_MESSAGE;
} Prevention
- Always set room.type from the RoomType enum, never from raw letters or external strings.
- For livechat/omnichannel rooms use the livechat accessor, not the generic room creator.
- Map external type codes to the enum at the boundary where data enters your App.
When it happens
Trigger: An App calls the modify creator's room builder with room.type set to a livechat room type, a thread/discussion type, an omni room type, or left undefined. Also triggered by string typos like 'c' or 'p' instead of the enum constants.
Common situations: Apps that try to create omnichannel/livechat rooms via the generic room creator instead of the livechat accessor; passing raw core-typings room type letters ('c','p','d') instead of the RoomType enum; building an IRoom from a webhook payload whose type field was not mapped to the enum.
Related errors
- Invalid user
- Room id not found
- Invalid Api parameter provided, it must be a valid IApi obje
- Invalid command parameter provided, must be a string.
- Invalid Slash Command parameter provided, it must be a valid
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/d5d630164b1e779f.
Report an issue: GitHub.