RocketChat/Rocket.Chat · error · Meteor.Error

invalid-number-of-uses

invalid-number-of-uses

Error message

Invite should be valid for 1, 5, 10, 25, 50, 100 or infinite (0) uses.

What it means

Error "Invite should be valid for 1, 5, 10, 25, 50, 100 or infinite (0) uses." thrown in RocketChat/Rocket.Chat.

Source

Thrown at apps/meteor/server/lib/rooms/invites/findOrCreateInvite.ts:86

			method: 'findOrCreateInvite',
			field: 'rid',
		});
	}

	if (!(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.INVITE, userId))) {
		throw new Meteor.Error('error-room-type-not-allowed', 'Cannot create invite links for this room type', {
			method: 'findOrCreateInvite',
		});
	}

	const { days = 1, maxUses = 0 } = invite;

	if (!possibleDays.includes(days)) {
		throw new Meteor.Error('invalid-number-of-days', 'Invite should expire in 1, 7, 15 or 30 days, or send 0 to never expire.');
	}

	if (!possibleUses.includes(maxUses)) {
		throw new Meteor.Error('invalid-number-of-uses', 'Invite should be valid for 1, 5, 10, 25, 50, 100 or infinite (0) uses.');
	}

	// Before anything, let's check if there's an existing invite with the same settings for the same channel and user and that has not yet expired.
	const existing = await Invites.findOneByUserRoomMaxUsesAndExpiration(userId, invite.rid, maxUses, days);

	// If an existing invite was found, return it's _id instead of creating a new one.
	if (existing) {
		existing.url = getInviteUrl(existing);
		return existing;
	}

	const _id = Random.id(6);

	// insert invite
	const createdAt = new Date();
	let expires = null;
	if (days > 0) {
		expires = new Date(createdAt);

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Pass one of the allowed maxUses values: 1, 5, 10, 25, 50, 100, or 0 for unlimited uses.

When it happens

Trigger: Thrown when the requested max number of invite uses is not one of the allowed values 1, 5, 10, 25, 50, 100, or 0 (infinite).

Common situations: See trigger scenarios.


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/48cdb7a605763157. Report an issue: GitHub.