RocketChat/Rocket.Chat · error · Meteor.Error
error-user-limit-exceeded
error-user-limit-exceeded
Error message
User Limit Exceeded
What it means
/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.
Source
Thrown at apps/meteor/server/slashcommands/inviteall/server.ts:72
}),
});
return;
}
if (!(await canAccessRoomAsync(baseChannel, user))) {
void api.broadcast('notify.ephemeralMessage', userId, message.rid, {
msg: i18n.t('Room_not_exist_or_not_permission', { lng }),
});
return;
}
try {
const APIsettings = settings.get<number>('API_User_Limit');
if (!APIsettings) {
return;
}
if ((await Subscriptions.countByRoomIdWhenUsernameExists(baseChannel._id)) > APIsettings) {
throw new Meteor.Error('error-user-limit-exceeded', 'User Limit Exceeded', {
method: 'addAllToRoom',
});
}
const cursor = Subscriptions.findByRoomIdWhenUsernameExists(baseChannel._id, {
projection: { 'u.username': 1 },
});
const users = (await cursor.toArray()).map((s: ISubscription) => s.u.username).filter(isTruthy);
if (!targetChannel && ['c', 'p'].indexOf(baseChannel.t) > -1) {
baseChannel.t === 'c' ? await createChannelMethod(userId, channel, users) : await createPrivateGroupMethod(user, channel, users);
void api.broadcast('notify.ephemeralMessage', userId, message.rid, {
msg: i18n.t('Channel_created', {
channelName: channel,
lng,
}),
});
} else {View on GitHub (pinned to b2c16d5842)
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
Example fix
// before
runSlashCommand('/invite-all-from #announcements');
// channel has 5000 members, API_User_Limit=1000 -> error-user-limit-exceeded
// after
const limit = settings.get<number>('API_User_Limit');
const members = await Subscriptions.countByRoomIdWhenUsernameExists(baseChannel._id);
if (limit && members > limit) {
return notifyUser(`Channel has ${members} members; API_User_Limit is ${limit}. Raise the limit or invite in batches.`);
} Defensive patterns
Strategy: validation
Validate before calling
const limit = settings.get<number>('API_User_Limit');
const members = await Subscriptions.countByRoomIdWhenUsernameExists(baseChannel._id);
if (limit && members > limit) {
return notifyUser(`Source channel exceeds API_User_Limit (${members} > ${limit}); raise the limit or invite in batches`);
}
runCommand('/invite-all-from', channel); Type guard
const isWithinUserLimit = (members: number, limit?: number): boolean => !limit || members <= limit;
Try / catch
catch (err) {
if (err instanceof Meteor.Error && err.error === 'error-user-limit-exceeded') {
// raise API_User_Limit or fall back to batched addUsersToRoom invites
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error-not-allowed
- error-room-type-not-archivable
- error-not-authorized
- error-user-not-found
- Only channels, private groups and direct messages can be cre
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/a67556a7dd3c7c5e.
Report an issue: GitHub.