{"record":{"id":"a67556a7dd3c7c5e","repo":"RocketChat/Rocket.Chat","slug":"error-user-limit-exceeded-a67556","errorCode":"error-user-limit-exceeded","errorMessage":"User Limit Exceeded","messagePattern":"User Limit Exceeded","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/slashcommands/inviteall/server.ts","lineNumber":72,"sourceCode":"\t\t\t\t}),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!(await canAccessRoomAsync(baseChannel, user))) {\n\t\t\tvoid api.broadcast('notify.ephemeralMessage', userId, message.rid, {\n\t\t\t\tmsg: i18n.t('Room_not_exist_or_not_permission', { lng }),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst APIsettings = settings.get<number>('API_User_Limit');\n\t\t\tif (!APIsettings) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((await Subscriptions.countByRoomIdWhenUsernameExists(baseChannel._id)) > APIsettings) {\n\t\t\t\tthrow new Meteor.Error('error-user-limit-exceeded', 'User Limit Exceeded', {\n\t\t\t\t\tmethod: 'addAllToRoom',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst cursor = Subscriptions.findByRoomIdWhenUsernameExists(baseChannel._id, {\n\t\t\t\tprojection: { 'u.username': 1 },\n\t\t\t});\n\t\t\tconst users = (await cursor.toArray()).map((s: ISubscription) => s.u.username).filter(isTruthy);\n\n\t\t\tif (!targetChannel && ['c', 'p'].indexOf(baseChannel.t) > -1) {\n\t\t\t\tbaseChannel.t === 'c' ? await createChannelMethod(userId, channel, users) : await createPrivateGroupMethod(user, channel, users);\n\t\t\t\tvoid api.broadcast('notify.ephemeralMessage', userId, message.rid, {\n\t\t\t\t\tmsg: i18n.t('Channel_created', {\n\t\t\t\t\t\tchannelName: channel,\n\t\t\t\t\t\tlng,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t} else {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/slashcommands/inviteall/server.ts#L54-L90","documentation":"/invite-all-from (the inviteall slash command) copies members from a base channel, but first reads the API_User_Limit setting and counts that channel's subscriptions whose user has a username. If the member count exceeds API_User_Limit it aborts with 'error-user-limit-exceeded' (method addAllToRoom) - a guard against single commands mutating huge channels. Note the surrounding logic: if API_User_Limit is unset or falsy the command returns early and does nothing, so the limit must be configured for invite-all to run at all.","triggerScenarios":"Running /invite-all-from on a channel with more members than the API_User_Limit value; workspaces where the limit was lowered after channels grew past it; automated provisioning that uses invite-all on large source channels.","commonSituations":"Community or enterprise workspaces with channels larger than the configured limit; admins tuning API_User_Limit down for load reasons and breaking invite-all flows; seed or migration scripts relying on the command.","solutions":["Raise API_User_Limit in Administration > General so it exceeds the source channel's member count","Invite users in smaller batches (or use addUsersToRoom per batch) instead of invite-all","Check the source channel's member count against the setting before running the command","If invite-all silently does nothing, confirm API_User_Limit is actually set - unset means early return"],"exampleFix":"// before\nrunSlashCommand('/invite-all-from #announcements');\n// channel has 5000 members, API_User_Limit=1000 -> error-user-limit-exceeded\n\n// after\nconst limit = settings.get<number>('API_User_Limit');\nconst members = await Subscriptions.countByRoomIdWhenUsernameExists(baseChannel._id);\nif (limit && members > limit) {\n\treturn notifyUser(`Channel has ${members} members; API_User_Limit is ${limit}. Raise the limit or invite in batches.`);\n}","handlingStrategy":"validation","validationCode":"const limit = settings.get<number>('API_User_Limit');\nconst members = await Subscriptions.countByRoomIdWhenUsernameExists(baseChannel._id);\nif (limit && members > limit) {\n\treturn notifyUser(`Source channel exceeds API_User_Limit (${members} > ${limit}); raise the limit or invite in batches`);\n}\nrunCommand('/invite-all-from', channel);","typeGuard":"const isWithinUserLimit = (members: number, limit?: number): boolean => !limit || members <= limit;","tryCatchPattern":"catch (err) {\n\tif (err instanceof Meteor.Error && err.error === 'error-user-limit-exceeded') {\n\t\t// raise API_User_Limit or fall back to batched addUsersToRoom invites\n\t} else throw err;\n}","preventionTips":["Compare the source channel's member count against API_User_Limit before running invite-all","Raise API_User_Limit deliberately for large community workspaces, noting the load implications","Remember that if API_User_Limit is unset, invite-all returns early and does nothing"],"tags":["slash-command","invite","rate-limit","admin-settings","rooms"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}