RocketChat/Rocket.Chat · error · Error

Invalid type

Error message

Invalid type

What it means

Thrown by GET /api/v1/livechat/users/:type when the :type URL segment is neither 'agent' nor 'manager'. Note the values are SINGULAR in current versions — older Rocket.Chat releases (< 4.x) used the plural 'agents'/'managers' on this same route, so upgraded integrations that still send the plural form get this error. Each branch also has its own permission requirement (agent list: transfer-livechat-guest or edit-omnichannel-contact; manager list: view-livechat-manager) but wrong permission yields 403, not this error.

Solutions

  1. Use the singular form: GET /api/v1/livechat/users/agent or GET /api/v1/livechat/users/manager
  2. After upgrading an old integration, audit every livechat/users/* call for plural path segments
  3. Whitelist the two accepted values in your client so bad input fails fast locally

Example fix

// before
request.get(api('livechat/users/agents')).set(credentials);
// after
request.get(api('livechat/users/agent')).set(credentials);
Defensive patterns

Strategy: validation

Validate before calling

const type = String(rawType).toLowerCase().replace(/s$/, ''); // 'agents' -> 'agent'
if (!['agent', 'manager'].includes(type)) throw new TypeError(`invalid type ${rawType}`);
await fetch(`${server}/api/v1/livechat/users/${type}`, { headers });

Type guard

type LivechatUserType = 'agent' | 'manager';
const isLivechatUserType = (t: string): t is LivechatUserType => t === 'agent' || t === 'manager';

Try / catch

const body = await (await fetch(url, { headers })).json();
if (!body.success && body.error === 'Invalid type') { /* re-map plural->singular and retry once */ }

Prevention

When it happens

Trigger: GET /api/v1/livechat/users/agents or /livechat/users/managers (plural) on a current server; typos like 'agnt'; empty type segment due to URL building bug.

Common situations: Scripts or SDK clients written against Rocket.Chat 3.x kept in service after upgrade; mixed documentation usage — some docs pages still show the plural form.

Related errors


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

Appendix: source

Thrown at apps/meteor/server/api/v1/omnichannel/users.ts:71

				);
			}
			if (this.urlParams.type === 'manager') {
				if (!(await hasAtLeastOnePermissionAsync(this.user, ['view-livechat-manager']))) {
					return API.v1.forbidden();
				}

				return API.v1.success(
					await findManagers({
						text,
						pagination: {
							offset,
							count,
							sort,
						},
					}),
				);
			}
			throw new Error('Invalid type');
		},
		async post() {
			if (this.urlParams.type === 'agent') {
				const user = await addAgent(this.bodyParams.username);
				if (user) {
					return API.v1.success({ user });
				}
			} else if (this.urlParams.type === 'manager') {
				const user = await addManager(this.bodyParams.username);
				if (user) {
					return API.v1.success({ user });
				}
			} else {
				throw new Error('Invalid type');
			}

			return API.v1.failure();
		},

View on GitHub (pinned to b2c16d5842)