RocketChat/Rocket.Chat · error · Error

error-invalid-user

Error message

error-invalid-user

What it means

Thrown by POST /api/v1/livechat/transcript/:rid when the authenticated user id (from the auth token headers) does not resolve to a document in the Users collection. The endpoint loads the requesting user to attach them to the transcript request; a null result means the credentials point at a deleted or otherwise missing user.

Solutions

  1. Re-login and obtain a fresh X-Auth-Token/X-User-Id pair (POST /api/v1/login) for an existing user with view-livechat-manager permission
  2. Verify the credentials work at all with GET /api/v1/me — if that also fails the account/token is gone
  3. If the user was deleted by mistake, restore it or create a dedicated service account for the integration and use its token
Defensive patterns

Strategy: validation

Validate before calling

const me = await (await fetch(`${server}/api/v1/me`, { headers })).json();
if (!me?.success) await relogin(); // token/user no longer valid — do not call transcript yet
await requestTranscript(rid);

Try / catch

const body = await (await fetch(url, { method: 'POST', headers })).json();
if (!body.success && body.error === 'error-invalid-user') { /* credentials stale: re-login and retry once with a fresh token */ }

Prevention

When it happens

Trigger: The user was deleted (or merged into another user) after the REST session/token was issued, and a client keeps sending the old X-User-Id/X-Auth-Token pair; a token minted in one environment used against another.

Common situations: Long-lived integration credentials whose owner account was removed during offboarding; restored database where users collection and tokens are out of sync; scripts with a hardcoded user id after a re-install.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


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

Appendix: source

Thrown at apps/meteor/server/api/v1/omnichannel/transcript.ts:65

			if (!(await Omnichannel.isWithinMACLimit(room))) {
				throw new Error('error-mac-limit-reached');
			}

			await LivechatRooms.unsetEmailTranscriptRequestedByRoomId(rid);

			return API.v1.success();
		},
		async post() {
			const { rid } = this.urlParams;
			const { email, subject } = this.bodyParams;

			const user = await Users.findOneById(this.userId, {
				projection: { _id: 1, username: 1, name: 1, utcOffset: 1 },
			});

			if (!user) {
				throw new Error('error-invalid-user');
			}

			await requestTranscript({ rid, email, subject, user });

			return API.v1.success();
		},
	},
);

View on GitHub (pinned to b2c16d5842)