{"record":{"id":"22120590952888cb","repo":"RocketChat/Rocket.Chat","slug":"error-direct-message-max-user-exceeded","errorCode":"error-direct-message-max-user-exceeded","errorMessage":"You cannot add more than ${maxUsers} users, including yourself to a direct message","messagePattern":"You cannot add more than (.+?) users, including yourself to a direct message","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/rooms/createDirectRoom.ts","lineNumber":52,"sourceCode":"\tname,\n\tu: {\n\t\t_id: user._id,\n\t\tusername: user.username,\n\t},\n});\n\nexport async function createDirectRoom(\n\tmembers: IUser[] | string[],\n\troomExtraData: Partial<IRoom> = {},\n\toptions: {\n\t\tforceNew?: boolean;\n\t\tcreator?: IUser['_id'];\n\t\tsubscriptionExtra?: ISubscriptionExtraData;\n\t},\n): Promise<ICreatedRoom> {\n\tconst maxUsers = settings.get<number>('DirectMesssage_maxUsers') || 1;\n\tif (members.length > maxUsers) {\n\t\tthrow new Meteor.Error(\n\t\t\t'error-direct-message-max-user-exceeded',\n\t\t\t`You cannot add more than ${maxUsers} users, including yourself to a direct message`,\n\t\t\t{\n\t\t\t\tmethod: 'createDirectRoom',\n\t\t\t},\n\t\t);\n\t}\n\n\tconst membersUsernames: string[] = members\n\t\t.map((member) => {\n\t\t\tif (typeof member === 'string') {\n\t\t\t\treturn member;\n\t\t\t}\n\t\t\treturn member.username;\n\t\t})\n\t\t.filter(isTruthy);\n\n\tawait callbacks.run('beforeCreateDirectRoom', membersUsernames, roomExtraData);","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/rooms/createDirectRoom.ts#L34-L70","documentation":"Meteor.Error('error-direct-message-max-user-exceeded') thrown by createDirectRoom when members.length exceeds the 'DirectMesssage_maxUsers' setting (the setting id really has a triple 's'; the code falls back to 1 when the setting is unset or 0).","triggerScenarios":"Creating a DM whose member count is above the workspace limit: selecting multiple recipients on a workspace with a low DirectMesssage_maxUsers value, or with the setting unset so the fallback of 1 applies.","commonSituations":"Admin lowered the DM participant limit; expectations about multi-user DMs vs. the configured limit; settings migrations leaving the value unset.","solutions":["Raise the 'DirectMesssage_maxUsers' setting in the administration settings to the desired participant count and save.","Create a private channel ('p') instead of a DM for larger groups.","Cap the recipient picker in the UI to the configured limit."],"exampleFix":"// before\nawait createDirectRoom([...tenMembers]); // throws error-direct-message-max-user-exceeded\n\n// after: create a private room instead for large groups\nawait createRoom('p', name, { members: tenMembers });","handlingStrategy":"validation","validationCode":"const maxUsers = settings.get<number>('DirectMesssage_maxUsers') || 1;\nif (members.length > maxUsers) {\n  // create a private channel instead, or raise the setting\n} else {\n  await createDirectRoom(members, roomExtraData, options);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createDirectRoom(members);\n} catch (error: any) {\n  if (error?.error === 'error-direct-message-max-user-exceeded') {\n    // offer group channel creation or suggest raising DirectMesssage_maxUsers\n  }\n}","preventionTips":["Cap recipient selection in the UI at the DirectMesssage_maxUsers value.","Remember the setting id's triple 's' ('DirectMesssage_maxUsers') when scripting.","Use channels rather than DMs for group conversations beyond the limit."],"tags":["direct-messages","rooms","limits","settings"],"backgroundTag":"user-limit-exceeded","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}